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

max6875: Discard obsolete detect method

There is no point in implementing a detect callback for the MAX6875, 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 basically divides the binary module size by 2.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Ben Gardner <gardner.ben@gmail.com>

+9 -26
+4 -2
Documentation/misc-devices/max6875
··· 42 42 43 43 Valid addresses for the MAX6875 are 0x50 and 0x52. 44 44 Valid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56. 45 - The driver does not probe any address, so you must force the address. 45 + The driver does not probe any address, so you explicitly instantiate the 46 + devices. 46 47 47 48 Example: 48 - $ modprobe max6875 force=0,0x50 49 + $ modprobe max6875 50 + $ echo max6875 0x50 > /sys/bus/i2c/devices/i2c-0/new_device 49 51 50 52 The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple 51 53 addresses. For example, for address 0x50, it also reserves 0x51.
+5 -24
drivers/misc/eeprom/max6875.c
··· 33 33 #include <linux/i2c.h> 34 34 #include <linux/mutex.h> 35 35 36 - /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ 37 - static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; 38 - 39 - /* Insmod parameters */ 40 - I2C_CLIENT_INSMOD_1(max6875); 41 - 42 36 /* The MAX6875 can only read/write 16 bytes at a time */ 43 37 #define SLICE_SIZE 16 44 38 #define SLICE_BITS 4 ··· 140 146 .read = max6875_read, 141 147 }; 142 148 143 - /* Return 0 if detection is successful, -ENODEV otherwise */ 144 - static int max6875_detect(struct i2c_client *client, int kind, 145 - struct i2c_board_info *info) 149 + static int max6875_probe(struct i2c_client *client, 150 + const struct i2c_device_id *id) 146 151 { 147 152 struct i2c_adapter *adapter = client->adapter; 153 + struct max6875_data *data; 154 + int err; 148 155 149 156 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA 150 157 | I2C_FUNC_SMBUS_READ_BYTE)) 151 158 return -ENODEV; 152 159 153 - /* Only check even addresses */ 160 + /* Only bind to even addresses */ 154 161 if (client->addr & 1) 155 162 return -ENODEV; 156 - 157 - strlcpy(info->type, "max6875", I2C_NAME_SIZE); 158 - 159 - return 0; 160 - } 161 - 162 - static int max6875_probe(struct i2c_client *client, 163 - const struct i2c_device_id *id) 164 - { 165 - struct max6875_data *data; 166 - int err; 167 163 168 164 if (!(data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL))) 169 165 return -ENOMEM; ··· 206 222 .probe = max6875_probe, 207 223 .remove = max6875_remove, 208 224 .id_table = max6875_id, 209 - 210 - .detect = max6875_detect, 211 - .address_data = &addr_data, 212 225 }; 213 226 214 227 static int __init max6875_init(void)