From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3632C10F0E for ; Thu, 18 Apr 2019 18:24:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7ADA720643 for ; Thu, 18 Apr 2019 18:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611860; bh=jSYeYiJF80OkDt6g1mNOb+1uxoJuiUKAeMBEwfUL/6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MYmPOWpKI/7QzuH2kjzjRpAIYSP4zNcdLdtKdlAt9l3/GckW5Ecg6/GaCaRyP9JEp l06x1J7r0ZS+z0NtDrTYrCWcwWXUruZwkFbxP5bhs+1RCi7hv5ahEthtD2qM3orlLV wMki7LkEIhfi1MnuiIAlgH4oCpJe9jIiXFqh9cfg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391538AbfDRSYT (ORCPT ); Thu, 18 Apr 2019 14:24:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:35440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390979AbfDRSFy (ORCPT ); Thu, 18 Apr 2019 14:05:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 690BD206B6; Thu, 18 Apr 2019 18:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610753; bh=jSYeYiJF80OkDt6g1mNOb+1uxoJuiUKAeMBEwfUL/6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PavaQN7IiOAsZMvgFdaorhRd6DfCNhff07n+DArN/BNEll7OSVVC+NA/Yt+AwNBdl KqAuSCPEr2yfNpccB6pmgdWY23aD1wm0YejMSnERoht0H15eaQb8zU+IjU2qE56Hns r6To8qEEb8pwcxiZoqCwdwuWl+i3WewZdfLTwGzM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Jarzmik , Nicolas Chauvet , Linus Walleij , Sasha Levin Subject: [PATCH 4.14 38/92] gpio: pxa: handle corner case of unprobed device Date: Thu, 18 Apr 2019 19:56:56 +0200 Message-Id: <20190418160433.634630112@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160430.325165109@linuxfoundation.org> References: <20190418160430.325165109@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 9ce3ebe973bf4073426f35f282c6b955ed802765 ] 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 Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- 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 2943dfc4c470..822ad220f0af 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.19.1