From patchwork Fri Feb 18 01:12:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Walls X-Patchwork-Id: 572701 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1I1Citt020999 for ; Fri, 18 Feb 2011 01:12:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754485Ab1BRBMm (ORCPT ); Thu, 17 Feb 2011 20:12:42 -0500 Received: from proofpoint-cluster.metrocast.net ([65.175.128.136]:45966 "EHLO proofpoint-cluster.metrocast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753427Ab1BRBMl (ORCPT ); Thu, 17 Feb 2011 20:12:41 -0500 Received: from [192.168.1.2] (d-216-36-28-191.cpe.metrocast.net [216.36.28.191]) (authenticated bits=0) by mango.metrocast.net (8.13.8/8.13.8) with ESMTP id p1I1CcUl015730 for ; Fri, 18 Feb 2011 01:12:39 GMT Subject: [PATCH 01/13] lirc_zilog: Restore checks for existence of the IR_tx object From: Andy Walls To: linux-media@vger.kernel.org In-Reply-To: <1297991502.9399.16.camel@localhost> References: <1297991502.9399.16.camel@localhost> Date: Thu, 17 Feb 2011 20:12:51 -0500 Message-ID: <1297991571.9399.17.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15, 1.0.148, 0.0.0000 definitions=2011-02-18_01:2011-02-17, 2011-02-18, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=5.0.0-1012030000 definitions=main-1102170207 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 18 Feb 2011 01:12:45 +0000 (UTC) diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c index 0aad0d7..7389b77 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) return -ENODATA; } schedule_timeout((100 * HZ + 999) / 1000); - ir->tx->need_boot = 1; + if (ir->tx != NULL) + ir->tx->need_boot = 1; ++failures; mutex_unlock(&ir->ir_lock); @@ -1032,9 +1033,10 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) int result; unsigned long mode, features = 0; - features |= LIRC_CAN_SEND_PULSE; if (ir->rx != NULL) features |= LIRC_CAN_REC_LIRCCODE; + if (ir->tx != NULL) + features |= LIRC_CAN_SEND_PULSE; switch (cmd) { case LIRC_GET_LENGTH: @@ -1061,9 +1063,15 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) result = -EINVAL; break; case LIRC_GET_SEND_MODE: + if (!(features&LIRC_CAN_SEND_MASK)) + return -ENOSYS; + result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg); break; case LIRC_SET_SEND_MODE: + if (!(features&LIRC_CAN_SEND_MASK)) + return -ENOSYS; + result = get_user(mode, (unsigned long *) arg); if (!result && mode != LIRC_MODE_PULSE) return -EINVAL; @@ -1242,8 +1250,10 @@ static int ir_remove(struct i2c_client *client) } /* Good-bye Tx */ - i2c_set_clientdata(ir->tx->c, NULL); - kfree(ir->tx); + if (ir->tx != NULL) { + i2c_set_clientdata(ir->tx->c, NULL); + kfree(ir->tx); + } /* Good-bye IR */ del_ir_device(ir); @@ -1393,9 +1403,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) * after registering with lirc as otherwise hotplug seems to take * 10s to create the lirc device. */ - ret = tx_init(ir->tx); - if (ret != 0) - goto out_unregister; + if (ir->tx != NULL) { + /* Special TX init */ + ret = tx_init(ir->tx); + if (ret != 0) + goto out_unregister; + } zilog_info("probe of IR %s on %s (i2c-%d) done. IR unit ready.\n", tx_probe ? "Tx" : "Rx", adap->name, adap->nr);