Commit ec400c9f authored by Mark Brown's avatar Mark Brown Committed by Linus Torvalds

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Éric Piel <eric.piel@tremplin-utc.net>
Cc: Ilkka Koskinen <ilkka.koskinen@nokia.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 895c156c
...@@ -79,8 +79,7 @@ static int lis3_i2c_init(struct lis3lv02d *lis3) ...@@ -79,8 +79,7 @@ static int lis3_i2c_init(struct lis3lv02d *lis3)
u8 reg; u8 reg;
int ret; int ret;
if (lis3->reg_ctrl) lis3_reg_ctrl(lis3, LIS3_REG_ON);
lis3_reg_ctrl(lis3, LIS3_REG_ON);
lis3->read(lis3, WHO_AM_I, &reg); lis3->read(lis3, WHO_AM_I, &reg);
if (reg != lis3->whoami) if (reg != lis3->whoami)
...@@ -106,10 +105,6 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, ...@@ -106,10 +105,6 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
struct lis3lv02d_platform_data *pdata = client->dev.platform_data; struct lis3lv02d_platform_data *pdata = client->dev.platform_data;
if (pdata) { if (pdata) {
/* Regulator control is optional */
if (pdata->driver_features & LIS3_USE_REGULATOR_CTRL)
lis3_dev.reg_ctrl = lis3_reg_ctrl;
if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && if ((pdata->driver_features & LIS3_USE_BLOCK_READ) &&
(i2c_check_functionality(client->adapter, (i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_I2C_BLOCK))) I2C_FUNC_SMBUS_I2C_BLOCK)))
...@@ -131,15 +126,13 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, ...@@ -131,15 +126,13 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
goto fail; goto fail;
} }
if (lis3_dev.reg_ctrl) { lis3_dev.regulators[0].supply = reg_vdd;
lis3_dev.regulators[0].supply = reg_vdd; lis3_dev.regulators[1].supply = reg_vdd_io;
lis3_dev.regulators[1].supply = reg_vdd_io; ret = regulator_bulk_get(&client->dev,
ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(lis3_dev.regulators),
ARRAY_SIZE(lis3_dev.regulators), lis3_dev.regulators);
lis3_dev.regulators); if (ret < 0)
if (ret < 0) goto fail;
goto fail;
}
lis3_dev.pdata = pdata; lis3_dev.pdata = pdata;
lis3_dev.bus_priv = client; lis3_dev.bus_priv = client;
...@@ -153,13 +146,11 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, ...@@ -153,13 +146,11 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, &lis3_dev); i2c_set_clientdata(client, &lis3_dev);
/* Provide power over the init call */ /* Provide power over the init call */
if (lis3_dev.reg_ctrl) lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
ret = lis3lv02d_init_device(&lis3_dev); ret = lis3lv02d_init_device(&lis3_dev);
if (lis3_dev.reg_ctrl) lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
if (ret) if (ret)
goto fail2; goto fail2;
...@@ -185,9 +176,8 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client) ...@@ -185,9 +176,8 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client)
lis3lv02d_joystick_disable(lis3); lis3lv02d_joystick_disable(lis3);
lis3lv02d_remove_fs(&lis3_dev); lis3lv02d_remove_fs(&lis3_dev);
if (lis3_dev.reg_ctrl) regulator_bulk_free(ARRAY_SIZE(lis3->regulators),
regulator_bulk_free(ARRAY_SIZE(lis3->regulators), lis3_dev.regulators);
lis3_dev.regulators);
return 0; return 0;
} }
......
...@@ -113,7 +113,6 @@ struct lis3lv02d_platform_data { ...@@ -113,7 +113,6 @@ struct lis3lv02d_platform_data {
s8 axis_x; s8 axis_x;
s8 axis_y; s8 axis_y;
s8 axis_z; s8 axis_z;
#define LIS3_USE_REGULATOR_CTRL 0x01
#define LIS3_USE_BLOCK_READ 0x02 #define LIS3_USE_BLOCK_READ 0x02
u16 driver_features; u16 driver_features;
int default_rate; int default_rate;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment