Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2079843ybb; Fri, 29 Mar 2019 18:31:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7SKPdEokrgZnQL4RgHkRdRp1JEjMm42nHJbpBdaSXc3T8a1E2sPh4G92SVjfzYtb/fHFK X-Received: by 2002:a62:6c43:: with SMTP id h64mr50398586pfc.123.1553909465184; Fri, 29 Mar 2019 18:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553909465; cv=none; d=google.com; s=arc-20160816; b=tuJm8tZs62VchHTZ7cP71rY7Lxf295tuSB8D6oUhNzYkzzn7VITdLMDg+BXzUVemUf x/WFDPIyOCDLdQmaW9t/3p7YUu0z6tS9xba5nXVcovgxPeywFz5D3s7+rGQiBmEYumQP IEYpHZAmajRUi0KATunj157MJM5btItmvk5W5dHsigBNbrlv9vn3HrbeAk/hG8ggc7Or EvMP43fi7YOypIeMp4KDqhNznudd749vgyU4B7KZwePbbY946He20nuiYSgCarzBE55C g4vcxy0q1JjZ6bZuRXYIpw1EMzf/r4+UOkYIVHLyJr5I91cDp4ZB5WCyubXTgQEAR8hB RIug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l40oUQ/9vgV90ZKJIrxqls8lZ+5FfGPpROPXqMSrZr8=; b=dzWZ0jSf0q41NQZ+cxkkiPrtmivGct6b9/xB67GGoekmwkBDhvjiB5DYL7TqevdwEJ 3dd8h+8+AmaNuZDH9dGOS7Yef/oLZMC/aeV1WH013CCzsYjQB1+a3CaEI+tGxArJcWPp JEje8fzRveKGNCiYj3tR+kMpbRlKMtBxzIJ5lxaTs7S0zx+7FrYN3try9hKMf/DvslQc Wi1v2t/40G/W7B5cIk0pg6QnPAdKobt2bXCF5xc2cyqNvLur5B4dSg89bQOxYqzRmEkN M3Uxs8UKn5Evh/m/m8is+98J45YPCTXfhDhb8HQLWLvxsw0ggiFcpyYz/ACC+nukoux5 p+Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xsGywjR2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si3046732pfn.229.2019.03.29.18.30.50; Fri, 29 Mar 2019 18:31:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=xsGywjR2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730674AbfC3B27 (ORCPT + 99 others); Fri, 29 Mar 2019 21:28:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:35650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730500AbfC3B26 (ORCPT ); Fri, 29 Mar 2019 21:28:58 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6264D2184C; Sat, 30 Mar 2019 01:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909337; bh=hH1uzSL2wUAqDKa5Db1ZaxJpggmglsG5piYbWiLYvOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xsGywjR2WCMv8OYX23Mmo/bcibbJmdlw74DPSV5EwULq0eNVwAnQcdUzktZSM1d/C LyoqwoLcxzL65n23B2GZkT0kKYOtKFU7czt3fPbuCgb9RbHwO/gzGQONKJhpqtBr8O A7+R5ZSyO+qwyaoEYwF6XR0FVIaY/x6ICrn1ugLA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Robert Jarzmik , Linus Walleij , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 02/57] gpio: pxa: handle corner case of unprobed device Date: Fri, 29 Mar 2019 21:27:55 -0400 Message-Id: <20190330012854.32212-2-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330012854.32212-1-sashal@kernel.org> References: <20190330012854.32212-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Jarzmik [ 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 eb27fa76e8fc..bcc6be4a5cb2 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -777,6 +777,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); @@ -795,6 +798,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