]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
regulator: mt6359: const-ify regulator descriptions
authorChen-Yu Tsai <wenst@chromium.org>
Thu, 14 May 2026 09:15:17 +0000 (17:15 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 20 May 2026 16:17:02 +0000 (17:17 +0100)
The regulator descriptions and extended descriptions don't change at
runtime. The only reason they are not const is that the regulator
driver data is non-const.

Const-ify the descriptions and all references to them. For the driver
data, explicitly cast it to non-const void *.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20260514091520.2718987-5-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/mt6359-regulator.c

index c8a788858824909cf5de4e5fb75b80e151d1e9d2..bcf9a476a34e12075ea823621a05f8950ff85c75 100644 (file)
@@ -251,7 +251,7 @@ static int mt6359_get_status(struct regulator_dev *rdev)
 {
        int ret;
        u32 regval;
-       struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
+       const struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
 
        ret = regmap_read(rdev->regmap, info->status_reg, &regval);
        if (ret != 0) {
@@ -267,7 +267,7 @@ static int mt6359_get_status(struct regulator_dev *rdev)
 
 static unsigned int mt6359_regulator_get_mode(struct regulator_dev *rdev)
 {
-       struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
+       const struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
        int ret, regval;
 
        ret = regmap_read(rdev->regmap, info->modeset_reg, &regval);
@@ -299,7 +299,7 @@ static unsigned int mt6359_regulator_get_mode(struct regulator_dev *rdev)
 static int mt6359_regulator_set_mode(struct regulator_dev *rdev,
                                     unsigned int mode)
 {
-       struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
+       const struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
        int ret = 0, val;
        int curr_mode;
 
@@ -354,7 +354,7 @@ static int mt6359_regulator_set_mode(struct regulator_dev *rdev,
 static int mt6359p_vemc_set_voltage_sel(struct regulator_dev *rdev,
                                        u32 sel)
 {
-       struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
+       const struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
        int ret;
        u32 val = 0;
 
@@ -393,7 +393,7 @@ static int mt6359p_vemc_set_voltage_sel(struct regulator_dev *rdev,
 
 static int mt6359p_vemc_get_voltage_sel(struct regulator_dev *rdev)
 {
-       struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
+       const struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
        int ret;
        u32 val = 0;
 
@@ -469,7 +469,7 @@ static const struct regulator_ops mt6359p_vemc_ops = {
 };
 
 /* The array is indexed by id(MT6359_ID_XXX) */
-static struct mt6359_regulator_info mt6359_regulators[] = {
+static const struct mt6359_regulator_info mt6359_regulators[] = {
        MT6359_BUCK("buck_vs1", VS1, 800000, 2200000, 12500,
                    MT6359_RG_BUCK_VS1_EN_ADDR,
                    MT6359_DA_VS1_EN_ADDR, MT6359_RG_BUCK_VS1_VOSEL_ADDR,
@@ -705,7 +705,7 @@ static struct mt6359_regulator_info mt6359_regulators[] = {
                          MT6359_RG_LDO_VSRAM_OTHERS_SSHUB_VOSEL_SHIFT),
 };
 
-static struct mt6359_regulator_info mt6359p_regulators[] = {
+static const struct mt6359_regulator_info mt6359p_regulators[] = {
        MT6359_BUCK("buck_vs1", VS1, 800000, 2200000, 12500,
                    MT6359_RG_BUCK_VS1_EN_ADDR,
                    MT6359_DA_VS1_EN_ADDR, MT6359_RG_BUCK_VS1_VOSEL_ADDR,
@@ -950,7 +950,7 @@ static int mt6359_regulator_probe(struct platform_device *pdev)
        struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent);
        struct regulator_config config = {};
        struct regulator_dev *rdev;
-       struct mt6359_regulator_info *mt6359_info;
+       const struct mt6359_regulator_info *mt6359_info;
        int i, hw_ver, ret;
 
        ret = regmap_read(mt6397->regmap, MT6359P_HWCID, &hw_ver);
@@ -965,7 +965,8 @@ static int mt6359_regulator_probe(struct platform_device *pdev)
        config.dev = mt6397->dev;
        config.regmap = mt6397->regmap;
        for (i = 0; i < MT6359_MAX_REGULATOR; i++, mt6359_info++) {
-               config.driver_data = mt6359_info;
+               /* drop const here, but all uses in the driver are const */
+               config.driver_data = (void *)mt6359_info;
                rdev = devm_regulator_register(&pdev->dev, &mt6359_info->desc, &config);
                if (IS_ERR(rdev)) {
                        dev_err(&pdev->dev, "failed to register %s\n", mt6359_info->desc.name);