Thread (5 messages) flat view 5 messages, 2 authors, 2012-06-21

Re: [PATCH] SPI: at25: Parse dt settings

From: Ivo Sieben <hidden>
Date: 2012-06-21 09:55:21
Also in: lkml

Hi,

2012/6/14 Alexandre Pereira da Silva [off-list ref]:
quoted hunk ↗ jump to hunk
@@ -305,25 +305,54 @@ static ssize_t at25_mem_write(struct memory_accessor *mem, const char *buf,
+       if (!spi->dev.platform_data) {
+               if (np) {
+                       u32 val;
+
+                       memset(&chip, 0, sizeof(chip));
+                       strncpy(chip.name, np->name, 10);
+
+                       err = of_property_read_u32(np, "at25,byte-len", &val);
+                       if (err) {
+                               dev_dbg(&spi->dev, "invalid chip dt description\n");
+                               goto fail;
+                       }
+                       chip.byte_len = val;
+
+                       err = of_property_read_u32(np, "at25,addr-mode", &val);
+                       if (err) {
+                               dev_dbg(&spi->dev, "invalid chip dt description\n");
+                               goto fail;
+                       }
+                       chip.flags = (u16)val;
+
+                       err = of_property_read_u32(np, "at25,page-size", &val);
+                       if (err) {
+                               dev_dbg(&spi->dev, "invalid chip dt description\n");
+                               goto fail;
+                       }
+                       chip.page_size = (u16)val;
+               } else {
+                       dev_dbg(&spi->dev, "no chip description\n");
+                       err = -ENODEV;
+                       goto fail;
+               }
+       } else
+               chip = *(struct spi_eeprom *)spi->dev.platform_data;
One small remark:
In case of platform_data, the "if (!chip)" check has been removed and
is now only handled in the device tree initialization.
Maybe add this check to the platform initialization as well:

} else {
        if (!spi->dev.platform_data) {
                dev_dbg(&spi->dev, "no chip description\n");
                err = -ENODEV;
                goto fail;
        }
        chip =  *(struct spi_eeprom *)spi->dev.platform_data;
}

Furthermore looks good to me...
(Note: I am not familiar with device trees, so I cannot judge that
part of this patch)

Regards,
Ivo Sieben
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help