From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Walleij Subject: Re: [PATCH 1/1] drivers/gpio: Altera soft IP GPIO driver Date: Fri, 16 Aug 2013 15:12:16 +0200 Message-ID: References: <1373267079-15843-1-git-send-email-thloh@altera.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: In-Reply-To: Sender: linux-doc-owner@vger.kernel.org To: Loh Tien Hock Cc: Tien Hock Loh , "devicetree@vger.kernel.org" , Rob Herring , Rob Landley , "linux-doc@vger.kernel.org" , "devicetree-discuss@lists.ozlabs.org" List-Id: devicetree@vger.kernel.org On Mon, Jul 29, 2013 at 6:24 PM, Loh Tien Hock wrote: > On Tue, Jul 30, 2013 at 12:11 AM, Linus Walleij >>>>> +static int altera_gpio_irq_set_type(struct irq_data *d, >>>>> + unsigned int type) >>>>> +{ >>>>> + struct altera_gpio_chip *altera_gc = irq_data_get_irq_chip_data(d); >>>>> + >>>>> + if (type == IRQ_TYPE_NONE) >>>>> + return 0; >>>>> + >>>>> + if (altera_gc->level_trigger) { >>>>> + if (type == IRQ_TYPE_LEVEL_HIGH) >>>>> + return 0; >>>>> + } else { >>>>> + if (type == IRQ_TYPE_EDGE_RISING && >>>>> + altera_gc->edge_type == ALTERA_IRQ_RISING) >>>>> + return 0; >>>>> + else if (type == IRQ_TYPE_EDGE_FALLING && >>>>> + altera_gc->edge_type == ALTERA_IRQ_FALLING) >>>>> + return 0; >>>>> + else if (type == IRQ_TYPE_EDGE_BOTH && >>>>> + altera_gc->edge_type == ALTERA_IRQ_BOTH) >>>>> + return 0; >>>> >>>> I don't quite realize why you need the local version of >>>> the IRQflag at all. Just store the standard edge indicator >>>> in an unsigned long? >>> >>> I don't understand the comment. Can you elaborate further? >> >> I misunderstood it for the above reason. But get rid of the >> custom ALTERA_IRQ_* defines and just use the standard >> definitions for IRQ_TYPE_*, the local defines does not add >> anything useful. > > We still need to compare the altera_gc->edge_type to the expected ones > (so that we don't allow incorrect configuration, eg. the GPIO is > configured as rising, but set_type tries to set falling). > So we should compare it with magic numbers, instead of custom defines > like the example below? > if (type == IRQ_TYPE_EDGE_RISING && > altera_gc->edge_type == 0) > return 0; And why can't altera_gc->edge_type use exactly the same enumerators so it becomes: (type == IRQ_TYPE_EDGE_RISING && altera_gc->edge_type == IRQ_TYPE_EDGE_RISING) ? Yours, Linus Walleij