Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
0f4cc282 3e80f95b

+17 -46
+17 -46
drivers/regulator/s2mps11.c
··· 342 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 346 regulator_desc_ldo2(1), 347 347 regulator_desc_ldo1(2), 348 348 regulator_desc_ldo1(3), ··· 393 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 396 static int s2mps11_pmic_probe(struct platform_device *pdev) 432 397 { 433 398 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); ··· 402 437 struct regulator_config config = { }; 403 438 struct s2mps11_info *s2mps11; 404 439 int i, ret = 0; 405 - struct regulator_desc *regulators = NULL; 406 - int rdev_num; 440 + const struct regulator_desc *regulators; 441 + enum sec_device_type dev_type; 407 442 408 443 s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info), 409 444 GFP_KERNEL); 410 445 if (!s2mps11) 411 446 return -ENOMEM; 412 447 413 - rdev_num = s2mps11_pmic_init_regulators_desc(pdev, &regulators); 414 - if (rdev_num < 0) 415 - return rdev_num; 448 + dev_type = platform_get_device_id(pdev)->driver_data; 449 + switch (dev_type) { 450 + case S2MPS11X: 451 + s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); 452 + regulators = s2mps11_regulators; 453 + break; 454 + default: 455 + dev_err(&pdev->dev, "Invalid device type: %u\n", dev_type); 456 + return -EINVAL; 457 + }; 416 458 417 459 if (!iodev->dev->of_node) { 418 460 if (pdata) { ··· 431 459 } 432 460 } 433 461 434 - rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL); 462 + rdata = kzalloc(sizeof(*rdata) * s2mps11->rdev_num, GFP_KERNEL); 435 463 if (!rdata) 436 464 return -ENOMEM; 437 465 438 - for (i = 0; i < rdev_num; i++) 466 + for (i = 0; i < s2mps11->rdev_num; i++) 439 467 rdata[i].name = regulators[i].name; 440 468 441 469 reg_np = of_find_node_by_name(iodev->dev->of_node, "regulators"); ··· 445 473 goto out; 446 474 } 447 475 448 - of_regulator_match(&pdev->dev, reg_np, rdata, rdev_num); 476 + of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); 449 477 450 478 common_reg: 451 479 platform_set_drvdata(pdev, s2mps11); 452 - s2mps11->rdev_num = rdev_num; 453 480 454 481 config.dev = &pdev->dev; 455 482 config.regmap = iodev->regmap_pmic; 456 483 config.driver_data = s2mps11; 457 - for (i = 0; i < rdev_num; i++) { 484 + for (i = 0; i < s2mps11->rdev_num; i++) { 458 485 struct regulator_dev *regulator; 459 486 460 487 if (!reg_np) {