On Thu, Jul 30, 2015 at 05:32:01PM +0200, Jan Luebbe wrote: > This driver is based on the Linux driver (v4.0). > > Signed-off-by: Jan Luebbe <jluebbe@xxxxxxxxxx> > --- > Changes from v1: > - Fix style problems reported by checkpatch (reported by Antony Pavlov). > > + *nand_davinci_get_pdata(struct device_d *dev) > +{ > + struct davinci_nand_pdata *pdata; > + const char *mode; > + u32 prop; > + > + pdata = kzalloc(sizeof(struct davinci_nand_pdata), > + GFP_KERNEL); > + if (!pdata) > + return ERR_PTR(-ENOMEM); > + if (!of_property_read_u32(dev->device_node, > + "ti,davinci-chipselect", &prop)) > + pdata->chipsel = prop; > + else > + return ERR_PTR(-EINVAL); > + > + if (!of_property_read_u32(dev->device_node, > + "ti,davinci-mask-ale", &prop)) > + pdata->mask_ale = prop; > + if (!of_property_read_u32(dev->device_node, > + "ti,davinci-mask-cle", &prop)) > + pdata->mask_cle = prop; > + if (!of_property_read_u32(dev->device_node, > + "ti,davinci-mask-chipsel", &prop)) > + pdata->mask_chipsel = prop; > + if (!of_property_read_string(dev->device_node, > + "nand-ecc-mode", &mode) || > + !of_property_read_string(dev->device_node, > + "ti,davinci-ecc-mode", &mode)) { We have of_get_nand_ecc_mode(). How about adding an optional propname argument to it and using it here? > + if (!strncmp("none", mode, 4)) > + pdata->ecc_mode = NAND_ECC_NONE; > + if (!strncmp("soft", mode, 4)) > + pdata->ecc_mode = NAND_ECC_SOFT; > + if (!strncmp("hw", mode, 2)) > + pdata->ecc_mode = NAND_ECC_HW; > + } > + if (!of_property_read_u32(dev->device_node, > + "ti,davinci-ecc-bits", &prop)) > + pdata->ecc_bits = prop; > + > + prop = of_get_nand_bus_width(dev->device_node); > + if (0 < prop || !of_property_read_u32(dev->device_node, > + "ti,davinci-nand-buswidth", &prop)) > + if (prop == 16) > + pdata->options |= NAND_BUSWIDTH_16; > + if (of_property_read_bool(dev->device_node, > + "nand-on-flash-bbt") || of_get_nand_on_flash_bbt()? > + of_property_read_bool(dev->device_node, > + "ti,davinci-nand-use-bbt")) > + pdata->bbt_options = NAND_BBT_USE_FLASH; > + > + if (of_device_is_compatible(dev->device_node, > + "ti,keystone-nand")) { > + pdata->options |= NAND_NO_SUBPAGE_WRITE; > + } > + return pdata; > +} > + > +static int nand_davinci_probe(struct device_d *dev) > +{ > + struct davinci_nand_pdata *pdata; > + struct davinci_nand_info *info; > + int ret; > + uint32_t val; > + nand_ecc_modes_t ecc_mode; > + > + pdata = nand_davinci_get_pdata(dev); Could you strip the pdata leftovers a bit more? Since this driver is device tree only it's a bit odd that all data is first parsed into a separately allocated struct davinci_nand_pdata * from where it is then moved to it's final destination in struct davinci_nand_info. -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox