aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndy Walls <awalls@md.metrocast.net>2011-01-26 19:06:43 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-22 18:23:49 -0400
commit12d896e1c17978599a98510fdfaff27a4e82c0bf (patch)
treef66be96087a4cf1629737aca80567570ddefaa80 /drivers
parentb443ac5a2836532af2315a4acb95c7a2cf721cbd (diff)
[media] lirc_zilog: Restore checks for existence of the IR_tx object
This reverts commit 8090232a237ab62e22307fc060097da1a283dd66 and adds an additional check for ir->tx == NULL. The user may need us to handle an RX only unit. Apparently there are TV capture units in existence with Rx only wiring and/or RX only firmware for the on-board Zilog Z8 IR unit. Signed-off-by: Andy Walls <awalls@md.metrocast.net> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/lirc/lirc_zilog.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
index 0aad0d7a74a3..7389b77ece8c 100644
--- a/drivers/staging/lirc/lirc_zilog.c
+++ b/drivers/staging/lirc/lirc_zilog.c
@@ -209,7 +209,8 @@ static int add_to_buf(struct IR *ir)
209 return -ENODATA; 209 return -ENODATA;
210 } 210 }
211 schedule_timeout((100 * HZ + 999) / 1000); 211 schedule_timeout((100 * HZ + 999) / 1000);
212 ir->tx->need_boot = 1; 212 if (ir->tx != NULL)
213 ir->tx->need_boot = 1;
213 214
214 ++failures; 215 ++failures;
215 mutex_unlock(&ir->ir_lock); 216 mutex_unlock(&ir->ir_lock);
@@ -1032,9 +1033,10 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
1032 int result; 1033 int result;
1033 unsigned long mode, features = 0; 1034 unsigned long mode, features = 0;
1034 1035
1035 features |= LIRC_CAN_SEND_PULSE;
1036 if (ir->rx != NULL) 1036 if (ir->rx != NULL)
1037 features |= LIRC_CAN_REC_LIRCCODE; 1037 features |= LIRC_CAN_REC_LIRCCODE;
1038 if (ir->tx != NULL)
1039 features |= LIRC_CAN_SEND_PULSE;
1038 1040
1039 switch (cmd) { 1041 switch (cmd) {
1040 case LIRC_GET_LENGTH: 1042 case LIRC_GET_LENGTH:
@@ -1061,9 +1063,15 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
1061 result = -EINVAL; 1063 result = -EINVAL;
1062 break; 1064 break;
1063 case LIRC_GET_SEND_MODE: 1065 case LIRC_GET_SEND_MODE:
1066 if (!(features&LIRC_CAN_SEND_MASK))
1067 return -ENOSYS;
1068
1064 result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg); 1069 result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg);
1065 break; 1070 break;
1066 case LIRC_SET_SEND_MODE: 1071 case LIRC_SET_SEND_MODE:
1072 if (!(features&LIRC_CAN_SEND_MASK))
1073 return -ENOSYS;
1074
1067 result = get_user(mode, (unsigned long *) arg); 1075 result = get_user(mode, (unsigned long *) arg);
1068 if (!result && mode != LIRC_MODE_PULSE) 1076 if (!result && mode != LIRC_MODE_PULSE)
1069 return -EINVAL; 1077 return -EINVAL;
@@ -1242,8 +1250,10 @@ static int ir_remove(struct i2c_client *client)
1242 } 1250 }
1243 1251
1244 /* Good-bye Tx */ 1252 /* Good-bye Tx */
1245 i2c_set_clientdata(ir->tx->c, NULL); 1253 if (ir->tx != NULL) {
1246 kfree(ir->tx); 1254 i2c_set_clientdata(ir->tx->c, NULL);
1255 kfree(ir->tx);
1256 }
1247 1257
1248 /* Good-bye IR */ 1258 /* Good-bye IR */
1249 del_ir_device(ir); 1259 del_ir_device(ir);
@@ -1393,9 +1403,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
1393 * after registering with lirc as otherwise hotplug seems to take 1403 * after registering with lirc as otherwise hotplug seems to take
1394 * 10s to create the lirc device. 1404 * 10s to create the lirc device.
1395 */ 1405 */
1396 ret = tx_init(ir->tx); 1406 if (ir->tx != NULL) {
1397 if (ret != 0) 1407 /* Special TX init */
1398 goto out_unregister; 1408 ret = tx_init(ir->tx);
1409 if (ret != 0)
1410 goto out_unregister;
1411 }
1399 1412
1400 zilog_info("probe of IR %s on %s (i2c-%d) done. IR unit ready.\n", 1413 zilog_info("probe of IR %s on %s (i2c-%d) done. IR unit ready.\n",
1401 tx_probe ? "Tx" : "Rx", adap->name, adap->nr); 1414 tx_probe ? "Tx" : "Rx", adap->name, adap->nr);