Skip to content

Commit 06b010d

Browse files
andy-shevbroonie
authored andcommitted
spi: microchip-core: Utilise temporary variable for struct device
Add a temporary variable to keep a pointer to struct device. Utilise it where it makes sense. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Prajna Rajendra Kumar <prajna.rajendrakumar@microchip.com> Link: https://patch.msgid.link/20251126075558.2035012-5-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 274b345 commit 06b010d

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

drivers/spi/spi-microchip-core-spi.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -296,55 +296,56 @@ static int mchp_corespi_transfer_one(struct spi_controller *host,
296296
static int mchp_corespi_probe(struct platform_device *pdev)
297297
{
298298
const char *protocol = "motorola";
299+
struct device *dev = &pdev->dev;
299300
struct spi_controller *host;
300301
struct mchp_corespi *spi;
301302
struct resource *res;
302303
u32 num_cs, mode, frame_size;
303304
bool assert_ssel;
304305
int ret = 0;
305306

306-
host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi));
307+
host = devm_spi_alloc_host(dev, sizeof(*spi));
307308
if (!host)
308309
return -ENOMEM;
309310

310311
platform_set_drvdata(pdev, host);
311312

312-
if (of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs))
313+
if (of_property_read_u32(dev->of_node, "num-cs", &num_cs))
313314
num_cs = MCHP_CORESPI_MAX_CS;
314315

315316
/*
316317
* Protocol: CFG_MODE
317318
* CoreSPI can be configured for Motorola, TI or NSC.
318319
* The current driver supports only Motorola mode.
319320
*/
320-
ret = of_property_read_string(pdev->dev.of_node, "microchip,protocol-configuration",
321+
ret = of_property_read_string(dev->of_node, "microchip,protocol-configuration",
321322
&protocol);
322323
if (ret && ret != -EINVAL)
323-
return dev_err_probe(&pdev->dev, ret, "Error reading protocol-configuration\n");
324+
return dev_err_probe(dev, ret, "Error reading protocol-configuration\n");
324325
if (strcmp(protocol, "motorola") != 0)
325-
return dev_err_probe(&pdev->dev, -EINVAL,
326+
return dev_err_probe(dev, -EINVAL,
326327
"CoreSPI: protocol '%s' not supported by this driver\n",
327328
protocol);
328329

329330
/*
330331
* Motorola mode (0-3): CFG_MOT_MODE
331332
* Mode is fixed in the IP configurator.
332333
*/
333-
ret = of_property_read_u32(pdev->dev.of_node, "microchip,motorola-mode", &mode);
334+
ret = of_property_read_u32(dev->of_node, "microchip,motorola-mode", &mode);
334335
if (ret)
335336
mode = MCHP_CORESPI_DEFAULT_MOTOROLA_MODE;
336337
else if (mode > 3)
337-
return dev_err_probe(&pdev->dev, -EINVAL,
338+
return dev_err_probe(dev, -EINVAL,
338339
"invalid 'microchip,motorola-mode' value %u\n", mode);
339340

340341
/*
341342
* Frame size: CFG_FRAME_SIZE
342343
* The hardware allows frame sizes <= APB data width.
343344
* However, this driver currently only supports 8-bit frames.
344345
*/
345-
ret = of_property_read_u32(pdev->dev.of_node, "microchip,frame-size", &frame_size);
346+
ret = of_property_read_u32(dev->of_node, "microchip,frame-size", &frame_size);
346347
if (!ret && frame_size != 8)
347-
return dev_err_probe(&pdev->dev, -EINVAL,
348+
return dev_err_probe(dev, -EINVAL,
348349
"CoreSPI: frame size %u not supported by this driver\n",
349350
frame_size);
350351

@@ -354,9 +355,9 @@ static int mchp_corespi_probe(struct platform_device *pdev)
354355
* To prevent CS deassertion when TX FIFO drains, the ssel-active property
355356
* keeps CS asserted for the full SPI transfer.
356357
*/
357-
assert_ssel = of_property_read_bool(pdev->dev.of_node, "microchip,ssel-active");
358+
assert_ssel = of_property_read_bool(dev->of_node, "microchip,ssel-active");
358359
if (!assert_ssel)
359-
return dev_err_probe(&pdev->dev, -EINVAL,
360+
return dev_err_probe(dev, -EINVAL,
360361
"hardware must enable 'microchip,ssel-active' to keep CS asserted for the SPI transfer\n");
361362

362363
spi = spi_controller_get_devdata(host);
@@ -368,9 +369,9 @@ static int mchp_corespi_probe(struct platform_device *pdev)
368369
host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
369370
host->transfer_one = mchp_corespi_transfer_one;
370371
host->set_cs = mchp_corespi_set_cs;
371-
host->dev.of_node = pdev->dev.of_node;
372+
host->dev.of_node = dev->of_node;
372373

373-
ret = of_property_read_u32(pdev->dev.of_node, "fifo-depth", &spi->fifo_depth);
374+
ret = of_property_read_u32(dev->of_node, "fifo-depth", &spi->fifo_depth);
374375
if (ret)
375376
spi->fifo_depth = MCHP_CORESPI_DEFAULT_FIFO_DEPTH;
376377

@@ -382,24 +383,21 @@ static int mchp_corespi_probe(struct platform_device *pdev)
382383
if (spi->irq < 0)
383384
return spi->irq;
384385

385-
ret = devm_request_irq(&pdev->dev, spi->irq, mchp_corespi_interrupt,
386-
IRQF_SHARED, dev_name(&pdev->dev), host);
386+
ret = devm_request_irq(dev, spi->irq, mchp_corespi_interrupt, IRQF_SHARED,
387+
dev_name(dev), host);
387388
if (ret)
388-
return dev_err_probe(&pdev->dev, ret,
389-
"could not request irq\n");
389+
return dev_err_probe(dev, ret, "could not request irq\n");
390390

391-
spi->clk = devm_clk_get_enabled(&pdev->dev, NULL);
391+
spi->clk = devm_clk_get_enabled(dev, NULL);
392392
if (IS_ERR(spi->clk))
393-
return dev_err_probe(&pdev->dev, PTR_ERR(spi->clk),
394-
"could not get clk\n");
393+
return dev_err_probe(dev, PTR_ERR(spi->clk), "could not get clk\n");
395394

396395
mchp_corespi_init(host, spi);
397396

398-
ret = devm_spi_register_controller(&pdev->dev, host);
397+
ret = devm_spi_register_controller(dev, host);
399398
if (ret) {
400399
mchp_corespi_disable(spi);
401-
return dev_err_probe(&pdev->dev, ret,
402-
"unable to register host for CoreSPI controller\n");
400+
return dev_err_probe(dev, ret, "unable to register host for CoreSPI controller\n");
403401
}
404402

405403
return 0;

0 commit comments

Comments
 (0)