aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/lirc/lirc_zilog.c87
1 files changed, 28 insertions, 59 deletions
diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
index 85e312f33513..00f2e7d3b3e5 100644
--- a/drivers/staging/lirc/lirc_zilog.c
+++ b/drivers/staging/lirc/lirc_zilog.c
@@ -62,7 +62,7 @@
62 62
63struct IR_rx { 63struct IR_rx {
64 /* RX device */ 64 /* RX device */
65 struct i2c_client c_rx; 65 struct i2c_client *c;
66 66
67 /* RX device buffer & lock */ 67 /* RX device buffer & lock */
68 struct lirc_buffer buf; 68 struct lirc_buffer buf;
@@ -81,7 +81,7 @@ struct IR_rx {
81 81
82struct IR_tx { 82struct IR_tx {
83 /* TX device */ 83 /* TX device */
84 struct i2c_client c_tx; 84 struct i2c_client *c;
85 85
86 /* TX additional actions needed */ 86 /* TX additional actions needed */
87 int need_boot; 87 int need_boot;
@@ -132,9 +132,6 @@ static struct mutex tx_data_lock;
132 ## args) 132 ## args)
133#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) 133#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
134 134
135#define ZILOG_HAUPPAUGE_IR_RX_NAME "Zilog/Hauppauge IR RX"
136#define ZILOG_HAUPPAUGE_IR_TX_NAME "Zilog/Hauppauge IR TX"
137
138/* module parameters */ 135/* module parameters */
139static int debug; /* debug output */ 136static int debug; /* debug output */
140static int disable_rx; /* disable RX device */ 137static int disable_rx; /* disable RX device */
@@ -181,7 +178,7 @@ static int add_to_buf(struct IR *ir)
181 * Send random "poll command" (?) Windows driver does this 178 * Send random "poll command" (?) Windows driver does this
182 * and it is a good point to detect chip failure. 179 * and it is a good point to detect chip failure.
183 */ 180 */
184 ret = i2c_master_send(&rx->c_rx, sendbuf, 1); 181 ret = i2c_master_send(rx->c, sendbuf, 1);
185 if (ret != 1) { 182 if (ret != 1) {
186 zilog_error("i2c_master_send failed with %d\n", ret); 183 zilog_error("i2c_master_send failed with %d\n", ret);
187 if (failures >= 3) { 184 if (failures >= 3) {
@@ -205,7 +202,7 @@ static int add_to_buf(struct IR *ir)
205 continue; 202 continue;
206 } 203 }
207 204
208 ret = i2c_master_recv(&rx->c_rx, keybuf, sizeof(keybuf)); 205 ret = i2c_master_recv(rx->c, keybuf, sizeof(keybuf));
209 mutex_unlock(&ir->ir_lock); 206 mutex_unlock(&ir->ir_lock);
210 if (ret != sizeof(keybuf)) { 207 if (ret != sizeof(keybuf)) {
211 zilog_error("i2c_master_recv failed with %d -- " 208 zilog_error("i2c_master_recv failed with %d -- "
@@ -315,9 +312,9 @@ static int set_use_inc(void *data)
315 * must be possible even when the device is open 312 * must be possible even when the device is open
316 */ 313 */
317 if (ir->rx != NULL) 314 if (ir->rx != NULL)
318 i2c_use_client(&ir->rx->c_rx); 315 i2c_use_client(ir->rx->c);
319 if (ir->tx != NULL) 316 if (ir->tx != NULL)
320 i2c_use_client(&ir->tx->c_tx); 317 i2c_use_client(ir->tx->c);
321 318
322 return 0; 319 return 0;
323} 320}
@@ -327,9 +324,9 @@ static void set_use_dec(void *data)
327 struct IR *ir = data; 324 struct IR *ir = data;
328 325
329 if (ir->rx) 326 if (ir->rx)
330 i2c_release_client(&ir->rx->c_rx); 327 i2c_release_client(ir->rx->c);
331 if (ir->tx) 328 if (ir->tx)
332 i2c_release_client(&ir->tx->c_tx); 329 i2c_release_client(ir->tx->c);
333 if (ir->l.owner != NULL) 330 if (ir->l.owner != NULL)
334 module_put(ir->l.owner); 331 module_put(ir->l.owner);
335} 332}
@@ -482,7 +479,7 @@ static int send_data_block(struct IR_tx *tx, unsigned char *data_block)
482 buf[1 + j] = data_block[i + j]; 479 buf[1 + j] = data_block[i + j];
483 dprintk("%02x %02x %02x %02x %02x", 480 dprintk("%02x %02x %02x %02x %02x",
484 buf[0], buf[1], buf[2], buf[3], buf[4]); 481 buf[0], buf[1], buf[2], buf[3], buf[4]);
485 ret = i2c_master_send(&tx->c_tx, buf, tosend + 1); 482 ret = i2c_master_send(tx->c, buf, tosend + 1);
486 if (ret != tosend + 1) { 483 if (ret != tosend + 1) {
487 zilog_error("i2c_master_send failed with %d\n", ret); 484 zilog_error("i2c_master_send failed with %d\n", ret);
488 return ret < 0 ? ret : -EFAULT; 485 return ret < 0 ? ret : -EFAULT;
@@ -506,19 +503,19 @@ static int send_boot_data(struct IR_tx *tx)
506 /* kick it off? */ 503 /* kick it off? */
507 buf[0] = 0x00; 504 buf[0] = 0x00;
508 buf[1] = 0x20; 505 buf[1] = 0x20;
509 ret = i2c_master_send(&tx->c_tx, buf, 2); 506 ret = i2c_master_send(tx->c, buf, 2);
510 if (ret != 2) { 507 if (ret != 2) {
511 zilog_error("i2c_master_send failed with %d\n", ret); 508 zilog_error("i2c_master_send failed with %d\n", ret);
512 return ret < 0 ? ret : -EFAULT; 509 return ret < 0 ? ret : -EFAULT;
513 } 510 }
514 ret = i2c_master_send(&tx->c_tx, buf, 1); 511 ret = i2c_master_send(tx->c, buf, 1);
515 if (ret != 1) { 512 if (ret != 1) {
516 zilog_error("i2c_master_send failed with %d\n", ret); 513 zilog_error("i2c_master_send failed with %d\n", ret);
517 return ret < 0 ? ret : -EFAULT; 514 return ret < 0 ? ret : -EFAULT;
518 } 515 }
519 516
520 /* Here comes the firmware version... (hopefully) */ 517 /* Here comes the firmware version... (hopefully) */
521 ret = i2c_master_recv(&tx->c_tx, buf, 4); 518 ret = i2c_master_recv(tx->c, buf, 4);
522 if (ret != 4) { 519 if (ret != 4) {
523 zilog_error("i2c_master_recv failed with %d\n", ret); 520 zilog_error("i2c_master_recv failed with %d\n", ret);
524 return 0; 521 return 0;
@@ -573,7 +570,7 @@ static int fw_load(struct IR_tx *tx)
573 } 570 }
574 571
575 /* Request codeset data file */ 572 /* Request codeset data file */
576 ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &tx->c_tx.dev); 573 ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &tx->c->dev);
577 if (ret != 0) { 574 if (ret != 0) {
578 zilog_error("firmware haup-ir-blaster.bin not available " 575 zilog_error("firmware haup-ir-blaster.bin not available "
579 "(%d)\n", ret); 576 "(%d)\n", ret);
@@ -822,19 +819,19 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
822 /* Send data block length? */ 819 /* Send data block length? */
823 buf[0] = 0x00; 820 buf[0] = 0x00;
824 buf[1] = 0x40; 821 buf[1] = 0x40;
825 ret = i2c_master_send(&tx->c_tx, buf, 2); 822 ret = i2c_master_send(tx->c, buf, 2);
826 if (ret != 2) { 823 if (ret != 2) {
827 zilog_error("i2c_master_send failed with %d\n", ret); 824 zilog_error("i2c_master_send failed with %d\n", ret);
828 return ret < 0 ? ret : -EFAULT; 825 return ret < 0 ? ret : -EFAULT;
829 } 826 }
830 ret = i2c_master_send(&tx->c_tx, buf, 1); 827 ret = i2c_master_send(tx->c, buf, 1);
831 if (ret != 1) { 828 if (ret != 1) {
832 zilog_error("i2c_master_send failed with %d\n", ret); 829 zilog_error("i2c_master_send failed with %d\n", ret);
833 return ret < 0 ? ret : -EFAULT; 830 return ret < 0 ? ret : -EFAULT;
834 } 831 }
835 832
836 /* Send finished download? */ 833 /* Send finished download? */
837 ret = i2c_master_recv(&tx->c_tx, buf, 1); 834 ret = i2c_master_recv(tx->c, buf, 1);
838 if (ret != 1) { 835 if (ret != 1) {
839 zilog_error("i2c_master_recv failed with %d\n", ret); 836 zilog_error("i2c_master_recv failed with %d\n", ret);
840 return ret < 0 ? ret : -EFAULT; 837 return ret < 0 ? ret : -EFAULT;
@@ -848,7 +845,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
848 /* Send prepare command? */ 845 /* Send prepare command? */
849 buf[0] = 0x00; 846 buf[0] = 0x00;
850 buf[1] = 0x80; 847 buf[1] = 0x80;
851 ret = i2c_master_send(&tx->c_tx, buf, 2); 848 ret = i2c_master_send(tx->c, buf, 2);
852 if (ret != 2) { 849 if (ret != 2) {
853 zilog_error("i2c_master_send failed with %d\n", ret); 850 zilog_error("i2c_master_send failed with %d\n", ret);
854 return ret < 0 ? ret : -EFAULT; 851 return ret < 0 ? ret : -EFAULT;
@@ -873,7 +870,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
873 for (i = 0; i < 20; ++i) { 870 for (i = 0; i < 20; ++i) {
874 set_current_state(TASK_UNINTERRUPTIBLE); 871 set_current_state(TASK_UNINTERRUPTIBLE);
875 schedule_timeout((50 * HZ + 999) / 1000); 872 schedule_timeout((50 * HZ + 999) / 1000);
876 ret = i2c_master_send(&tx->c_tx, buf, 1);