From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD9B41DF74A; Tue, 8 Oct 2024 13:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728393955; cv=none; b=Uw2bjOO0wMsghprSRBX4Dxxb6fsir+kkGFQLDtu6Uu3oQ76RAAt93bRT07/xjlKSa+ngGWyuxvaMj4y3LEW/l4eC2nMFMN0q6TlsVpYJ/3ktwUiUjWY7npPLimgrUmDRauTrOplwLrhedvJk0sghoJ1osvUTsGHQw3idIdiRroY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728393955; c=relaxed/simple; bh=25faNqIoSk+uWA3aun5N2FoqGqSibm+5cF4IeExAz8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PkCCqPdXL0zW6GiFF8UOBrY9t2f8sRuNbB25LhP9mflcUMmg4KXtOPL5cE2CGbsX7oKKbYrGGW5r6QVhBsli8GGuvoC+g9rJ8dURnsoPjykSgC7u9v6h5qbLJ1uO2sjVhxjqL0EHXNitLVa3ntl+kMYPWOpuRre6KDHc23dj3Do= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lFtevrUn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lFtevrUn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D06A0C4CECD; Tue, 8 Oct 2024 13:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728393954; bh=25faNqIoSk+uWA3aun5N2FoqGqSibm+5cF4IeExAz8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lFtevrUnl9QapNmU4zEeYfvxEmctbPfU+pb6Sod7svBWBiRqSTIZTvI4ZyCZ8I4Rb 8EY9y/i+nWBn1FEyzKhZ2JVN+z7hNNZ9jx+ppn+GHw+rMzxb2o1audSTsoZ90Pgq6j rEn+QG8cLo8NrxCncV4U6MtMAJQTCo6iGzrUm+Cw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nuno Sa , Dmitry Torokhov Subject: [PATCH 6.6 304/386] Input: adp5589-keys - fix adp5589_gpio_get_value() Date: Tue, 8 Oct 2024 14:09:09 +0200 Message-ID: <20241008115641.349413623@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115629.309157387@linuxfoundation.org> References: <20241008115629.309157387@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nuno Sa commit c684771630e64bc39bddffeb65dd8a6612a6b249 upstream. The adp5589 seems to have the same behavior as similar devices as explained in commit 910a9f5636f5 ("Input: adp5588-keys - get value from data out when dir is out"). Basically, when the gpio is set as output we need to get the value from ADP5589_GPO_DATA_OUT_A register instead of ADP5589_GPI_STATUS_A. Fixes: 9d2e173644bb ("Input: ADP5589 - new driver for I2C Keypad Decoder and I/O Expander") Signed-off-by: Nuno Sa Link: https://lore.kernel.org/r/20241001-b4-dev-adp5589-fw-conversion-v1-2-fca0149dfc47@analog.com Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/keyboard/adp5589-keys.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c @@ -391,10 +391,17 @@ static int adp5589_gpio_get_value(struct struct adp5589_kpad *kpad = gpiochip_get_data(chip); unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); + int val; - return !!(adp5589_read(kpad->client, - kpad->var->reg(ADP5589_GPI_STATUS_A) + bank) & - bit); + mutex_lock(&kpad->gpio_lock); + if (kpad->dir[bank] & bit) + val = kpad->dat_out[bank]; + else + val = adp5589_read(kpad->client, + kpad->var->reg(ADP5589_GPI_STATUS_A) + bank); + mutex_unlock(&kpad->gpio_lock); + + return !!(val & bit); } static void adp5589_gpio_set_value(struct gpio_chip *chip,