.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) ST-Ericsson SA 2010 |
---|
3 | | - * |
---|
4 | | - * License Terms: GNU General Public License v2 |
---|
5 | 4 | * |
---|
6 | 5 | * Authors: Bengt Jonsson <bengt.g.jonsson@stericsson.com> |
---|
7 | 6 | * |
---|
.. | .. |
---|
479 | 478 | * struct ab8500_ext_regulator_info - ab8500 regulator information |
---|
480 | 479 | * @dev: device pointer |
---|
481 | 480 | * @desc: regulator description |
---|
482 | | - * @rdev: regulator device |
---|
483 | 481 | * @cfg: regulator configuration (extension of regulator FW configuration) |
---|
484 | 482 | * @update_bank: bank to control on/off |
---|
485 | 483 | * @update_reg: register to control on/off |
---|
.. | .. |
---|
495 | 493 | struct ab8500_ext_regulator_info { |
---|
496 | 494 | struct device *dev; |
---|
497 | 495 | struct regulator_desc desc; |
---|
498 | | - struct regulator_dev *rdev; |
---|
499 | 496 | struct ab8500_ext_regulator_cfg *cfg; |
---|
500 | 497 | u8 update_bank; |
---|
501 | 498 | u8 update_reg; |
---|
.. | .. |
---|
530 | 527 | info->update_bank, info->update_reg, |
---|
531 | 528 | info->update_mask, regval); |
---|
532 | 529 | if (ret < 0) { |
---|
533 | | - dev_err(rdev_get_dev(info->rdev), |
---|
| 530 | + dev_err(rdev_get_dev(rdev), |
---|
534 | 531 | "couldn't set enable bits for regulator\n"); |
---|
535 | 532 | return ret; |
---|
536 | 533 | } |
---|
.. | .. |
---|
566 | 563 | info->update_bank, info->update_reg, |
---|
567 | 564 | info->update_mask, regval); |
---|
568 | 565 | if (ret < 0) { |
---|
569 | | - dev_err(rdev_get_dev(info->rdev), |
---|
| 566 | + dev_err(rdev_get_dev(rdev), |
---|
570 | 567 | "couldn't set disable bits for regulator\n"); |
---|
571 | 568 | return ret; |
---|
572 | 569 | } |
---|
.. | .. |
---|
720 | 717 | return -EINVAL; |
---|
721 | 718 | } |
---|
722 | 719 | |
---|
723 | | -static struct regulator_ops ab8500_ext_regulator_ops = { |
---|
| 720 | +static const struct regulator_ops ab8500_ext_regulator_ops = { |
---|
724 | 721 | .enable = ab8500_ext_regulator_enable, |
---|
725 | 722 | .disable = ab8500_ext_regulator_disable, |
---|
726 | 723 | .is_enabled = ab8500_ext_regulator_is_enabled, |
---|
.. | .. |
---|
735 | 732 | [AB8500_EXT_SUPPLY1] = { |
---|
736 | 733 | .desc = { |
---|
737 | 734 | .name = "VEXTSUPPLY1", |
---|
| 735 | + .of_match = of_match_ptr("ab8500_ext1"), |
---|
738 | 736 | .ops = &ab8500_ext_regulator_ops, |
---|
739 | 737 | .type = REGULATOR_VOLTAGE, |
---|
740 | 738 | .id = AB8500_EXT_SUPPLY1, |
---|
.. | .. |
---|
752 | 750 | [AB8500_EXT_SUPPLY2] = { |
---|
753 | 751 | .desc = { |
---|
754 | 752 | .name = "VEXTSUPPLY2", |
---|
| 753 | + .of_match = of_match_ptr("ab8500_ext2"), |
---|
755 | 754 | .ops = &ab8500_ext_regulator_ops, |
---|
756 | 755 | .type = REGULATOR_VOLTAGE, |
---|
757 | 756 | .id = AB8500_EXT_SUPPLY2, |
---|
.. | .. |
---|
769 | 768 | [AB8500_EXT_SUPPLY3] = { |
---|
770 | 769 | .desc = { |
---|
771 | 770 | .name = "VEXTSUPPLY3", |
---|
| 771 | + .of_match = of_match_ptr("ab8500_ext3"), |
---|
772 | 772 | .ops = &ab8500_ext_regulator_ops, |
---|
773 | 773 | .type = REGULATOR_VOLTAGE, |
---|
774 | 774 | .id = AB8500_EXT_SUPPLY3, |
---|
.. | .. |
---|
785 | 785 | }, |
---|
786 | 786 | }; |
---|
787 | 787 | |
---|
788 | | -static struct of_regulator_match ab8500_ext_regulator_match[] = { |
---|
789 | | - { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, }, |
---|
790 | | - { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, }, |
---|
791 | | - { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, }, |
---|
792 | | -}; |
---|
793 | | - |
---|
794 | 788 | static int ab8500_ext_regulator_probe(struct platform_device *pdev) |
---|
795 | 789 | { |
---|
796 | 790 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
---|
797 | 791 | struct ab8500_regulator_platform_data *pdata = &ab8500_regulator_plat_data; |
---|
798 | | - struct device_node *np = pdev->dev.of_node; |
---|
799 | 792 | struct regulator_config config = { }; |
---|
800 | | - int i, err; |
---|
801 | | - |
---|
802 | | - if (np) { |
---|
803 | | - err = of_regulator_match(&pdev->dev, np, |
---|
804 | | - ab8500_ext_regulator_match, |
---|
805 | | - ARRAY_SIZE(ab8500_ext_regulator_match)); |
---|
806 | | - if (err < 0) { |
---|
807 | | - dev_err(&pdev->dev, |
---|
808 | | - "Error parsing regulator init data: %d\n", err); |
---|
809 | | - return err; |
---|
810 | | - } |
---|
811 | | - } |
---|
| 793 | + struct regulator_dev *rdev; |
---|
| 794 | + int i; |
---|
812 | 795 | |
---|
813 | 796 | if (!ab8500) { |
---|
814 | 797 | dev_err(&pdev->dev, "null mfd parent\n"); |
---|
.. | .. |
---|
844 | 827 | |
---|
845 | 828 | config.dev = &pdev->dev; |
---|
846 | 829 | config.driver_data = info; |
---|
847 | | - config.of_node = ab8500_ext_regulator_match[i].of_node; |
---|
848 | | - config.init_data = (np) ? |
---|
849 | | - ab8500_ext_regulator_match[i].init_data : |
---|
850 | | - &pdata->ext_regulator[i]; |
---|
| 830 | + config.init_data = &pdata->ext_regulator[i]; |
---|
851 | 831 | |
---|
852 | 832 | /* register regulator with framework */ |
---|
853 | | - info->rdev = devm_regulator_register(&pdev->dev, &info->desc, |
---|
854 | | - &config); |
---|
855 | | - if (IS_ERR(info->rdev)) { |
---|
856 | | - err = PTR_ERR(info->rdev); |
---|
| 833 | + rdev = devm_regulator_register(&pdev->dev, &info->desc, |
---|
| 834 | + &config); |
---|
| 835 | + if (IS_ERR(rdev)) { |
---|
857 | 836 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
---|
858 | 837 | info->desc.name); |
---|
859 | | - return err; |
---|
| 838 | + return PTR_ERR(rdev); |
---|
860 | 839 | } |
---|
861 | 840 | |
---|
862 | | - dev_dbg(rdev_get_dev(info->rdev), |
---|
863 | | - "%s-probed\n", info->desc.name); |
---|
| 841 | + dev_dbg(&pdev->dev, "%s-probed\n", info->desc.name); |
---|
864 | 842 | } |
---|
865 | 843 | |
---|
866 | 844 | return 0; |
---|