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

[media] lirc_zilog: Remove use of deprecated struct i2c_adapter.id field

Remove use of deprecated struct i2c_adapter.id field. In the process,
perform different detection of the HD PVR's Z8 IR microcontroller versus
the other Hauppauge cards with the Z8 IR microcontroller.

Also added a comment about probe() function behavior that needs to be
fixed.

Signed-off-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Andy Walls and committed by
Mauro Carvalho Chehab
d7c72356 a9cd591e

+31 -16
+31 -16
drivers/staging/lirc/lirc_zilog.c
··· 66 66 /* Device info */ 67 67 struct mutex ir_lock; 68 68 int open; 69 + bool is_hdpvr; 69 70 70 71 /* RX device */ 71 72 struct i2c_client c_rx; ··· 207 206 } 208 207 209 208 /* key pressed ? */ 210 - #ifdef I2C_HW_B_HDPVR 211 - if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR) { 209 + if (ir->is_hdpvr) { 212 210 if (got_data && (keybuf[0] == 0x80)) 213 211 return 0; 214 212 else if (got_data && (keybuf[0] == 0x00)) 215 213 return -ENODATA; 216 214 } else if ((ir->b[0] & 0x80) == 0) 217 - #else 218 - if ((ir->b[0] & 0x80) == 0) 219 - #endif 220 215 return got_data ? 0 : -ENODATA; 221 216 222 217 /* look what we have */ ··· 838 841 return ret < 0 ? ret : -EFAULT; 839 842 } 840 843 841 - #ifdef I2C_HW_B_HDPVR 842 844 /* 843 845 * The sleep bits aren't necessary on the HD PVR, and in fact, the 844 846 * last i2c_master_recv always fails with a -5, so for now, we're 845 847 * going to skip this whole mess and say we're done on the HD PVR 846 848 */ 847 - if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR) 848 - goto done; 849 - #endif 849 + if (ir->is_hdpvr) { 850 + dprintk("sent code %u, key %u\n", code, key); 851 + return 0; 852 + } 850 853 851 854 /* 852 855 * This bit NAKs until the device is ready, so we retry it ··· 1108 1111 static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id); 1109 1112 static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg); 1110 1113 1114 + #define ID_FLAG_TX 0x01 1115 + #define ID_FLAG_HDPVR 0x02 1116 + 1111 1117 static const struct i2c_device_id ir_transceiver_id[] = { 1112 - /* Generic entry for any IR transceiver */ 1113 - { "ir_video", 0 }, 1114 - /* IR device specific entries should be added here */ 1115 - { "ir_tx_z8f0811_haup", 0 }, 1116 - { "ir_rx_z8f0811_haup", 0 }, 1118 + { "ir_tx_z8f0811_haup", ID_FLAG_TX }, 1119 + { "ir_rx_z8f0811_haup", 0 }, 1120 + { "ir_tx_z8f0811_hdpvr", ID_FLAG_HDPVR | ID_FLAG_TX }, 1121 + { "ir_rx_z8f0811_hdpvr", ID_FLAG_HDPVR }, 1117 1122 { } 1118 1123 }; 1119 1124 ··· 1195 1196 int ret; 1196 1197 int have_rx = 0, have_tx = 0; 1197 1198 1198 - dprintk("%s: adapter id=0x%x, client addr=0x%02x\n", 1199 - __func__, adap->id, client->addr); 1199 + dprintk("%s: adapter name (%s) nr %d, i2c_device_id name (%s), " 1200 + "client addr=0x%02x\n", 1201 + __func__, adap->name, adap->nr, id->name, client->addr); 1200 1202 1203 + /* 1204 + * FIXME - This probe function probes both the Tx and Rx 1205 + * addresses of the IR microcontroller. 1206 + * 1207 + * However, the I2C subsystem is passing along one I2C client at a 1208 + * time, based on matches to the ir_transceiver_id[] table above. 1209 + * The expectation is that each i2c_client address will be probed 1210 + * individually by drivers so the I2C subsystem can mark all client 1211 + * addresses as claimed or not. 1212 + * 1213 + * This probe routine causes only one of the client addresses, TX or RX, 1214 + * to be claimed. This will cause a problem if the I2C subsystem is 1215 + * subsequently triggered to probe unclaimed clients again. 1216 + */ 1201 1217 /* 1202 1218 * The external IR receiver is at i2c address 0x71. 1203 1219 * The IR transmitter is at 0x70. ··· 1255 1241 mutex_init(&ir->ir_lock); 1256 1242 mutex_init(&ir->buf_lock); 1257 1243 ir->need_boot = 1; 1244 + ir->is_hdpvr = (id->driver_data & ID_FLAG_HDPVR) ? true : false; 1258 1245 1259 1246 memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver)); 1260 1247 ir->l.minor = -1;