From patchwork Tue Sep 23 13:37:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yalin" X-Patchwork-Id: 392514 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EDC3A1400B5 for ; Tue, 23 Sep 2014 23:38:04 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753898AbaIWNiE (ORCPT ); Tue, 23 Sep 2014 09:38:04 -0400 Received: from cnbjrel01.sonyericsson.com ([219.141.167.165]:19702 "EHLO cnbjrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883AbaIWNiD convert rfc822-to-8bit (ORCPT ); Tue, 23 Sep 2014 09:38:03 -0400 From: "Wang, Yalin" To: Grygorii Strashko , Linus Walleij CC: "gnurou@gmail.com" , "linux-gpio@vger.kernel.org" , "akpm@linux-foundation.org" Date: Tue, 23 Sep 2014 21:37:58 +0800 Subject: RE: [PATCH] gpiolib:change to use irq_alloc_descs_from to alloc virqs Thread-Topic: [PATCH] gpiolib:change to use irq_alloc_descs_from to alloc virqs Thread-Index: Ac/XLjdtlu5JR3HRS5uaFgH3il78pwAA3ku7 Message-ID: <35FD53F367049845BC99AC72306C23D103D6DB4D6F2A@CNBJMBX05.corpusers.net> References: <35FD53F367049845BC99AC72306C23D103CDBFBFB017@CNBJMBX05.corpusers.net>, <35FD53F367049845BC99AC72306C23D103D6DB4D6F29@CNBJMBX05.corpusers.net>, <54216EA5.5010506@ti.com> In-Reply-To: <54216EA5.5010506@ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Hi In fact, i don't encounter any problem about gpio code, i just find this issue when i see the source code, i feel it is not safe, so i make a patch for it. yes, you are right, "irq_base" is used only twice in gpiolib code, but it maybe used by some other drivers, if remove it, some drivers will can't get virq base. it should get it by find_irq_mapping(), but it is also ok. in fact , we can allow the virq are allocated one by one, but this need change gpiochip_irqchip_remove( ) function, it should not assume the virq are contentious, i think both method are ok , it is just decided by how you want design it :) To summarize, we should make gpiochip_irqchip_add() and gpiochip_irqchip_remove() both work correctly. diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 15cc0bb..81762ed 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -524,7 +524,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) /* Remove all IRQ mappings and delete the domain */ if (gpiochip->irqdomain) { for (offset = 0; offset < gpiochip->ngpio; offset++) - irq_dispose_mapping(gpiochip->irq_base + offset); + irq_dispose_mapping(irq_find_mapping(gpiochip->irqdomain, offset)); irq_domain_remove(gpiochip->irqdomain); }