From patchwork Tue May 26 11:34:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 6480721 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 506C4C0020 for ; Tue, 26 May 2015 13:30:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C98D2060E for ; Tue, 26 May 2015 13:30:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 542C1204AF for ; Tue, 26 May 2015 13:30:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753877AbbEZNaZ (ORCPT ); Tue, 26 May 2015 09:30:25 -0400 Received: from winston.telenet-ops.be ([195.130.137.75]:41731 "EHLO winston.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752916AbbEZNaW (ORCPT ); Tue, 26 May 2015 09:30:22 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [195.130.137.88]) by winston.telenet-ops.be (Postfix) with ESMTP id AB8A81BC98C for ; Tue, 26 May 2015 13:34:40 +0200 (CEST) Received: from ayla.of.borg ([84.193.93.87]) by michel.telenet-ops.be with bizsmtp id YbZy1q0091t5w8s06bZynX; Tue, 26 May 2015 13:33:58 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1YxD7O-0008Uk-15; Tue, 26 May 2015 13:33:58 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1YxD7T-0004L9-RF; Tue, 26 May 2015 13:34:03 +0200 From: Geert Uytterhoeven To: Linus Walleij , Alexandre Courbot Cc: linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] gpio: pcf857x: Check for irq_set_irq_wake() failures Date: Tue, 26 May 2015 13:34:02 +0200 Message-Id: <1432640042-16650-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 If an interrupt controller doesn't support wake-up configuration, irq_set_irq_wake() returns an error code. Then any subsequent call trying to deconfigure wake-up will cause an imbalance, and a warning will be printed: WARNING: CPU: 1 PID: 1341 at kernel/irq/manage.c:540 irq_set_irq_wake+0x Unbalanced IRQ 26 wake disable To fix this, refrain from any further parent interrupt controller (de)configuration if irq_set_irq_wake() failed. Signed-off-by: Geert Uytterhoeven --- drivers/gpio/gpio-pcf857x.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index 945f0cda8529d38a..83db0e19ec7e6b49 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c @@ -91,6 +91,7 @@ struct pcf857x { spinlock_t slock; /* protect irq demux */ unsigned out; /* software latch */ unsigned status; /* current status */ + unsigned int irq_parent; int (*write)(struct i2c_client *client, unsigned data); int (*read)(struct i2c_client *client); @@ -217,9 +218,19 @@ static unsigned int noop_ret(struct irq_data *data) static int pcf857x_irq_set_wake(struct irq_data *data, unsigned int on) { struct pcf857x *gpio = irq_data_get_irq_chip_data(data); + int error = 0; + + if (gpio->irq_parent) { + error = irq_set_irq_wake(gpio->irq_parent, on); + if (error) { + dev_dbg(&gpio->client->dev, + "irq %u doesn't support irq_set_wake\n", + gpio->irq_parent); + gpio->irq_parent = 0; + } + } - irq_set_irq_wake(gpio->client->irq, on); - return 0; + return error; } static struct irq_chip pcf857x_irq_chip = { @@ -364,6 +375,7 @@ static int pcf857x_probe(struct i2c_client *client, gpiochip_set_chained_irqchip(&gpio->chip, &pcf857x_irq_chip, client->irq, NULL); + gpio->irq_parent = client->irq; } /* Let platform code set up the GPIOs and their users.