From patchwork Mon Jun 28 16:59:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 108406 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5SH0U5N001941 for ; Mon, 28 Jun 2010 17:00:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752588Ab0F1RA2 (ORCPT ); Mon, 28 Jun 2010 13:00:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14706 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811Ab0F1RA0 (ORCPT ); Mon, 28 Jun 2010 13:00:26 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5SH0Qen021350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 28 Jun 2010 13:00:26 -0400 Received: from pedra (vpn-9-119.rdu.redhat.com [10.11.9.119]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5SH0HGL008891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 28 Jun 2010 13:00:25 -0400 Date: Mon, 28 Jun 2010 13:59:58 -0300 From: Mauro Carvalho Chehab Cc: Linux Media Mailing List Subject: [PATCH 3/4] ir-core: Add support for disabling all protocols Message-ID: <20100628135958.3b36a6bf@pedra> In-Reply-To: References: Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 To: unlisted-recipients:; (no To-header on input) 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.3 (demeter.kernel.org [140.211.167.41]); Mon, 28 Jun 2010 17:00:30 +0000 (UTC) diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c index 9a464a3..db8c7f4 100644 --- a/drivers/media/IR/ir-sysfs.c +++ b/drivers/media/IR/ir-sysfs.c @@ -45,6 +45,8 @@ static struct { { IR_TYPE_SONY, "sony" }, }; +#define PROTO_NONE "none" + /** * show_protocols() - shows the current IR protocol(s) * @d: the device descriptor @@ -101,6 +103,7 @@ static ssize_t show_protocols(struct device *d, * Writing "+proto" will add a protocol to the list of enabled protocols. * Writing "-proto" will remove a protocol from the list of enabled protocols. * Writing "proto" will enable only "proto". + * Writing "none" will disable all protocols. * Returns -EINVAL if an invalid protocol combination or unknown protocol name * is used, otherwise @len. */ @@ -134,16 +137,22 @@ static ssize_t store_protocols(struct device *d, disable = false; } - for (i = 0; i < ARRAY_SIZE(proto_names); i++) { - if (!strncasecmp(tmp, proto_names[i].name, strlen(proto_names[i].name))) { - tmp += strlen(proto_names[i].name); - mask = proto_names[i].type; - break; + + if (!enable && !disable && !strncasecmp(tmp, PROTO_NONE, sizeof(PROTO_NONE))) { + mask = 0; + tmp += sizeof(PROTO_NONE); + } else { + for (i = 0; i < ARRAY_SIZE(proto_names); i++) { + if (!strncasecmp(tmp, proto_names[i].name, strlen(proto_names[i].name))) { + tmp += strlen(proto_names[i].name); + mask = proto_names[i].type; + break; + } + } + if (i == ARRAY_SIZE(proto_names)) { + IR_dprintk(1, "Unknown protocol\n"); + return -EINVAL; } - } - if (i == ARRAY_SIZE(proto_names)) { - IR_dprintk(1, "Unknown protocol\n"); - return -EINVAL; } tmp = skip_spaces(tmp);