diff options
Diffstat (limited to 'drivers/misc/lis3lv02d/lis3lv02d_i2c.c')
| -rw-r--r-- | drivers/misc/lis3lv02d/lis3lv02d_i2c.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c index b20dfb4522d2..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, ®); | 84 | lis3->read(lis3, WHO_AM_I, ®); |
| 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,16 +146,19 @@ 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 == 0) | 155 | if (ret) |
| 165 | return 0; | 156 | goto fail2; |
| 157 | return 0; | ||
| 158 | |||
| 159 | fail2: | ||
| 160 | regulator_bulk_free(ARRAY_SIZE(lis3_dev.regulators), | ||
| 161 | lis3_dev.regulators); | ||
| 166 | fail: | 162 | fail: |
| 167 | if (pdata && pdata->release_resources) | 163 | if (pdata && pdata->release_resources) |
| 168 | pdata->release_resources(); | 164 | pdata->release_resources(); |
| @@ -177,12 +173,11 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client) | |||
| 177 | if (pdata && pdata->release_resources) | 173 | if (pdata && pdata->release_resources) |
| 178 | pdata->release_resources(); | 174 | pdata->release_resources(); |
| 179 | 175 | ||
| 180 | lis3lv02d_joystick_disable(); | 176 | lis3lv02d_joystick_disable(lis3); |
| 181 | lis3lv02d_remove_fs(&lis3_dev); | 177 | lis3lv02d_remove_fs(&lis3_dev); |
| 182 | 178 | ||
| 183 | if (lis3_dev.reg_ctrl) | 179 | regulator_bulk_free(ARRAY_SIZE(lis3->regulators), |
| 184 | regulator_bulk_free(ARRAY_SIZE(lis3->regulators), | 180 | lis3_dev.regulators); |
| 185 | lis3_dev.regulators); | ||
| 186 | return 0; | 181 | return 0; |
| 187 | } | 182 | } |
| 188 | 183 | ||
