From: Andy Walls <awalls@md.metrocast.net>
To: linux-media@vger.kernel.org
Cc: Jean Delvare <khali@linux-fr.org>,
Jarod Wilson <jarod@redhat.com>, Janne Grunau <j@jannau.net>,
Mauro Carvalho Chehab <mchehab@redhat.com>
Subject: [PATCH 3/3] lirc_zilog: Remove use of deprecated struct i2c_adapter.id field
Date: Tue, 28 Dec 2010 20:49:50 -0500 [thread overview]
Message-ID: <1293587390.3098.16.camel@localhost> (raw)
In-Reply-To: <1293587067.3098.10.camel@localhost>
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>
---
drivers/staging/lirc/lirc_zilog.c | 47 ++++++++++++++++++++++++------------
1 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
index 52be6de..ad29bb1 100644
--- a/drivers/staging/lirc/lirc_zilog.c
+++ b/drivers/staging/lirc/lirc_zilog.c
@@ -66,6 +66,7 @@ struct IR {
/* Device info */
struct mutex ir_lock;
int open;
+ bool is_hdpvr;
/* RX device */
struct i2c_client c_rx;
@@ -206,16 +207,12 @@ static int add_to_buf(struct IR *ir)
}
/* key pressed ? */
-#ifdef I2C_HW_B_HDPVR
- if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR) {
+ if (ir->is_hdpvr) {
if (got_data && (keybuf[0] == 0x80))
return 0;
else if (got_data && (keybuf[0] == 0x00))
return -ENODATA;
} else if ((ir->b[0] & 0x80) == 0)
-#else
- if ((ir->b[0] & 0x80) == 0)
-#endif
return got_data ? 0 : -ENODATA;
/* look what we have */
@@ -841,15 +838,15 @@ static int send_code(struct IR *ir, unsigned int code, unsigned int key)
return ret < 0 ? ret : -EFAULT;
}
-#ifdef I2C_HW_B_HDPVR
/*
* The sleep bits aren't necessary on the HD PVR, and in fact, the
* last i2c_master_recv always fails with a -5, so for now, we're
* going to skip this whole mess and say we're done on the HD PVR
*/
- if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR)
- goto done;
-#endif
+ if (ir->is_hdpvr) {
+ dprintk("sent code %u, key %u\n", code, key);
+ return 0;
+ }
/*
* This bit NAKs until the device is ready, so we retry it
@@ -1111,12 +1108,14 @@ static int ir_remove(struct i2c_client *client);
static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id);
static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg);
+#define ID_FLAG_TX 0x01
+#define ID_FLAG_HDPVR 0x02
+
static const struct i2c_device_id ir_transceiver_id[] = {
- /* Generic entry for any IR transceiver */
- { "ir_video", 0 },
- /* IR device specific entries should be added here */
- { "ir_tx_z8f0811_haup", 0 },
- { "ir_rx_z8f0811_haup", 0 },
+ { "ir_tx_z8f0811_haup", ID_FLAG_TX },
+ { "ir_rx_z8f0811_haup", 0 },
+ { "ir_tx_z8f0811_hdpvr", ID_FLAG_HDPVR | ID_FLAG_TX },
+ { "ir_rx_z8f0811_hdpvr", ID_FLAG_HDPVR },
{ }
};
@@ -1196,10 +1195,25 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
int ret;
int have_rx = 0, have_tx = 0;
- dprintk("%s: adapter id=0x%x, client addr=0x%02x\n",
- __func__, adap->id, client->addr);
+ dprintk("%s: adapter name (%s) nr %d, i2c_device_id name (%s), "
+ "client addr=0x%02x\n",
+ __func__, adap->name, adap->nr, id->name, client->addr);
/*
+ * FIXME - This probe function probes both the Tx and Rx
+ * addresses of the IR microcontroller.
+ *
+ * However, the I2C subsystem is passing along one I2C client at a
+ * time, based on matches to the ir_transceiver_id[] table above.
+ * The expectation is that each i2c_client address will be probed
+ * individually by drivers so the I2C subsystem can mark all client
+ * addresses as claimed or not.
+ *
+ * This probe routine causes only one of the client addresses, TX or RX,
+ * to be claimed. This will cause a problem if the I2C subsystem is
+ * subsequently triggered to probe unclaimed clients again.
+ */
+ /*
* The external IR receiver is at i2c address 0x71.
* The IR transmitter is at 0x70.
*/
@@ -1241,6 +1255,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
mutex_init(&ir->ir_lock);
mutex_init(&ir->buf_lock);
ir->need_boot = 1;
+ ir->is_hdpvr = (id->driver_data & ID_FLAG_HDPVR) ? true : false;
memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver));
ir->l.minor = -1;
--
1.7.2.1
next prev parent reply other threads:[~2010-12-29 2:47 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1293587067.3098.10.camel@localhost>
2010-12-29 1:46 ` [PATCH 1/3] hdpvr: Add I2C and ir-kdb-i2c registration of the Zilog Z8 IR chip Andy Walls
2010-12-29 11:08 ` Mauro Carvalho Chehab
2010-12-29 13:40 ` Andy Walls
2011-01-05 12:50 ` Jean Delvare
2011-01-05 22:44 ` Andy Walls
2010-12-29 1:47 ` [PATCH 2/3] ir-kbd-i2c: Add HD PVR IR Rx support to ir-kbd-i2c Andy Walls
2010-12-29 11:12 ` Mauro Carvalho Chehab
2010-12-29 14:14 ` Andy Walls
2011-01-05 12:53 ` Jean Delvare
2010-12-29 1:49 ` Andy Walls [this message]
2011-01-05 14:45 ` [PATCH 3/3] lirc_zilog: Remove use of deprecated struct i2c_adapter.id field Jean Delvare
2011-01-05 17:34 ` Mauro Carvalho Chehab
2011-01-05 21:51 ` Jean Delvare
2011-01-05 22:02 ` Mauro Carvalho Chehab
2011-01-06 1:20 ` Andy Walls
2011-01-13 9:46 ` Jean Delvare
2011-01-13 13:31 ` Jean Delvare
2011-01-06 0:46 ` Andy Walls
2011-01-13 13:21 ` Jean Delvare
2011-01-13 14:12 ` Devin Heitmueller
2011-01-13 16:34 Andy Walls
2011-01-13 16:48 ` Jean Delvare
2011-01-13 17:07 ` Devin Heitmueller
2011-01-13 17:19 ` Jean Delvare
2011-01-13 17:04 ` Devin Heitmueller
-- strict thread matches above, loose matches on Subject: below --
2011-01-13 16:59 Andy Walls
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1293587390.3098.16.camel@localhost \
--to=awalls@md.metrocast.net \
--cc=j@jannau.net \
--cc=jarod@redhat.com \
--cc=khali@linux-fr.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox