Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3749938imm; Sat, 25 Aug 2018 01:49:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ06LCuewpQokkbYdygZxno/Mgie4e0R1khIstCK7deBM8afCGOObGf9jpcRs4D+mia5HjM X-Received: by 2002:a65:4147:: with SMTP id x7-v6mr4903773pgp.220.1535186975688; Sat, 25 Aug 2018 01:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535186975; cv=none; d=google.com; s=arc-20160816; b=LYbpP+CzwWeoTPjfG+KFsTl0NuvJInkSt3s1HZCPU4h7nUO/Jn3WWRhe1zpf+hhDlT xYl2zKMZGAyIbcB7PW7g8NsSCz2LJagdAjBK+BvJBqpzgMcgH7dJcsCnwg9sROa2Vi6I GNoQaZugvNYNFwyuQGvwC/wFJVfABN4p9S5CB6tIAxw9k2aqS9m7BmF39bzdAxF2ajMf uhJbyjkw4YlMEzLe2H3/HwaWQb1i+JCkyuak8TqKow50JjomVR034WyGBSaLqbSOlGJJ CwIFxdQFtY0LBcIYbhGrHgJyNW3iYX01tsqV58dRWAPSHPj9e7SYnb5z9DSzXeN5VYA0 7w3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pn9WizxBylyssXZAHBego1g21CVPMzvkvE6+b2qOc3g=; b=qm5NnYmLwScoPFXpGK1Gys1NMdm9AGhv30/Zt3PAkpH0sLD6PZwjMvUTzvntqIEWQe TMRtec9326c7yliq2jaItYBct7rbSwi4grfXejDAXX6OmV0BHgN5FEc7CZbRJTIuguYA 1Ck3M5795RpZA46tgS+O2J/XU2KTlM/umT1QB1i5Ld+Nk/SiFY/r+ug4w4v5at2wzQrg GrnIXiMWr6VLCWdeJp8RtTNUxR0K0OwVY5QynVkdIH/PUE9mvi3TJZm57QVlMTGeNr9s +tjp17L2IbPGoNuDv0K38brTHoJKFelfrWP8/xS7Fy7HrNSDhOCFXwGA6OAbI+LzeZWv 1BSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10-v6si7772301plt.136.2018.08.25.01.48.57; Sat, 25 Aug 2018 01:49:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726872AbeHYMWs (ORCPT + 99 others); Sat, 25 Aug 2018 08:22:48 -0400 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:47501 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbeHYMWs (ORCPT ); Sat, 25 Aug 2018 08:22:48 -0400 Received: from belgarion.home ([90.89.234.36]) by mwinf5d41 with ME id TLkR1y00h0nnJME03LkXDn; Sat, 25 Aug 2018 10:44:31 +0200 X-ME-Helo: belgarion.home X-ME-Auth: amFyem1pay5yb2JlcnRAb3JhbmdlLmZy X-ME-Date: Sat, 25 Aug 2018 10:44:31 +0200 X-ME-IP: 90.89.234.36 From: Robert Jarzmik To: Robert Jarzmik , Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: pxa: handle corner case of unprobed device Date: Sat, 25 Aug 2018 10:44:17 +0200 Message-Id: <20180825084417.13526-1-robert.jarzmik@free.fr> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the corner case where the gpio driver probe fails, for whatever reason, the suspend and resume handlers will still be called as they have to be registered as syscore operations. This applies as well when no probe was called while the driver has been built in the kernel. Nicolas tracked this in : https://bugzilla.kernel.org/show_bug.cgi?id=200905 Therefore, add a failsafe in these function, and test if a proper probe succeeded and the driver is functional. Signed-off-by: Robert Jarzmik Reported-by: Nicolas Chauvet --- drivers/gpio/gpio-pxa.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index c18712dabf93..bfe4c5c9f41c 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -776,6 +776,9 @@ static int pxa_gpio_suspend(void) struct pxa_gpio_bank *c; int gpio; + if (!pchip) + return 0; + for_each_gpio_bank(gpio, c, pchip) { c->saved_gplr = readl_relaxed(c->regbase + GPLR_OFFSET); c->saved_gpdr = readl_relaxed(c->regbase + GPDR_OFFSET); @@ -794,6 +797,9 @@ static void pxa_gpio_resume(void) struct pxa_gpio_bank *c; int gpio; + if (!pchip) + return; + for_each_gpio_bank(gpio, c, pchip) { /* restore level with set/clear */ writel_relaxed(c->saved_gplr, c->regbase + GPSR_OFFSET); -- 2.11.0