On 23/04/2022 05:46, Jonathan Bakker wrote: > From: Tomasz Figa <tomasz.figa@xxxxxxxxx> > > This patch adds support for instantation using Device Tree. > > Signed-off-by: Tomasz Figa <tomasz.figa@xxxxxxxxx> > Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@xxxxxxxxx> > Signed-off-by: Jonathan Bakker <xc-racer2@xxxxxxx> > > --- > Changes from previous patchset > - Adjust to having a nand child node as per binding feedback > --- > drivers/mtd/nand/onenand/onenand_samsung.c | 67 +++++++++++++++++++++- > 1 file changed, 65 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/nand/onenand/onenand_samsung.c b/drivers/mtd/nand/onenand/onenand_samsung.c > index 62014f8d27b6..0108c8c75d5b 100644 > --- a/drivers/mtd/nand/onenand/onenand_samsung.c > +++ b/drivers/mtd/nand/onenand/onenand_samsung.c > @@ -22,6 +22,7 @@ > #include <linux/dma-mapping.h> > #include <linux/interrupt.h> > #include <linux/io.h> > +#include <linux/of.h> > > #include "samsung.h" > > @@ -832,8 +833,36 @@ static void s3c_onenand_setup(struct mtd_info *mtd) > this->write_bufferram = onenand_write_bufferram; > } > > +#ifdef CONFIG_OF > +static const struct of_device_id s3c_onenand_of_match[] = { > + { .compatible = "samsung,s3c6400-onenand", > + .data = (void *)TYPE_S3C6400 }, > + { .compatible = "samsung,s3c6410-onenand", > + .data = (void *)TYPE_S3C6410 }, > + { .compatible = "samsung,s5pv210-onenand", > + .data = (void *)TYPE_S5PC110 }, > + {}, > +}; > +MODULE_DEVICE_TABLE(of, onenand_s3c_dt_match); > +#endif > + > +static enum soc_type s3c_onenand_get_device_id(struct platform_device *pdev) > +{ > + struct device_node *np = pdev->dev.of_node; > + > + if (IS_ENABLED(CONFIG_OF) && np) { > + const struct of_device_id *match; > + > + match = of_match_node(s3c_onenand_of_match, np); > + return (enum soc_type)match->data; > + } This can be simpler: if (dev_of_node(&pdev->dev)) return of_device_get_match_data(&pdev->dev); This allows you to put the of_device_id table in usual place, so just before the platform_driver structure. > + > + return platform_get_device_id(pdev)->driver_data; > +} > + > static int s3c_onenand_probe(struct platform_device *pdev) > { > + struct device_node *np = pdev->dev.of_node; dev_of_node() Best regards, Krzysztof