aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/tmp102.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2014-02-02 17:22:30 -0500
committerGuenter Roeck <linux@roeck-us.net>2014-05-21 19:02:20 -0400
commitfbd9af164c4a70e6f37b6985de8d481a6958cc2c (patch)
tree6ecfa86c71351e144185921d96a047eeb81ff350 /drivers/hwmon/tmp102.c
parentaa9bcddada9e6e6538ac44b3623bb23b802ba689 (diff)
hwmon: (tmp102) Introduce dev variable in probe function
The pointer to client->dev is used several times in the probe function. Simplify code by introducing a separate variable for it. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/tmp102.c')
-rw-r--r--drivers/hwmon/tmp102.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 6748b4583e7b..5ea99a25fdfe 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -162,17 +162,18 @@ static const struct attribute_group tmp102_attr_group = {
162static int tmp102_probe(struct i2c_client *client, 162static int tmp102_probe(struct i2c_client *client,
163 const struct i2c_device_id *id) 163 const struct i2c_device_id *id)
164{ 164{
165 struct device *dev = &client->dev;
165 struct tmp102 *tmp102; 166 struct tmp102 *tmp102;
166 int status; 167 int status;
167 168
168 if (!i2c_check_functionality(client->adapter, 169 if (!i2c_check_functionality(client->adapter,
169 I2C_FUNC_SMBUS_WORD_DATA)) { 170 I2C_FUNC_SMBUS_WORD_DATA)) {
170 dev_err(&client->dev, 171 dev_err(dev,
171 "adapter doesn't support SMBus word transactions\n"); 172 "adapter doesn't support SMBus word transactions\n");
172 return -ENODEV; 173 return -ENODEV;
173 } 174 }
174 175
175 tmp102 = devm_kzalloc(&client->dev, sizeof(*tmp102), GFP_KERNEL); 176 tmp102 = devm_kzalloc(dev, sizeof(*tmp102), GFP_KERNEL);
176 if (!tmp102) 177 if (!tmp102)
177 return -ENOMEM; 178 return -ENOMEM;
178 179
@@ -180,54 +181,53 @@ static int tmp102_probe(struct i2c_client *client,
180 181
181 status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG); 182 status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
182 if (status < 0) { 183 if (status < 0) {
183 dev_err(&client->dev, "error reading config register\n"); 184 dev_err(dev, "error reading config register\n");
184 return status; 185 return status;
185 } 186 }
186 tmp102->config_orig = status; 187 tmp102->config_orig = status;
187 status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, 188 status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
188 TMP102_CONFIG); 189 TMP102_CONFIG);
189 if (status < 0) { 190 if (status < 0) {
190 dev_err(&client->dev, "error writing config register\n"); 191 dev_err(dev, "error writing config register\n");
191 goto fail_restore_config; 192 goto fail_restore_config;
192 } 193 }
193 status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG); 194 status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
194 if (status < 0) { 195 if (status < 0) {
195 dev_err(&client->dev, "error reading config register\n"); 196 dev_err(dev, "error reading config register\n");
196 goto fail_restore_config; 197 goto fail_restore_config;
197 } 198 }
198 status &= ~TMP102_CONFIG_RD_ONLY; 199 status &= ~TMP102_CONFIG_RD_ONLY;
199 if (status != TMP102_CONFIG) { 200 if (status != TMP102_CONFIG) {
200 dev_err(&client->dev, "config settings did not stick\n"); 201 dev_err(dev, "config settings did not stick\n");
201 status = -ENODEV; 202 status = -ENODEV;
202 goto fail_restore_config; 203 goto fail_restore_config;
203 } 204 }
204 tmp102->last_update = jiffies - HZ; 205 tmp102->last_update = jiffies - HZ;
205 mutex_init(&tmp102->lock); 206 mutex_init(&tmp102->lock);
206 207
207 status = sysfs_create_group(&client->dev.kobj, &tmp102_attr_group); 208 status = sysfs_create_group(&dev->kobj, &tmp102_attr_group);
208 if (status) { 209 if (status) {
209 dev_dbg(&client->dev, "could not create sysfs files\n"); 210 dev_dbg(dev, "could not create sysfs files\n");
210 goto fail_restore_config; 211 goto fail_restore_config;
211 } 212 }
212 tmp102->hwmon_dev = hwmon_device_register(&client->dev); 213 tmp102->hwmon_dev = hwmon_device_register(dev);
213 if (IS_ERR(tmp102->hwmon_dev)) { 214 if (IS_ERR(tmp102->hwmon_dev)) {
214 dev_dbg(&client->dev, "unable to register hwmon device\n"); 215 dev_dbg(dev, "unable to register hwmon device\n");
215 status = PTR_ERR(tmp102->hwmon_dev); 216 status = PTR_ERR(tmp102->hwmon_dev);
216 goto fail_remove_sysfs; 217 goto fail_remove_sysfs;
217 } 218 }
218 219
219 tmp102->tz = thermal_zone_of_sensor_register(&client->dev, 0, 220 tmp102->tz = thermal_zone_of_sensor_register(dev, 0, dev,
220 &client->dev,
221 tmp102_read_temp, NULL); 221 tmp102_read_temp, NULL);
222 if (IS_ERR(tmp102->tz)) 222 if (IS_ERR(tmp102->tz))
223 tmp102->tz = NULL; 223 tmp102->tz = NULL;
224 224
225 dev_info(&client->dev, "initialized\n"); 225 dev_info(dev, "initialized\n");
226 226
227 return 0; 227 return 0;
228 228
229fail_remove_sysfs: 229fail_remove_sysfs:
230 sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); 230 sysfs_remove_group(&dev->kobj, &tmp102_attr_group);
231fail_restore_config: 231fail_restore_config:
232 i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, 232 i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
233 tmp102->config_orig); 233 tmp102->config_orig);