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-core.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'drivers/mfd/mc13xxx-core.c') diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index b0c7cb04af85..06e64b6fcb89 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c @@ -636,42 +636,36 @@ static inline int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx) } #endif -int mc13xxx_common_init(struct mc13xxx *mc13xxx, - struct mc13xxx_platform_data *pdata, int irq) +int mc13xxx_common_init(struct device *dev) { + struct mc13xxx_platform_data *pdata = dev_get_platdata(dev); + struct mc13xxx *mc13xxx = dev_get_drvdata(dev); int ret; u32 revision; - mc13xxx_lock(mc13xxx); + mc13xxx->dev = dev; ret = mc13xxx_reg_read(mc13xxx, MC13XXX_REVISION, &revision); if (ret) - goto err_revision; + return ret; mc13xxx->variant->print_revision(mc13xxx, revision); /* mask all irqs */ ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK0, 0x00ffffff); if (ret) - goto err_mask; + return ret; ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK1, 0x00ffffff); if (ret) - goto err_mask; + return ret; - ret = request_threaded_irq(irq, NULL, mc13xxx_irq_thread, + ret = request_threaded_irq(mc13xxx->irq, NULL, mc13xxx_irq_thread, IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mc13xxx", mc13xxx); - - if (ret) { -err_mask: -err_revision: - mc13xxx_unlock(mc13xxx); + if (ret) return ret; - } - - mc13xxx->irq = irq; - mc13xxx_unlock(mc13xxx); + mutex_init(&mc13xxx->lock); if (mc13xxx_probe_flags_dt(mc13xxx) < 0 && pdata) mc13xxx->flags = pdata->flags; @@ -707,13 +701,17 @@ err_revision: } EXPORT_SYMBOL_GPL(mc13xxx_common_init); -void mc13xxx_common_cleanup(struct mc13xxx *mc13xxx) +int mc13xxx_common_exit(struct device *dev) { + struct mc13xxx *mc13xxx = dev_get_drvdata(dev); + free_irq(mc13xxx->irq, mc13xxx); + mfd_remove_devices(dev); + mutex_destroy(&mc13xxx->lock); - mfd_remove_devices(mc13xxx->dev); + return 0; } -EXPORT_SYMBOL_GPL(mc13xxx_common_cleanup); +EXPORT_SYMBOL_GPL(mc13xxx_common_exit); MODULE_DESCRIPTION("Core driver for Freescale MC13XXX PMIC"); MODULE_AUTHOR("Uwe Kleine-Koenig "); -- cgit v1.2.3