Message ID | 20241029102238.44673-2-tudor.ambarus@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [RESEND,v4,1/2] dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply | expand |
On Tue, Oct 29 2024, Tudor Ambarus wrote: > From: Peng Fan <peng.fan@nxp.com> > > SPI NOR flashes needs power supply to work properly. The power supply > maybe software controllable per board design. So add the support > for an vcc-supply regulator. > > Signed-off-by: Peng Fan <peng.fan@nxp.com> > Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> > [ta: move devm_regulator_get_enable() to spi_nor_probe(). Add local dev > variable to avoid dereferences.] > Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
On 11/11/24 2:02 PM, Pratyush Yadav wrote: > On Tue, Oct 29 2024, Tudor Ambarus wrote: > >> From: Peng Fan <peng.fan@nxp.com> >> >> SPI NOR flashes needs power supply to work properly. The power supply >> maybe software controllable per board design. So add the support >> for an vcc-supply regulator. >> >> Signed-off-by: Peng Fan <peng.fan@nxp.com> >> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> >> [ta: move devm_regulator_get_enable() to spi_nor_probe(). Add local dev >> variable to avoid dereferences.] >> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> > > Reviewed-by: Pratyush Yadav <pratyush@kernel.org> > thanks, Pratyush. I sent a v5 here, where I introduce the temporary variable to struct device in its dedicated patch. Would you mind adding the R-b tag there? https://lore.kernel.org/linux-mtd/20241111111946.9048-1-tudor.ambarus@linaro.org/ btw, I try to keep patchwork in sync, so you can see the status of patches there as well: https://patchwork.ozlabs.org/project/linux-mtd/list/?series=&submitter=&state=&q=spi-nor&archive=&delegate= Thanks!
On Tue, Nov 12 2024, Tudor Ambarus wrote: > On 11/11/24 2:02 PM, Pratyush Yadav wrote: >> On Tue, Oct 29 2024, Tudor Ambarus wrote: >> >>> From: Peng Fan <peng.fan@nxp.com> >>> >>> SPI NOR flashes needs power supply to work properly. The power supply >>> maybe software controllable per board design. So add the support >>> for an vcc-supply regulator. >>> >>> Signed-off-by: Peng Fan <peng.fan@nxp.com> >>> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> >>> [ta: move devm_regulator_get_enable() to spi_nor_probe(). Add local dev >>> variable to avoid dereferences.] >>> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> >> >> Reviewed-by: Pratyush Yadav <pratyush@kernel.org> >> > > thanks, Pratyush. I sent a v5 here, where I introduce the temporary > variable to struct device in its dedicated patch. Would you mind adding > the R-b tag there? > https://lore.kernel.org/linux-mtd/20241111111946.9048-1-tudor.ambarus@linaro.org/ Ah, I missed that in the many emails in by mailbox. Will take a look. > > btw, I try to keep patchwork in sync, so you can see the status of > patches there as well: > > https://patchwork.ozlabs.org/project/linux-mtd/list/?series=&submitter=&state=&q=spi-nor&archive=&delegate= > > Thanks!
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index b6f374ded390..29441f2bab5d 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -17,6 +17,7 @@ #include <linux/mtd/spi-nor.h> #include <linux/mutex.h> #include <linux/of_platform.h> +#include <linux/regulator/consumer.h> #include <linux/sched/task_stack.h> #include <linux/sizes.h> #include <linux/slab.h> @@ -3576,7 +3577,8 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor) static int spi_nor_probe(struct spi_mem *spimem) { struct spi_device *spi = spimem->spi; - struct flash_platform_data *data = dev_get_platdata(&spi->dev); + struct device *dev = &spi->dev; + struct flash_platform_data *data = dev_get_platdata(dev); struct spi_nor *nor; /* * Enable all caps by default. The core will mask them after @@ -3586,12 +3588,16 @@ static int spi_nor_probe(struct spi_mem *spimem) char *flash_name; int ret; - nor = devm_kzalloc(&spi->dev, sizeof(*nor), GFP_KERNEL); + ret = devm_regulator_get_enable(dev, "vcc"); + if (ret) + return ret; + + nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL); if (!nor) return -ENOMEM; nor->spimem = spimem; - nor->dev = &spi->dev; + nor->dev = dev; spi_nor_set_flash_node(nor, spi->dev.of_node); spi_mem_set_drvdata(spimem, nor);