From patchwork Wed Mar 26 21:08:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 3895331 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 89EA5BF540 for ; Wed, 26 Mar 2014 21:11:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C20F52021C for ; Wed, 26 Mar 2014 21:11:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E32EF201FD for ; Wed, 26 Mar 2014 21:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755880AbaCZVLB (ORCPT ); Wed, 26 Mar 2014 17:11:01 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:55179 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755829AbaCZVLA (ORCPT ); Wed, 26 Mar 2014 17:11:00 -0400 Received: by mail-wi0-f173.google.com with SMTP id f8so5188807wiw.0 for ; Wed, 26 Mar 2014 14:10:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; bh=7Ru9EqgxhmoieqjqDlhS3fKk96dKNI/pXE8QGT8yI9Q=; b=kb/ZBtM8Jmc0UjSnsR4FprQjoWEUqBDiljtxWOMfioYS4TDySL83Kputcu4DQGCgoQ ZLmEpwMiJRi1dhSxvG8aoxwet2MLElSsv8lMMQK8b5tMwjx13YOzbmf6LI4pyt6NBKAa UMvT0onySbWuOkue4fSH1VTdU/DWxqsYRDkVxCsUGm7SO2l1iHhF8NVniOA+MWbYBMpL 8RQUFlLdFf/N3Y75+AWY1eST5ZYZ0HtPD/fYj7Fm8GxxS1YioeE2sc19ByXAIxU96fRS 6RBgPX+51UeSQE8K8dJynsiyvvvbE69ofFJnq/ekQ7XBhPcpocIookCRo+tJkinjk8fp PI1Q== X-Gm-Message-State: ALoCoQlMruDFFUmJnguXoIDHfH/fTcgJ+aQ8JD80I0DUk7dZhWX4richIHKWbprh0fGmRo7FWx50 X-Received: by 10.180.75.49 with SMTP id z17mr197446wiv.1.1395868259465; Wed, 26 Mar 2014 14:10:59 -0700 (PDT) Received: from localhost.localdomain (jahogan.plus.com. [212.159.75.221]) by mx.google.com with ESMTPSA id h5sm5699905wiy.18.2014.03.26.14.10.57 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2014 14:10:58 -0700 (PDT) From: James Hogan To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, James Hogan , =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= Subject: [PATCH 2/3] rc-main: Limit to a single wakeup protocol group Date: Wed, 26 Mar 2014 21:08:32 +0000 Message-Id: <1395868113-17950-3-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395868113-17950-1-git-send-email-james.hogan@imgtec.com> References: <1395868113-17950-1-git-send-email-james.hogan@imgtec.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Limit the enabled wakeup protocols to be within a protocol group, as defined by the proto_names array. For example this prevents the selection of both rc-5 and nec, while allowing rc-5 alone (which encompasses both normal rc-5 and rc-5x). It doesn't usually make sense to enable more than one wakeup protocol since only a single protocol can usually be used for wakeup at a time, and doing so with encode based wakeup will result in an arbitrary protocol being used if multiple are possible. Reported-by: Antti Seppälä Signed-off-by: James Hogan Cc: Mauro Carvalho Chehab Cc: Antti Seppälä --- Sorry it took a little while to get around to submitting this. --- drivers/media/rc/rc-main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index e067fee..79d1060 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -979,6 +979,19 @@ static ssize_t store_protocols(struct device *device, goto out; } + if (fattr->type == RC_FILTER_WAKEUP) { + /* A proto_names entry must cover enabled wakeup protocols */ + for (i = 0; i < ARRAY_SIZE(proto_names); i++) + if (type & proto_names[i].type && + !(type & ~proto_names[i].type)) + break; + if (i == ARRAY_SIZE(proto_names)) { + IR_dprintk(1, "Multiple distinct wakeup protocols\n"); + ret = -EINVAL; + goto out; + } + } + change_protocol = (fattr->type == RC_FILTER_NORMAL) ? dev->change_protocol : dev->change_wakeup_protocol; if (change_protocol) {