From db9ef449aaa550389008c2020fba02e4440ce24b Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Sat, 14 Dec 2013 17:03:12 +0400 Subject: mfd: mc13xxx: Simplify probe() & remove() This patch simplifies probe() and remove() functions by moving some initialisation code out from the I2C/SPI init() and exit() functions and into the core driver. Signed-off-by: Alexander Shiyan Signed-off-by: Lee Jones --- drivers/mfd/mc13xxx-spi.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'drivers/mfd/mc13xxx-spi.c') diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c index cbcc86d9b6e..38ab6782979 100644 --- a/drivers/mfd/mc13xxx-spi.c +++ b/drivers/mfd/mc13xxx-spi.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -129,26 +128,24 @@ static struct regmap_bus regmap_mc13xxx_bus = { static int mc13xxx_spi_probe(struct spi_device *spi) { struct mc13xxx *mc13xxx; - struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev); int ret; mc13xxx = devm_kzalloc(&spi->dev, sizeof(*mc13xxx), GFP_KERNEL); if (!mc13xxx) return -ENOMEM; - spi_set_drvdata(spi, mc13xxx); + dev_set_drvdata(&spi->dev, mc13xxx); + spi->mode = SPI_MODE_0 | SPI_CS_HIGH; - mc13xxx->dev = &spi->dev; - mutex_init(&mc13xxx->lock); + mc13xxx->irq = spi->irq; mc13xxx->regmap = devm_regmap_init(&spi->dev, ®map_mc13xxx_bus, &spi->dev, &mc13xxx_regmap_spi_config); if (IS_ERR(mc13xxx->regmap)) { ret = PTR_ERR(mc13xxx->regmap); - dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n", - ret); + dev_err(&spi->dev, "Failed to initialize regmap: %d\n", ret); return ret; } @@ -163,16 +160,12 @@ static int mc13xxx_spi_probe(struct spi_device *spi) mc13xxx->variant = (void *)id_entry->driver_data; } - return mc13xxx_common_init(mc13xxx, pdata, spi->irq); + return mc13xxx_common_init(&spi->dev); } static int mc13xxx_spi_remove(struct spi_device *spi) { - struct mc13xxx *mc13xxx = spi_get_drvdata(spi); - - mc13xxx_common_cleanup(mc13xxx); - - return 0; + return mc13xxx_common_exit(&spi->dev); } static struct spi_driver mc13xxx_spi_driver = { -- cgit v1.2.3-70-g09d2