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 <shc_work@mail.ru> Signed-off-by: Lee Jones <lee.jones@linaro.org>
此提交包含在:
@@ -13,7 +13,6 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/mfd/mc13xxx.h>
|
||||
@@ -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 = {
|
||||
|
新增問題並參考
封鎖使用者