History

[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.

Andy Walls committed 15 years ago

Commit d7c72351 parent a9cd5911 file · +31 −16Browse files

Showing the changes to drivers/staging/lirc (1 of 1 file). Show all

Unified · Split

drivers/staging/lirc/lirc_zilog.c+31−16
@@ -66,6 +66,7 @@ struct IR { · 65 unmodified lines
6666 /* Device info */
6767 struct mutex ir_lock;
6868 int open;
69+ bool is_hdpvr;
6970
7071 /* RX device */
7172 struct i2c_client c_rx;
@@ -206,16 +207,12 @@ static int add_to_buf(struct IR *ir) · 134 unmodified lines
206207 }
207208
208209 /* key pressed ? */
209−#ifdef I2C_HW_B_HDPVR
210− if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR) {
210+ if (ir->is_hdpvr) {
211211 if (got_data && (keybuf[0] == 0x80))
212212 return 0;
213213 else if (got_data && (keybuf[0] == 0x00))
214214 return -ENODATA;
215215 } else if ((ir->b[0] & 0x80) == 0)
216−#else
217− if ((ir->b[0] & 0x80) == 0)
218−#endif
219216 return got_data ? 0 : -ENODATA;
220217
221218 /* look what we have */
@@ -841,15 +838,15 @@ static int send_code(struct IR *ir, unsigned int code, unsigned int key) · 619 unmodified lines
841838 return ret < 0 ? ret : -EFAULT;
842839 }
843840
844−#ifdef I2C_HW_B_HDPVR
845841 /*
846842 * The sleep bits aren't necessary on the HD PVR, and in fact, the
847843 * last i2c_master_recv always fails with a -5, so for now, we're
848844 * going to skip this whole mess and say we're done on the HD PVR
849845 */
850− if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR)
851− goto done;
852−#endif
846+ if (ir->is_hdpvr) {
847+ dprintk("sent code %u, key %u\n", code, key);
848+ return 0;
849+ }
853850
854851 /*
855852 * This bit NAKs until the device is ready, so we retry it
@@ -1111,12 +1108,14 @@ static int ir_remove(struct i2c_client *client); · 255 unmodified lines
11111108 static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id);
11121109 static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg);
11131110
1111+#define ID_FLAG_TX 0x01
1112+#define ID_FLAG_HDPVR 0x02
1113+
11141114 static const struct i2c_device_id ir_transceiver_id[] = {
1115− /* Generic entry for any IR transceiver */
1116− { "ir_video", 0 },
1117− /* IR device specific entries should be added here */
1118− { "ir_tx_z8f0811_haup", 0 },
1119− { "ir_rx_z8f0811_haup", 0 },
1115+ { "ir_tx_z8f0811_haup", ID_FLAG_TX },
1116+ { "ir_rx_z8f0811_haup", 0 },
1117+ { "ir_tx_z8f0811_hdpvr", ID_FLAG_HDPVR | ID_FLAG_TX },
1118+ { "ir_rx_z8f0811_hdpvr", ID_FLAG_HDPVR },
11201119 { }
11211120 };
11221121
@@ -1196,9 +1195,24 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) · 73 unmodified lines
11961195 int ret;
11971196 int have_rx = 0, have_tx = 0;
11981197
1199− dprintk("%s: adapter id=0x%x, client addr=0x%02x\n",
1200− __func__, adap->id, client->addr);
1198+ dprintk("%s: adapter name (%s) nr %d, i2c_device_id name (%s), "
1199+ "client addr=0x%02x\n",
1200+ __func__, adap->name, adap->nr, id->name, client->addr);
12011201
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+ */
12021216 /*
12031217 * The external IR receiver is at i2c address 0x71.
12041218 * The IR transmitter is at 0x70.
@@ -1241,6 +1255,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) · 36 unmodified lines
12411255 mutex_init(&ir->ir_lock);
12421256 mutex_init(&ir->buf_lock);
12431257 ir->need_boot = 1;
1258+ ir->is_hdpvr = (id->driver_data & ID_FLAG_HDPVR) ? true : false;
12441259
12451260 memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver));
12461261 ir->l.minor = -1;