diff options
author | Chao Xie <chao.xie@marvell.com> | 2013-06-14 01:21:52 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-06-18 03:41:11 -0400 |
commit | 3a3ece5415bd7a4bc7923906369525943332fc1a (patch) | |
tree | a79c3de2872d1ce348dae1be5f859a1f66b0d0a8 /drivers/mfd | |
parent | 03dcc544bff9ff36b9ac5e2b992a7a4890e6edc4 (diff) |
mfd: 88pm800: Enhance sub devices initialization
Separate the devices initialization into different functions.
It makes the probe function clearer.
Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/88pm800.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index 2c0b4155181f..a475fb3c2d0c 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c | |||
@@ -305,6 +305,40 @@ out: | |||
305 | return ret; | 305 | return ret; |
306 | } | 306 | } |
307 | 307 | ||
308 | static int device_onkey_init(struct pm80x_chip *chip, | ||
309 | struct pm80x_platform_data *pdata) | ||
310 | { | ||
311 | int ret; | ||
312 | |||
313 | ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], | ||
314 | ARRAY_SIZE(onkey_devs), &onkey_resources[0], 0, | ||
315 | NULL); | ||
316 | if (ret) { | ||
317 | dev_err(chip->dev, "Failed to add onkey subdev\n"); | ||
318 | return ret; | ||
319 | } | ||
320 | |||
321 | return 0; | ||
322 | } | ||
323 | |||
324 | static int device_rtc_init(struct pm80x_chip *chip, | ||
325 | struct pm80x_platform_data *pdata) | ||
326 | { | ||
327 | int ret; | ||
328 | |||
329 | rtc_devs[0].platform_data = pdata->rtc; | ||
330 | rtc_devs[0].pdata_size = | ||
331 | pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0; | ||
332 | ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], | ||
333 | ARRAY_SIZE(rtc_devs), NULL, 0, NULL); | ||
334 | if (ret) { | ||
335 | dev_err(chip->dev, "Failed to add rtc subdev\n"); | ||
336 | return ret; | ||
337 | } | ||
338 | |||
339 | return 0; | ||
340 | } | ||
341 | |||
308 | static int device_irq_init_800(struct pm80x_chip *chip) | 342 | static int device_irq_init_800(struct pm80x_chip *chip) |
309 | { | 343 | { |
310 | struct regmap *map = chip->regmap; | 344 | struct regmap *map = chip->regmap; |
@@ -454,27 +488,16 @@ static int device_800_init(struct pm80x_chip *chip, | |||
454 | goto out; | 488 | goto out; |
455 | } | 489 | } |
456 | 490 | ||
457 | ret = | 491 | ret = device_onkey_init(chip, pdata); |
458 | mfd_add_devices(chip->dev, 0, &onkey_devs[0], | 492 | if (ret) { |
459 | ARRAY_SIZE(onkey_devs), &onkey_resources[0], 0, | ||
460 | NULL); | ||
461 | if (ret < 0) { | ||
462 | dev_err(chip->dev, "Failed to add onkey subdev\n"); | 493 | dev_err(chip->dev, "Failed to add onkey subdev\n"); |
463 | goto out_dev; | 494 | goto out_dev; |
464 | } else | 495 | } |
465 | dev_info(chip->dev, "[%s]:Added mfd onkey_devs\n", __func__); | 496 | |
466 | 497 | ret = device_rtc_init(chip, pdata); | |
467 | if (pdata && pdata->rtc) { | 498 | if (ret) { |
468 | rtc_devs[0].platform_data = pdata->rtc; | 499 | dev_err(chip->dev, "Failed to add rtc subdev\n"); |
469 | rtc_devs[0].pdata_size = sizeof(struct pm80x_rtc_pdata); | 500 | goto out; |
470 | ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], | ||
471 | ARRAY_SIZE(rtc_devs), NULL, 0, NULL); | ||
472 | if (ret < 0) { | ||
473 | dev_err(chip->dev, "Failed to add rtc subdev\n"); | ||
474 | goto out_dev; | ||
475 | } else | ||
476 | dev_info(chip->dev, | ||
477 | "[%s]:Added mfd rtc_devs\n", __func__); | ||
478 | } | 501 | } |
479 | 502 | ||
480 | return 0; | 503 | return 0; |