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

lis3lv02d: make regulator API usage unconditional

The regulator API contains a range of features for stubbing itself out
when not in use and for transparently restricting the actual effect of
regulator API calls where they can't be supported on a particular system
so that drivers don't need to individually implement this. Simplify the
driver slightly by making use of this idiom.

The only in tree user is ecovec24 which does not use the regulator API.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Éric Piel <eric.piel@tremplin-utc.net>
Cc: Ilkka Koskinen <ilkka.koskinen@nokia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mark Brown and committed by
Linus Torvalds
ec400c9f 895c156c

+12 -23
+12 -22
drivers/misc/lis3lv02d/lis3lv02d_i2c.c
··· 79 79 u8 reg; 80 80 int ret; 81 81 82 - if (lis3->reg_ctrl) 83 - lis3_reg_ctrl(lis3, LIS3_REG_ON); 82 + lis3_reg_ctrl(lis3, LIS3_REG_ON); 84 83 85 84 lis3->read(lis3, WHO_AM_I, &reg); 86 85 if (reg != lis3->whoami) ··· 105 106 struct lis3lv02d_platform_data *pdata = client->dev.platform_data; 106 107 107 108 if (pdata) { 108 - /* Regulator control is optional */ 109 - if (pdata->driver_features & LIS3_USE_REGULATOR_CTRL) 110 - lis3_dev.reg_ctrl = lis3_reg_ctrl; 111 - 112 109 if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && 113 110 (i2c_check_functionality(client->adapter, 114 111 I2C_FUNC_SMBUS_I2C_BLOCK))) ··· 126 131 goto fail; 127 132 } 128 133 129 - if (lis3_dev.reg_ctrl) { 130 - lis3_dev.regulators[0].supply = reg_vdd; 131 - lis3_dev.regulators[1].supply = reg_vdd_io; 132 - ret = regulator_bulk_get(&client->dev, 133 - ARRAY_SIZE(lis3_dev.regulators), 134 - lis3_dev.regulators); 135 - if (ret < 0) 136 - goto fail; 137 - } 134 + lis3_dev.regulators[0].supply = reg_vdd; 135 + lis3_dev.regulators[1].supply = reg_vdd_io; 136 + ret = regulator_bulk_get(&client->dev, 137 + ARRAY_SIZE(lis3_dev.regulators), 138 + lis3_dev.regulators); 139 + if (ret < 0) 140 + goto fail; 138 141 139 142 lis3_dev.pdata = pdata; 140 143 lis3_dev.bus_priv = client; ··· 146 153 i2c_set_clientdata(client, &lis3_dev); 147 154 148 155 /* Provide power over the init call */ 149 - if (lis3_dev.reg_ctrl) 150 - lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON); 156 + lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON); 151 157 152 158 ret = lis3lv02d_init_device(&lis3_dev); 153 159 154 - if (lis3_dev.reg_ctrl) 155 - lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF); 160 + lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF); 156 161 157 162 if (ret) 158 163 goto fail2; ··· 176 185 lis3lv02d_joystick_disable(lis3); 177 186 lis3lv02d_remove_fs(&lis3_dev); 178 187 179 - if (lis3_dev.reg_ctrl) 180 - regulator_bulk_free(ARRAY_SIZE(lis3->regulators), 181 - lis3_dev.regulators); 188 + regulator_bulk_free(ARRAY_SIZE(lis3->regulators), 189 + lis3_dev.regulators); 182 190 return 0; 183 191 } 184 192
-1
include/linux/lis3lv02d.h
··· 113 113 s8 axis_x; 114 114 s8 axis_y; 115 115 s8 axis_z; 116 - #define LIS3_USE_REGULATOR_CTRL 0x01 117 116 #define LIS3_USE_BLOCK_READ 0x02 118 117 u16 driver_features; 119 118 int default_rate;