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

regulator: fixed: Don't supply voltage change ops when no GPIO is given

Rather than replicating the core support for always on regulators use
a different set of ops with none of the enable related operations provided
when we don't have any ops. This ensures that we automatically pick up
any enhanced support for such regulators that the core has such as the
warnings about regulation constraints that can't be used.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

+13 -14
+13 -14
drivers/regulator/fixed.c
··· 105 105 { 106 106 struct fixed_voltage_data *data = rdev_get_drvdata(dev); 107 107 108 - if (gpio_is_valid(data->gpio)) { 109 - gpio_set_value_cansleep(data->gpio, data->enable_high); 110 - data->is_enabled = true; 111 - } 108 + gpio_set_value_cansleep(data->gpio, data->enable_high); 109 + data->is_enabled = true; 112 110 113 111 return 0; 114 112 } ··· 115 117 { 116 118 struct fixed_voltage_data *data = rdev_get_drvdata(dev); 117 119 118 - if (gpio_is_valid(data->gpio)) { 119 - gpio_set_value_cansleep(data->gpio, !data->enable_high); 120 - data->is_enabled = false; 121 - } 120 + gpio_set_value_cansleep(data->gpio, !data->enable_high); 121 + data->is_enabled = false; 122 122 123 123 return 0; 124 124 } ··· 149 153 return data->microvolts; 150 154 } 151 155 152 - static struct regulator_ops fixed_voltage_ops = { 156 + static struct regulator_ops fixed_voltage_gpio_ops = { 153 157 .is_enabled = fixed_voltage_is_enabled, 154 158 .enable = fixed_voltage_enable, 155 159 .disable = fixed_voltage_disable, 156 160 .enable_time = fixed_voltage_enable_time, 161 + .get_voltage = fixed_voltage_get_voltage, 162 + .list_voltage = fixed_voltage_list_voltage, 163 + }; 164 + 165 + static struct regulator_ops fixed_voltage_ops = { 157 166 .get_voltage = fixed_voltage_get_voltage, 158 167 .list_voltage = fixed_voltage_list_voltage, 159 168 }; ··· 193 192 } 194 193 drvdata->desc.type = REGULATOR_VOLTAGE; 195 194 drvdata->desc.owner = THIS_MODULE; 196 - drvdata->desc.ops = &fixed_voltage_ops; 197 195 198 196 if (config->microvolts) 199 197 drvdata->desc.n_voltages = 1; ··· 242 242 goto err_gpio; 243 243 } 244 244 245 + drvdata->desc.ops = &fixed_voltage_gpio_ops; 246 + 245 247 } else { 246 - /* Regulator without GPIO control is considered 247 - * always enabled 248 - */ 249 - drvdata->is_enabled = true; 248 + drvdata->desc.ops = &fixed_voltage_ops; 250 249 } 251 250 252 251 drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev,