diff options
author | Yi Zhang <yizhang@marvell.com> | 2013-01-21 21:43:45 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-02-13 18:22:54 -0500 |
commit | 306df798507d8e009a7d4a5e8ce238a3b107de20 (patch) | |
tree | 763002544391b3f0369dfb46dc4e4993a467e7c6 | |
parent | b3aac62bbb1c3f8e71c88e6e477836def3058fe8 (diff) |
mfd: 88pm80x: Remove redundant devm_* calls
devm_* functions are device managed and make error handling
and code simpler; it also fix error exit paths
Signed-off-by: Yi Zhang <yizhang@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/88pm800.c | 10 | ||||
-rw-r--r-- | drivers/mfd/88pm805.c | 4 | ||||
-rw-r--r-- | drivers/mfd/88pm80x.c | 22 | ||||
-rw-r--r-- | include/linux/mfd/88pm80x.h | 2 |
4 files changed, 10 insertions, 28 deletions
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index 391e23e6a647..582bda543520 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c | |||
@@ -531,7 +531,7 @@ static int pm800_probe(struct i2c_client *client, | |||
531 | ret = device_800_init(chip, pdata); | 531 | ret = device_800_init(chip, pdata); |
532 | if (ret) { | 532 | if (ret) { |
533 | dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id); | 533 | dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id); |
534 | goto err_800_init; | 534 | goto err_subchip_alloc; |
535 | } | 535 | } |
536 | 536 | ||
537 | ret = pm800_pages_init(chip); | 537 | ret = pm800_pages_init(chip); |
@@ -546,10 +546,8 @@ static int pm800_probe(struct i2c_client *client, | |||
546 | err_page_init: | 546 | err_page_init: |
547 | mfd_remove_devices(chip->dev); | 547 | mfd_remove_devices(chip->dev); |
548 | device_irq_exit_800(chip); | 548 | device_irq_exit_800(chip); |
549 | err_800_init: | ||
550 | devm_kfree(&client->dev, subchip); | ||
551 | err_subchip_alloc: | 549 | err_subchip_alloc: |
552 | pm80x_deinit(client); | 550 | pm80x_deinit(); |
553 | out_init: | 551 | out_init: |
554 | return ret; | 552 | return ret; |
555 | } | 553 | } |
@@ -562,9 +560,7 @@ static int pm800_remove(struct i2c_client *client) | |||
562 | device_irq_exit_800(chip); | 560 | device_irq_exit_800(chip); |
563 | 561 | ||
564 | pm800_pages_exit(chip); | 562 | pm800_pages_exit(chip); |
565 | devm_kfree(&client->dev, chip->subchip); | 563 | pm80x_deinit(); |
566 | |||
567 | pm80x_deinit(client); | ||
568 | 564 | ||
569 | return 0; | 565 | return 0; |
570 | } | 566 | } |
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c index e671230be2b1..65d7ac099b20 100644 --- a/drivers/mfd/88pm805.c +++ b/drivers/mfd/88pm805.c | |||
@@ -257,7 +257,7 @@ static int pm805_probe(struct i2c_client *client, | |||
257 | pdata->plat_config(chip, pdata); | 257 | pdata->plat_config(chip, pdata); |
258 | 258 | ||
259 | err_805_init: | 259 | err_805_init: |
260 | pm80x_deinit(client); | 260 | pm80x_deinit(); |
261 | out_init: | 261 | out_init: |
262 | return ret; | 262 | return ret; |
263 | } | 263 | } |
@@ -269,7 +269,7 @@ static int pm805_remove(struct i2c_client *client) | |||
269 | mfd_remove_devices(chip->dev); | 269 | mfd_remove_devices(chip->dev); |
270 | device_irq_exit_805(chip); | 270 | device_irq_exit_805(chip); |
271 | 271 | ||
272 | pm80x_deinit(client); | 272 | pm80x_deinit(); |
273 | 273 | ||
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
diff --git a/drivers/mfd/88pm80x.c b/drivers/mfd/88pm80x.c index 1adb355d86d1..f736a46eb8c0 100644 --- a/drivers/mfd/88pm80x.c +++ b/drivers/mfd/88pm80x.c | |||
@@ -48,14 +48,12 @@ int pm80x_init(struct i2c_client *client, | |||
48 | ret = PTR_ERR(map); | 48 | ret = PTR_ERR(map); |
49 | dev_err(&client->dev, "Failed to allocate register map: %d\n", | 49 | dev_err(&client->dev, "Failed to allocate register map: %d\n", |
50 | ret); | 50 | ret); |
51 | goto err_regmap_init; | 51 | return ret; |
52 | } | 52 | } |
53 | 53 | ||
54 | chip->id = id->driver_data; | 54 | chip->id = id->driver_data; |
55 | if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) { | 55 | if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) |
56 | ret = -EINVAL; | 56 | return -EINVAL; |
57 | goto err_chip_id; | ||
58 | } | ||
59 | 57 | ||
60 | chip->client = client; | 58 | chip->client = client; |
61 | chip->regmap = map; | 59 | chip->regmap = map; |
@@ -82,19 +80,11 @@ int pm80x_init(struct i2c_client *client, | |||
82 | } | 80 | } |
83 | 81 | ||
84 | return 0; | 82 | return 0; |
85 | |||
86 | err_chip_id: | ||
87 | regmap_exit(map); | ||
88 | err_regmap_init: | ||
89 | devm_kfree(&client->dev, chip); | ||
90 | return ret; | ||
91 | } | 83 | } |
92 | EXPORT_SYMBOL_GPL(pm80x_init); | 84 | EXPORT_SYMBOL_GPL(pm80x_init); |
93 | 85 | ||
94 | int pm80x_deinit(struct i2c_client *client) | 86 | int pm80x_deinit(void) |
95 | { | 87 | { |
96 | struct pm80x_chip *chip = i2c_get_clientdata(client); | ||
97 | |||
98 | /* | 88 | /* |
99 | * workaround: clear the dependency between pm800 and pm805. | 89 | * workaround: clear the dependency between pm800 and pm805. |
100 | * would remove it after HW chip fixes the issue. | 90 | * would remove it after HW chip fixes the issue. |
@@ -103,10 +93,6 @@ int pm80x_deinit(struct i2c_client *client) | |||
103 | g_pm80x_chip->companion = NULL; | 93 | g_pm80x_chip->companion = NULL; |
104 | else | 94 | else |
105 | g_pm80x_chip = NULL; | 95 | g_pm80x_chip = NULL; |
106 | |||
107 | regmap_exit(chip->regmap); | ||
108 | devm_kfree(&client->dev, chip); | ||
109 | |||
110 | return 0; | 96 | return 0; |
111 | } | 97 | } |
112 | EXPORT_SYMBOL_GPL(pm80x_deinit); | 98 | EXPORT_SYMBOL_GPL(pm80x_deinit); |
diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h index 478672ed0c3d..e94537befabd 100644 --- a/include/linux/mfd/88pm80x.h +++ b/include/linux/mfd/88pm80x.h | |||
@@ -365,5 +365,5 @@ static inline int pm80x_dev_resume(struct device *dev) | |||
365 | 365 | ||
366 | extern int pm80x_init(struct i2c_client *client, | 366 | extern int pm80x_init(struct i2c_client *client, |
367 | const struct i2c_device_id *id); | 367 | const struct i2c_device_id *id); |
368 | extern int pm80x_deinit(struct i2c_client *client); | 368 | extern int pm80x_deinit(void); |
369 | #endif /* __LINUX_MFD_88PM80X_H */ | 369 | #endif /* __LINUX_MFD_88PM80X_H */ |