diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2014-03-03 10:53:51 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-03 22:01:57 -0500 |
commit | 0f4cc282951a76011db1da6787b3d2acc63238ca (patch) | |
tree | 0ddb76ef04b2d6eb0337fc0f492569cda78b73f2 /drivers/regulator/s2mps11.c | |
parent | 3e80f95bfc5f490bda4785cb672490f7012a40d0 (diff) |
regulator: s2mps11: Fix section mismatch
Remove __initconst from regulator_desc array because this array is used
during probe and s2mps11_pmic_probe() is not in __init section. However
still select the number of supported regulators according to device ID
so the driver will be ready for adding support for S2MPS14 device.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/s2mps11.c')
-rw-r--r-- | drivers/regulator/s2mps11.c | 63 |
1 files changed, 17 insertions, 46 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index ca66fc56fa58..ca876de72eae 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -342,7 +342,7 @@ static struct regulator_ops s2mps11_buck_ops = { | |||
342 | .enable_mask = S2MPS11_ENABLE_MASK \ | 342 | .enable_mask = S2MPS11_ENABLE_MASK \ |
343 | } | 343 | } |
344 | 344 | ||
345 | static const struct regulator_desc s2mps11_regulators[] __initconst = { | 345 | static const struct regulator_desc s2mps11_regulators[] = { |
346 | regulator_desc_ldo2(1), | 346 | regulator_desc_ldo2(1), |
347 | regulator_desc_ldo1(2), | 347 | regulator_desc_ldo1(2), |
348 | regulator_desc_ldo1(3), | 348 | regulator_desc_ldo1(3), |
@@ -393,41 +393,6 @@ static const struct regulator_desc s2mps11_regulators[] __initconst = { | |||
393 | regulator_desc_buck10, | 393 | regulator_desc_buck10, |
394 | }; | 394 | }; |
395 | 395 | ||
396 | /* | ||
397 | * Allocates memory under 'regulators' pointer and copies there array | ||
398 | * of regulator_desc for given device. | ||
399 | * | ||
400 | * Returns number of regulators or negative ERRNO on error. | ||
401 | */ | ||
402 | static int __init | ||
403 | s2mps11_pmic_init_regulators_desc(struct platform_device *pdev, | ||
404 | struct regulator_desc **regulators) | ||
405 | { | ||
406 | const struct regulator_desc *regulators_init; | ||
407 | enum sec_device_type dev_type; | ||
408 | int rdev_num; | ||
409 | |||
410 | dev_type = platform_get_device_id(pdev)->driver_data; | ||
411 | switch (dev_type) { | ||
412 | case S2MPS11X: | ||
413 | rdev_num = ARRAY_SIZE(s2mps11_regulators); | ||
414 | regulators_init = s2mps11_regulators; | ||
415 | break; | ||
416 | default: | ||
417 | dev_err(&pdev->dev, "Invalid device type: %u\n", dev_type); | ||
418 | return -EINVAL; | ||
419 | }; | ||
420 | |||
421 | *regulators = devm_kzalloc(&pdev->dev, | ||
422 | sizeof(**regulators) * rdev_num, GFP_KERNEL); | ||
423 | if (!*regulators) | ||
424 | return -ENOMEM; | ||
425 | |||
426 | memcpy(*regulators, regulators_init, sizeof(**regulators) * rdev_num); | ||
427 | |||
428 | return rdev_num; | ||
429 | } | ||
430 | |||
431 | static int s2mps11_pmic_probe(struct platform_device *pdev) | 396 | static int s2mps11_pmic_probe(struct platform_device *pdev) |
432 | { | 397 | { |
433 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 398 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
@@ -437,17 +402,24 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
437 | struct regulator_config config = { }; | 402 | struct regulator_config config = { }; |
438 | struct s2mps11_info *s2mps11; | 403 | struct s2mps11_info *s2mps11; |
439 | int i, ret = 0; | 404 | int i, ret = 0; |
440 | struct regulator_desc *regulators = NULL; | 405 | const struct regulator_desc *regulators; |
441 | int rdev_num; | 406 | enum sec_device_type dev_type; |
442 | 407 | ||
443 | s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info), | 408 | s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info), |
444 | GFP_KERNEL); | 409 | GFP_KERNEL); |
445 | if (!s2mps11) | 410 | if (!s2mps11) |
446 | return -ENOMEM; | 411 | return -ENOMEM; |
447 | 412 | ||
448 | rdev_num = s2mps11_pmic_init_regulators_desc(pdev, ®ulators); | 413 | dev_type = platform_get_device_id(pdev)->driver_data; |
449 | if (rdev_num < 0) | 414 | switch (dev_type) { |
450 | return rdev_num; | 415 | case S2MPS11X: |
416 | s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); | ||
417 | regulators = s2mps11_regulators; | ||
418 | break; | ||
419 | default: | ||
420 | dev_err(&pdev->dev, "Invalid device type: %u\n", dev_type); | ||
421 | return -EINVAL; | ||
422 | }; | ||
451 | 423 | ||
452 | if (!iodev->dev->of_node) { | 424 | if (!iodev->dev->of_node) { |
453 | if (pdata) { | 425 | if (pdata) { |
@@ -459,11 +431,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
459 | } | 431 | } |
460 | } | 432 | } |
461 | 433 | ||
462 | rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL); | 434 | rdata = kzalloc(sizeof(*rdata) * s2mps11->rdev_num, GFP_KERNEL); |
463 | if (!rdata) | 435 | if (!rdata) |
464 | return -ENOMEM; | 436 | return -ENOMEM; |
465 | 437 | ||
466 | for (i = 0; i < rdev_num; i++) | 438 | for (i = 0; i < s2mps11->rdev_num; i++) |
467 | rdata[i].name = regulators[i].name; | 439 | rdata[i].name = regulators[i].name; |
468 | 440 | ||
469 | reg_np = of_find_node_by_name(iodev->dev->of_node, "regulators"); | 441 | reg_np = of_find_node_by_name(iodev->dev->of_node, "regulators"); |
@@ -473,16 +445,15 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
473 | goto out; | 445 | goto out; |
474 | } | 446 | } |
475 | 447 | ||
476 | of_regulator_match(&pdev->dev, reg_np, rdata, rdev_num); | 448 | of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); |
477 | 449 | ||
478 | common_reg: | 450 | common_reg: |
479 | platform_set_drvdata(pdev, s2mps11); | 451 | platform_set_drvdata(pdev, s2mps11); |
480 | s2mps11->rdev_num = rdev_num; | ||
481 | 452 | ||
482 | config.dev = &pdev->dev; | 453 | config.dev = &pdev->dev; |
483 | config.regmap = iodev->regmap_pmic; | 454 | config.regmap = iodev->regmap_pmic; |
484 | config.driver_data = s2mps11; | 455 | config.driver_data = s2mps11; |
485 | for (i = 0; i < rdev_num; i++) { | 456 | for (i = 0; i < s2mps11->rdev_num; i++) { |
486 | struct regulator_dev *regulator; | 457 | struct regulator_dev *regulator; |
487 | 458 | ||
488 | if (!reg_np) { | 459 | if (!reg_np) { |