Commit 306df798507d8e009a7d4a5e8ce238a3b107de20

Authored by Yi Zhang
Committed by Samuel Ortiz
1 parent b3aac62bbb

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>

Showing 4 changed files with 10 additions and 28 deletions Side-by-side Diff

drivers/mfd/88pm800.c
... ... @@ -531,7 +531,7 @@
531 531 ret = device_800_init(chip, pdata);
532 532 if (ret) {
533 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 537 ret = pm800_pages_init(chip);
538 538  
... ... @@ -546,10 +546,8 @@
546 546 err_page_init:
547 547 mfd_remove_devices(chip->dev);
548 548 device_irq_exit_800(chip);
549   -err_800_init:
550   - devm_kfree(&client->dev, subchip);
551 549 err_subchip_alloc:
552   - pm80x_deinit(client);
  550 + pm80x_deinit();
553 551 out_init:
554 552 return ret;
555 553 }
... ... @@ -562,9 +560,7 @@
562 560 device_irq_exit_800(chip);
563 561  
564 562 pm800_pages_exit(chip);
565   - devm_kfree(&client->dev, chip->subchip);
566   -
567   - pm80x_deinit(client);
  563 + pm80x_deinit();
568 564  
569 565 return 0;
570 566 }
drivers/mfd/88pm805.c
... ... @@ -257,7 +257,7 @@
257 257 pdata->plat_config(chip, pdata);
258 258  
259 259 err_805_init:
260   - pm80x_deinit(client);
  260 + pm80x_deinit();
261 261 out_init:
262 262 return ret;
263 263 }
... ... @@ -269,7 +269,7 @@
269 269 mfd_remove_devices(chip->dev);
270 270 device_irq_exit_805(chip);
271 271  
272   - pm80x_deinit(client);
  272 + pm80x_deinit();
273 273  
274 274 return 0;
275 275 }
drivers/mfd/88pm80x.c
... ... @@ -48,14 +48,12 @@
48 48 ret = PTR_ERR(map);
49 49 dev_err(&client->dev, "Failed to allocate register map: %d\n",
50 50 ret);
51   - goto err_regmap_init;
  51 + return ret;
52 52 }
53 53  
54 54 chip->id = id->driver_data;
55   - if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) {
56   - ret = -EINVAL;
57   - goto err_chip_id;
58   - }
  55 + if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805)
  56 + return -EINVAL;
59 57  
60 58 chip->client = client;
61 59 chip->regmap = map;
62 60  
63 61  
... ... @@ -82,19 +80,11 @@
82 80 }
83 81  
84 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 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 89 * workaround: clear the dependency between pm800 and pm805.
100 90 * would remove it after HW chip fixes the issue.
... ... @@ -103,10 +93,6 @@
103 93 g_pm80x_chip->companion = NULL;
104 94 else
105 95 g_pm80x_chip = NULL;
106   -
107   - regmap_exit(chip->regmap);
108   - devm_kfree(&client->dev, chip);
109   -
110 96 return 0;
111 97 }
112 98 EXPORT_SYMBOL_GPL(pm80x_deinit);
include/linux/mfd/88pm80x.h
... ... @@ -365,6 +365,6 @@
365 365  
366 366 extern int pm80x_init(struct i2c_client *client,
367 367 const struct i2c_device_id *id);
368   -extern int pm80x_deinit(struct i2c_client *client);
  368 +extern int pm80x_deinit(void);
369 369 #endif /* __LINUX_MFD_88PM80X_H */