From patchwork Sun Jul 10 16:34:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 9222703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0BB260572 for ; Sun, 10 Jul 2016 16:34:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A85C223B3C for ; Sun, 10 Jul 2016 16:34:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A8652621E; Sun, 10 Jul 2016 16:34:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1602A23B3C for ; Sun, 10 Jul 2016 16:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933462AbcGJQej (ORCPT ); Sun, 10 Jul 2016 12:34:39 -0400 Received: from gofer.mess.org ([80.229.237.210]:35657 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933292AbcGJQeg (ORCPT ); Sun, 10 Jul 2016 12:34:36 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 9421C62138; Sun, 10 Jul 2016 17:34:33 +0100 (BST) From: Sean Young To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Subject: [PATCH 1/5] [media] rc: make s_tx_mask consistent Date: Sun, 10 Jul 2016 17:34:32 +0100 Message-Id: <1468168473-27499-2-git-send-email-sean@mess.org> X-Mailer: git-send-email 2.1.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When s_tx_mask is given an invalid bitmask, the number of transmitters should be returned. See the LIRC_SET_TRANSMITTER_MASK lirc ioctl documentation. Signed-off-by: Sean Young --- drivers/media/rc/mceusb.c | 6 ++++++ drivers/media/rc/winbond-cir.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index 35155ae..0d1da2c 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -881,6 +881,12 @@ static int mceusb_set_tx_mask(struct rc_dev *dev, u32 mask) { struct mceusb_dev *ir = dev->priv; + /* return number of transmitters */ + int emitters = ir->num_txports ? ir->num_txports : 2; + + if (mask >= (1 << emitters)) + return emitters; + if (ir->flags.tx_mask_normal) ir->tx_mask = mask; else diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index d839f73..95ae60e 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c @@ -615,6 +615,10 @@ wbcir_txmask(struct rc_dev *dev, u32 mask) unsigned long flags; u8 val; + /* return the number of transmitters */ + if (mask > 15) + return 4; + /* Four outputs, only one output can be enabled at a time */ switch (mask) { case 0x1: