aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-31 20:11:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-31 20:30:52 -0400
commitec400c9fab99d16a491cea17d27d0c6a5780b97c (patch)
tree38516e6244d3ec0b68e52a5679f0b4b9517d71db
parent895c156c044a736d8dc2239020f4530bb6245675 (diff)
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>
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d_i2c.c34
-rw-r--r--include/linux/lis3lv02d.h1
2 files changed, 12 insertions, 23 deletions
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
index 6cdc38f6a9a8..c02fea029dcf 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
@@ -79,8 +79,7 @@ static int lis3_i2c_init(struct lis3lv02d *lis3)
79 u8 reg; 79 u8 reg;
80 int ret; 80 int ret;
81 81
82 if (lis3->reg_ctrl) 82 lis3_reg_ctrl(lis3, LIS3_REG_ON);
83 lis3_reg_ctrl(lis3, LIS3_REG_ON);
84 83
85 lis3->read(lis3, WHO_AM_I, &reg); 84 lis3->read(lis3, WHO_AM_I, &reg);
86 if (reg != lis3->whoami) 85 if (reg != lis3->whoami)
@@ -106,10 +105,6 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
106 struct lis3lv02d_platform_data *pdata = client->dev.platform_data; 105 struct lis3lv02d_platform_data *pdata = client->dev.platform_data;
107 106
108 if (pdata) { 107 if (pdata) {
109 /* Regulator control is optional */
110 if (pdata->driver_features & LIS3_USE_REGULATOR_CTRL)
111 lis3_dev.reg_ctrl = lis3_reg_ctrl;
112
113 if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && 108 if ((pdata->driver_features & LIS3_USE_BLOCK_READ) &&
114 (i2c_check_functionality(client->adapter, 109 (i2c_check_functionality(client->adapter,
115 I2C_FUNC_SMBUS_I2C_BLOCK))) 110 I2C_FUNC_SMBUS_I2C_BLOCK)))
@@ -131,15 +126,13 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
131 goto fail; 126 goto fail;
132 } 127 }
133 128
134 if (lis3_dev.reg_ctrl) { 129 lis3_dev.regulators[0].supply = reg_vdd;
135 lis3_dev.regulators[0].supply = reg_vdd; 130 lis3_dev.regulators[1].supply = reg_vdd_io;
136 lis3_dev.regulators[1].supply = reg_vdd_io; 131 ret = regulator_bulk_get(&client->dev,
137 ret = regulator_bulk_get(&client->dev, 132 ARRAY_SIZE(lis3_dev.regulators),
138 ARRAY_SIZE(lis3_dev.regulators), 133 lis3_dev.regulators);
139 lis3_dev.regulators); 134 if (ret < 0)
140 if (ret < 0) 135 goto fail;
141 goto fail;
142 }
143 136
144 lis3_dev.pdata = pdata; 137 lis3_dev.pdata = pdata;
145 lis3_dev.bus_priv = client; 138 lis3_dev.bus_priv = client;
@@ -153,13 +146,11 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
153 i2c_set_clientdata(client, &lis3_dev); 146 i2c_set_clientdata(client, &lis3_dev);
154 147
155 /* Provide power over the init call */ 148 /* Provide power over the init call */
156 if (lis3_dev.reg_ctrl) 149 lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
157 lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
158 150
159 ret = lis3lv02d_init_device(&lis3_dev); 151 ret = lis3lv02d_init_device(&lis3_dev);
160 152
161 if (lis3_dev.reg_ctrl) 153 lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
162 lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
163 154
164 if (ret) 155 if (ret)
165 goto fail2; 156 goto fail2;
@@ -185,9 +176,8 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client)
185 lis3lv02d_joystick_disable(lis3); 176 lis3lv02d_joystick_disable(lis3);
186 lis3lv02d_remove_fs(&lis3_dev); 177 lis3lv02d_remove_fs(&lis3_dev);
187 178
188 if (lis3_dev.reg_ctrl) 179 regulator_bulk_free(ARRAY_SIZE(lis3->regulators),
189 regulator_bulk_free(ARRAY_SIZE(lis3->regulators), 180 lis3_dev.regulators);
190 lis3_dev.regulators);
191 return 0; 181 return 0;
192} 182}
193 183
diff --git a/include/linux/lis3lv02d.h b/include/linux/lis3lv02d.h
index d4292c8431e0..f1664c636af0 100644
--- a/include/linux/lis3lv02d.h
+++ b/include/linux/lis3lv02d.h
@@ -113,7 +113,6 @@ struct lis3lv02d_platform_data {
113 s8 axis_x; 113 s8 axis_x;
114 s8 axis_y; 114 s8 axis_y;
115 s8 axis_z; 115 s8 axis_z;
116#define LIS3_USE_REGULATOR_CTRL 0x01
117#define LIS3_USE_BLOCK_READ 0x02 116#define LIS3_USE_BLOCK_READ 0x02
118 u16 driver_features; 117 u16 driver_features;
119 int default_rate; 118 int default_rate;