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

From: Ivo Sieben
Date: Thu Jun 21 2012 - 05:55:14 EST


Hi,

2012/6/14 Alexandre Pereira da Silva <aletes.xgr@xxxxxxxxx>:
> @@ -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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/