@@ -54,11 +54,11 @@ enum lm75_type { /* keep sorted in alphabetical order */
54
54
tmp75 ,
55
55
};
56
56
57
- /* Addresses scanned by legacy style driver binding */
57
+ /* Addresses scanned */
58
58
static const unsigned short normal_i2c [] = { 0x48 , 0x49 , 0x4a , 0x4b , 0x4c ,
59
59
0x4d , 0x4e , 0x4f , I2C_CLIENT_END };
60
60
61
- /* Insmod parameters (only for legacy style driver binding) */
61
+ /* Insmod parameters */
62
62
I2C_CLIENT_INSMOD_1 (lm75 );
63
63
64
64
@@ -72,7 +72,6 @@ static const u8 LM75_REG_TEMP[3] = {
72
72
73
73
/* Each client has this additional data */
74
74
struct lm75_data {
75
- struct i2c_client * client ;
76
75
struct device * hwmon_dev ;
77
76
struct mutex update_lock ;
78
77
u8 orig_conf ;
@@ -138,7 +137,7 @@ static const struct attribute_group lm75_group = {
138
137
139
138
/*-----------------------------------------------------------------------*/
140
139
141
- /* "New style" I2C driver binding -- following the driver model */
140
+ /* device probe and removal */
142
141
143
142
static int
144
143
lm75_probe (struct i2c_client * client , const struct i2c_device_id * id )
@@ -157,8 +156,6 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
157
156
return - ENOMEM ;
158
157
159
158
i2c_set_clientdata (client , data );
160
-
161
- data -> client = client ;
162
159
mutex_init (& data -> update_lock );
163
160
164
161
/* Set to LM75 resolution (9 bits, 1/2 degree C) and range.
@@ -236,45 +233,16 @@ static const struct i2c_device_id lm75_ids[] = {
236
233
};
237
234
MODULE_DEVICE_TABLE (i2c , lm75_ids );
238
235
239
- static struct i2c_driver lm75_driver = {
240
- .driver = {
241
- .name = "lm75" ,
242
- },
243
- .probe = lm75_probe ,
244
- .remove = lm75_remove ,
245
- .id_table = lm75_ids ,
246
- };
247
-
248
- /*-----------------------------------------------------------------------*/
249
-
250
- /* "Legacy" I2C driver binding */
251
-
252
- static struct i2c_driver lm75_legacy_driver ;
253
-
254
- /* This function is called by i2c_probe */
255
- static int lm75_detect (struct i2c_adapter * adapter , int address , int kind )
236
+ /* Return 0 if detection is successful, -ENODEV otherwise */
237
+ static int lm75_detect (struct i2c_client * new_client , int kind ,
238
+ struct i2c_board_info * info )
256
239
{
240
+ struct i2c_adapter * adapter = new_client -> adapter ;
257
241
int i ;
258
- struct i2c_client * new_client ;
259
- int err = 0 ;
260
242
261
243
if (!i2c_check_functionality (adapter , I2C_FUNC_SMBUS_BYTE_DATA |
262
244
I2C_FUNC_SMBUS_WORD_DATA ))
263
- goto exit ;
264
-
265
- /* OK. For now, we presume we have a valid address. We create the
266
- client structure, even though there may be no sensor present.
267
- But it allows us to use i2c_smbus_read_*_data() calls. */
268
- new_client = kzalloc (sizeof * new_client , GFP_KERNEL );
269
- if (!new_client ) {
270
- err = - ENOMEM ;
271
- goto exit ;
272
- }
273
-
274
- new_client -> addr = address ;
275
- new_client -> adapter = adapter ;
276
- new_client -> driver = & lm75_legacy_driver ;
277
- new_client -> flags = 0 ;
245
+ return - ENODEV ;
278
246
279
247
/* Now, we do the remaining detection. There is no identification-
280
248
dedicated register so we have to rely on several tricks:
@@ -294,71 +262,44 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
294
262
|| i2c_smbus_read_word_data (new_client , 5 ) != hyst
295
263
|| i2c_smbus_read_word_data (new_client , 6 ) != hyst
296
264
|| i2c_smbus_read_word_data (new_client , 7 ) != hyst )
297
- goto exit_free ;
265
+ return - ENODEV ;
298
266
os = i2c_smbus_read_word_data (new_client , 3 );
299
267
if (i2c_smbus_read_word_data (new_client , 4 ) != os
300
268
|| i2c_smbus_read_word_data (new_client , 5 ) != os
301
269
|| i2c_smbus_read_word_data (new_client , 6 ) != os
302
270
|| i2c_smbus_read_word_data (new_client , 7 ) != os )
303
- goto exit_free ;
271
+ return - ENODEV ;
304
272
305
273
/* Unused bits */
306
274
if (conf & 0xe0 )
307
- goto exit_free ;
275
+ return - ENODEV ;
308
276
309
277
/* Addresses cycling */
310
278
for (i = 8 ; i < 0xff ; i += 8 )
311
279
if (i2c_smbus_read_byte_data (new_client , i + 1 ) != conf
312
280
|| i2c_smbus_read_word_data (new_client , i + 2 ) != hyst
313
281
|| i2c_smbus_read_word_data (new_client , i + 3 ) != os )
314
- goto exit_free ;
282
+ return - ENODEV ;
315
283
}
316
284
317
285
/* NOTE: we treat "force=..." and "force_lm75=..." the same.
318
286
* Only new-style driver binding distinguishes chip types.
319
287
*/
320
- strlcpy (new_client -> name , "lm75" , I2C_NAME_SIZE );
321
-
322
- /* Tell the I2C layer a new client has arrived */
323
- err = i2c_attach_client (new_client );
324
- if (err )
325
- goto exit_free ;
326
-
327
- err = lm75_probe (new_client , NULL );
328
- if (err < 0 )
329
- goto exit_detach ;
288
+ strlcpy (info -> type , "lm75" , I2C_NAME_SIZE );
330
289
331
290
return 0 ;
332
-
333
- exit_detach :
334
- i2c_detach_client (new_client );
335
- exit_free :
336
- kfree (new_client );
337
- exit :
338
- return err ;
339
- }
340
-
341
- static int lm75_attach_adapter (struct i2c_adapter * adapter )
342
- {
343
- if (!(adapter -> class & I2C_CLASS_HWMON ))
344
- return 0 ;
345
- return i2c_probe (adapter , & addr_data , lm75_detect );
346
291
}
347
292
348
- static int lm75_detach_client (struct i2c_client * client )
349
- {
350
- lm75_remove (client );
351
- i2c_detach_client (client );
352
- kfree (client );
353
- return 0 ;
354
- }
355
-
356
- static struct i2c_driver lm75_legacy_driver = {
293
+ static struct i2c_driver lm75_driver = {
294
+ .class = I2C_CLASS_HWMON ,
357
295
.driver = {
358
- .name = "lm75_legacy " ,
296
+ .name = "lm75 " ,
359
297
},
360
- .attach_adapter = lm75_attach_adapter ,
361
- .detach_client = lm75_detach_client ,
298
+ .probe = lm75_probe ,
299
+ .remove = lm75_remove ,
300
+ .id_table = lm75_ids ,
301
+ .detect = lm75_detect ,
302
+ .address_data = & addr_data ,
362
303
};
363
304
364
305
/*-----------------------------------------------------------------------*/
@@ -424,22 +365,11 @@ static struct lm75_data *lm75_update_device(struct device *dev)
424
365
425
366
static int __init sensors_lm75_init (void )
426
367
{
427
- int status ;
428
-
429
- status = i2c_add_driver (& lm75_driver );
430
- if (status < 0 )
431
- return status ;
432
-
433
- status = i2c_add_driver (& lm75_legacy_driver );
434
- if (status < 0 )
435
- i2c_del_driver (& lm75_driver );
436
-
437
- return status ;
368
+ return i2c_add_driver (& lm75_driver );
438
369
}
439
370
440
371
static void __exit sensors_lm75_exit (void )
441
372
{
442
- i2c_del_driver (& lm75_legacy_driver );
443
373
i2c_del_driver (& lm75_driver );
444
374
}
445
375
0 commit comments