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