From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60750503BF3; Wed, 30 Sep 2026 16:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786221; cv=none; b=ILk7hvElpHxlFYh/PVX1KhXsvMvbRA5+mPAo1H729rxbjuHKdUXEK5ncRLNQSdId+ACN7OOC/+UzO0yAnHWdx/NhJlp/N8t9IrqMb6suHZpSstF081JiL61wwSJ54FCgeIDNpYb+DvjU1VsXxoVGgUbMkZeCWGsO4yjdkcPFkvM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786221; c=relaxed/simple; bh=bWQOmxK5FAVpvPR1PEA4Bs87u8HK1ma/MW7GCfS6I0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m0K5aE+U79ISQUYxSe5rPbfDGgJonItaOl8i1eqzAI05yRl7kx4P9OYMWyCtrG4jOwPqxx5gLO7lxnwKuO+aa1fMBw5sMmzwSXxYRH6s/22DU7wsyVaQfF92uFlzuvqgMaAGbboSZujmoJi/soPnHyUVOUhwKxJ3c/q6+id+pV4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ba3xKT6K; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ba3xKT6K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F3F01F000FF; Wed, 30 Sep 2026 16:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786220; bh=MGJzTG3X327ykSGKyUPmU2ME/+xynl9U7mkkEGVuTD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ba3xKT6Kryx5Ul6SGw4co+zU5V0FYX8THetriZIWd1iBQ2GORpoPXjhWe418gtZ7f M/BVqm7GJcrsT5US3OWdY7bAvJRUYQMZXbm9wXkUucnTej6GiEmW3So+auiAtAChQ/ m+/GUsFsyKeFjmHTk6gV3PSl4V5JUyBIDwNUUo2Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Alvin=20=C5=A0ipraga?= , =?UTF-8?q?Nuno=20S=C3=A1?= , Dmitry Torokhov Subject: [PATCH 6.1 739/982] Input: adp5588-keys - cache GPIO state before registering the gpiochip Date: Wed, 30 Sep 2026 17:24:35 +0200 Message-ID: <20260930152432.625613360@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alvin Šipraga commit 21efadc62272cabee9bec27777ae75d84a9ca8a8 upstream. So as not to clobber any pre-programmed GPIO state in the execution of its gpiochip ops, the driver caches things during probe time. However, since those ops can be called both during and immediately after the call to devm_gpiochip_add_data(), it is imperative that things are cached before that. That's not the case right now, so reorder the two steps to prevent any clobbering. In the concrete example which motivated this change, a bootloader was preconfiguring an important GPIO output to HIGH before booting the kernel. Linux would then inadvertently set that output to LOW while configuring a GPIO hog on a discrete GPIO line within the same 8-bit bank (because the cached value was 0=LOW). Fixes: ba9f507a1bea ("Input: adp5588-keys - export unused GPIO pins") Signed-off-by: Alvin Šipraga Reviewed-by: Nuno Sá Link: https://patch.msgid.link/20260818-adp5588-gpio-cache-v1-1-650a2674fc0d@analog.com Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/keyboard/adp5588-keys.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/input/keyboard/adp5588-keys.c +++ b/drivers/input/keyboard/adp5588-keys.c @@ -453,12 +453,6 @@ static int adp5588_gpio_add(struct adp55 mutex_init(&kpad->gpio_lock); - error = devm_gpiochip_add_data(dev, &kpad->gc, kpad); - if (error) { - dev_err(dev, "gpiochip_add failed: %d\n", error); - return error; - } - for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { kpad->dat_out[i] = adp5588_read(kpad->client, GPIO_DAT_OUT1 + i); @@ -466,6 +460,12 @@ static int adp5588_gpio_add(struct adp55 kpad->pull_dis[i] = adp5588_read(kpad->client, GPIO_PULL1 + i); } + error = devm_gpiochip_add_data(dev, &kpad->gc, kpad); + if (error) { + dev_err(dev, "gpiochip_add failed: %d\n", error); + return error; + } + return 0; }