Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ds2482: Discard obsolete detect method

There is no point in implementing a detect callback for the DS2482, as
this device can't be detected. It was there solely to handle "force"
module parameters to instantiate devices, but now we have a better sysfs
interface that can do the same.

So we can get rid of the ugly module parameters and the detect callback.
This shrinks the binary module size by 21%.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Ben Gardner <gardner.ben@gmail.com>

+8 -33
+3 -3
Documentation/w1/masters/ds2482
··· 24 24 25 25 Valid addresses are 0x18, 0x19, 0x1a, and 0x1b. 26 26 However, the device cannot be detected without writing to the i2c bus, so no 27 - detection is done. 28 - You should force the device address. 27 + detection is done. You should instantiate the device explicitly. 29 28 30 - $ modprobe ds2482 force=0,0x18 29 + $ modprobe ds2482 30 + $ echo ds2482 0x18 > /sys/bus/i2c/devices/i2c-0/new_device 31 31
+5 -30
drivers/w1/masters/ds2482.c
··· 24 24 #include "../w1_int.h" 25 25 26 26 /** 27 - * Address is selected using 2 pins, resulting in 4 possible addresses. 28 - * 0x18, 0x19, 0x1a, 0x1b 29 - * However, the chip cannot be detected without doing an i2c write, 30 - * so use the force module parameter. 31 - */ 32 - static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; 33 - 34 - /** 35 - * Insmod parameters 36 - */ 37 - I2C_CLIENT_INSMOD_1(ds2482); 38 - 39 - /** 40 27 * The DS2482 registers - there are 3 registers that are addressed by a read 41 28 * pointer. The read pointer is set by the last command executed. 42 29 * ··· 83 96 84 97 static int ds2482_probe(struct i2c_client *client, 85 98 const struct i2c_device_id *id); 86 - static int ds2482_detect(struct i2c_client *client, int kind, 87 - struct i2c_board_info *info); 88 99 static int ds2482_remove(struct i2c_client *client); 89 100 90 101 ··· 102 117 .probe = ds2482_probe, 103 118 .remove = ds2482_remove, 104 119 .id_table = ds2482_id, 105 - .detect = ds2482_detect, 106 - .address_data = &addr_data, 107 120 }; 108 121 109 122 /* ··· 408 425 } 409 426 410 427 411 - static int ds2482_detect(struct i2c_client *client, int kind, 412 - struct i2c_board_info *info) 413 - { 414 - if (!i2c_check_functionality(client->adapter, 415 - I2C_FUNC_SMBUS_WRITE_BYTE_DATA | 416 - I2C_FUNC_SMBUS_BYTE)) 417 - return -ENODEV; 418 - 419 - strlcpy(info->type, "ds2482", I2C_NAME_SIZE); 420 - 421 - return 0; 422 - } 423 - 424 428 static int ds2482_probe(struct i2c_client *client, 425 429 const struct i2c_device_id *id) 426 430 { ··· 415 445 int err = -ENODEV; 416 446 int temp1; 417 447 int idx; 448 + 449 + if (!i2c_check_functionality(client->adapter, 450 + I2C_FUNC_SMBUS_WRITE_BYTE_DATA | 451 + I2C_FUNC_SMBUS_BYTE)) 452 + return -ENODEV; 418 453 419 454 if (!(data = kzalloc(sizeof(struct ds2482_data), GFP_KERNEL))) { 420 455 err = -ENOMEM;