aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/da9052-spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/da9052-spi.c')
-rw-r--r--drivers/mfd/da9052-spi.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/mfd/da9052-spi.c b/drivers/mfd/da9052-spi.c
index 6faf149e8d94..dbeadc5a6436 100644
--- a/drivers/mfd/da9052-spi.c
+++ b/drivers/mfd/da9052-spi.c
@@ -25,8 +25,9 @@ static int __devinit da9052_spi_probe(struct spi_device *spi)
25{ 25{
26 int ret; 26 int ret;
27 const struct spi_device_id *id = spi_get_device_id(spi); 27 const struct spi_device_id *id = spi_get_device_id(spi);
28 struct da9052 *da9052 = kzalloc(sizeof(struct da9052), GFP_KERNEL); 28 struct da9052 *da9052;
29 29
30 da9052 = devm_kzalloc(&spi->dev, sizeof(struct da9052), GFP_KERNEL);
30 if (!da9052) 31 if (!da9052)
31 return -ENOMEM; 32 return -ENOMEM;
32 33
@@ -42,25 +43,19 @@ static int __devinit da9052_spi_probe(struct spi_device *spi)
42 da9052_regmap_config.read_flag_mask = 1; 43 da9052_regmap_config.read_flag_mask = 1;
43 da9052_regmap_config.write_flag_mask = 0; 44 da9052_regmap_config.write_flag_mask = 0;
44 45
45 da9052->regmap = regmap_init_spi(spi, &da9052_regmap_config); 46 da9052->regmap = devm_regmap_init_spi(spi, &da9052_regmap_config);
46 if (IS_ERR(da9052->regmap)) { 47 if (IS_ERR(da9052->regmap)) {
47 ret = PTR_ERR(da9052->regmap); 48 ret = PTR_ERR(da9052->regmap);
48 dev_err(&spi->dev, "Failed to allocate register map: %d\n", 49 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
49 ret); 50 ret);
50 goto err; 51 return ret;
51 } 52 }
52 53
53 ret = da9052_device_init(da9052, id->driver_data); 54 ret = da9052_device_init(da9052, id->driver_data);
54 if (ret != 0) 55 if (ret != 0)
55 goto err_regmap; 56 return ret;
56 57
57 return 0; 58 return 0;
58
59err_regmap:
60 regmap_exit(da9052->regmap);
61err:
62 kfree(da9052);
63 return ret;
64} 59}
65 60
66static int __devexit da9052_spi_remove(struct spi_device *spi) 61static int __devexit da9052_spi_remove(struct spi_device *spi)
@@ -68,9 +63,6 @@ static int __devexit da9052_spi_remove(struct spi_device *spi)
68 struct da9052 *da9052 = dev_get_drvdata(&spi->dev); 63 struct da9052 *da9052 = dev_get_drvdata(&spi->dev);
69 64
70 da9052_device_exit(da9052); 65 da9052_device_exit(da9052);
71 regmap_exit(da9052->regmap);
72 kfree(da9052);
73
74 return 0; 66 return 0;
75} 67}
76 68
@@ -88,7 +80,6 @@ static struct spi_driver da9052_spi_driver = {
88 .id_table = da9052_spi_id, 80 .id_table = da9052_spi_id,
89 .driver = { 81 .driver = {
90 .name = "da9052", 82 .name = "da9052",
91 .bus = &spi_bus_type,
92 .owner = THIS_MODULE, 83 .owner = THIS_MODULE,
93 }, 84 },
94}; 85};