Skip to content

Commit 07c8888

Browse files
ambarusPratyush Yadav
authored andcommitted
mtd: spi-nor: use local variable for struct device
Use a local variable for the struct device pointers to avoid dereferencing. Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> Reviewed-by: Pratyush Yadav <pratyush@kernel.org> Signed-off-by: Pratyush Yadav <pratyush@kernel.org> Link: https://lore.kernel.org/r/20241111111946.9048-2-tudor.ambarus@linaro.org
1 parent e7f4e92 commit 07c8888

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/mtd/spi-nor/core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,7 +3576,8 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
35763576
static int spi_nor_probe(struct spi_mem *spimem)
35773577
{
35783578
struct spi_device *spi = spimem->spi;
3579-
struct flash_platform_data *data = dev_get_platdata(&spi->dev);
3579+
struct device *dev = &spi->dev;
3580+
struct flash_platform_data *data = dev_get_platdata(dev);
35803581
struct spi_nor *nor;
35813582
/*
35823583
* Enable all caps by default. The core will mask them after
@@ -3586,13 +3587,13 @@ static int spi_nor_probe(struct spi_mem *spimem)
35863587
char *flash_name;
35873588
int ret;
35883589

3589-
nor = devm_kzalloc(&spi->dev, sizeof(*nor), GFP_KERNEL);
3590+
nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL);
35903591
if (!nor)
35913592
return -ENOMEM;
35923593

35933594
nor->spimem = spimem;
3594-
nor->dev = &spi->dev;
3595-
spi_nor_set_flash_node(nor, spi->dev.of_node);
3595+
nor->dev = dev;
3596+
spi_nor_set_flash_node(nor, dev->of_node);
35963597

35973598
spi_mem_set_drvdata(spimem, nor);
35983599

@@ -3628,9 +3629,8 @@ static int spi_nor_probe(struct spi_mem *spimem)
36283629
*/
36293630
if (nor->params->page_size > PAGE_SIZE) {
36303631
nor->bouncebuf_size = nor->params->page_size;
3631-
devm_kfree(nor->dev, nor->bouncebuf);
3632-
nor->bouncebuf = devm_kmalloc(nor->dev,
3633-
nor->bouncebuf_size,
3632+
devm_kfree(dev, nor->bouncebuf);
3633+
nor->bouncebuf = devm_kmalloc(dev, nor->bouncebuf_size,
36343634
GFP_KERNEL);
36353635
if (!nor->bouncebuf)
36363636
return -ENOMEM;

0 commit comments

Comments
 (0)