From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757921Ab1KPOjJ (ORCPT ); Wed, 16 Nov 2011 09:39:09 -0500 Received: from na3sys009aog107.obsmtp.com ([74.125.149.197]:36515 "EHLO na3sys009aog107.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757848Ab1KPOjH (ORCPT ); Wed, 16 Nov 2011 09:39:07 -0500 Date: Wed, 16 Nov 2011 15:39:00 +0100 From: Patrick Combes To: Russell King - ARM Linux Cc: Mark Brown , grant.likely@secretlab.ca, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Hugo Dupras Subject: Re: [RFC][PATCH] gpiolib: add irq_wake (power-management) sysfs file Message-ID: <20111116143857.GB5847@una0919255> References: <1321004406-15663-1-git-send-email-p-combes@ti.com> <20111115131636.GA31028@sirena.org.uk> <20111115172053.GB9581@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111115172053.GB9581@n2100.arm.linux.org.uk> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 15, 2011 at 05:20:53PM +0000, Russell King - ARM Linux wrote: > On Tue, Nov 15, 2011 at 01:16:37PM +0000, Mark Brown wrote: > > On Fri, Nov 11, 2011 at 10:40:06AM +0100, Patrick Combes wrote: > > > + else if (sysfs_streq(buf, "enable") || sysfs_streq(buf, "1")) > > > + status = enable_irq_wake(gpio_to_irq(gpio)); > > > + else if (sysfs_streq(buf, "disable") || sysfs_streq(buf, "0")) > > > + status = disable_irq_wake(gpio_to_irq(gpio)); > > > + else > > > + status = -EINVAL; > > > > ...this doesn't do anything to stop userspace doing multiple enables and > > disables. > > It doesn't check whether gpio_to_irq(gpio) returns something sane either. > It should be doing something like this before taking the mutex: > > irq = gpio_to_irq(gpio); > if (irq <= 0) > return irq < 0 ? irq : -EINVAL; > > and then doing (enable|disable)_irq_wake() on irq. Ok I add this check