Skip to content

Commit

Permalink
spi: Clean up probe and remove functions
Browse files Browse the repository at this point in the history
While backporting 33cf00e ("spi: attach/detach SPI device to the ACPI
power domain"), I noticed that the code changes were suboptimal:

* Why use &spi->dev when we have dev at hand?

* After fixing the above, spi is used only once, so we don't really
  need a local variable for it.

This results in the following clean-up.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Jean Delvare authored and Mark Brown committed Feb 14, 2014
1 parent 38dbfb5 commit aec35f4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,25 +255,23 @@ EXPORT_SYMBOL_GPL(spi_bus_type);
static int spi_drv_probe(struct device *dev)
{
const struct spi_driver *sdrv = to_spi_driver(dev->driver);
struct spi_device *spi = to_spi_device(dev);
int ret;

acpi_dev_pm_attach(&spi->dev, true);
ret = sdrv->probe(spi);
acpi_dev_pm_attach(dev, true);
ret = sdrv->probe(to_spi_device(dev));
if (ret)
acpi_dev_pm_detach(&spi->dev, true);
acpi_dev_pm_detach(dev, true);

return ret;
}

static int spi_drv_remove(struct device *dev)
{
const struct spi_driver *sdrv = to_spi_driver(dev->driver);
struct spi_device *spi = to_spi_device(dev);
int ret;

ret = sdrv->remove(spi);
acpi_dev_pm_detach(&spi->dev, true);
ret = sdrv->remove(to_spi_device(dev));
acpi_dev_pm_detach(dev, true);

return ret;
}
Expand Down

0 comments on commit aec35f4

Please sign in to comment.