Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3036189pxb; Mon, 18 Oct 2021 07:03:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV1Jh/aZ+4an/P05jyaKfWNL8btySpcDFMEguoKZeciuEXujd9uG5OZGe+x8z/DZoiQh5I X-Received: by 2002:a05:6402:27d2:: with SMTP id c18mr45276378ede.186.1634565827359; Mon, 18 Oct 2021 07:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565827; cv=none; d=google.com; s=arc-20160816; b=lIpCajDpIxH+Ebb25c8c8nWJ3b4JbZ4FsO+lwXq3eEkTCtzQqLOPGqKmrHggcF6cB9 +RHAj2jhF6+fMk8M2qoDucH9k0k73ckjzVfGlAyxtDk0t4yvMECMwm988f1NbalyPaKI phg8o+FxJW4viy6hg+VNj2y9wQFYe8v8cztra00/ybrvzqPc9slOlSdBs4r8DCiHO34y KniOto20f4Of3JIMVy/Jc5Uqs/ucFXkW4hot6JdAqhPCAA3rlZM2m4J1BVR/p6AFnSbo ZNxqG59QM62ZPUcI7GZWhidPhncctq3KIsMVFKKXYd3uoR/9U3U/dn4gSnMLumh/Lf0i Xr+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zzme4mmwHjW/E5FyKOSvVyDxXCdZhW3os9bKfWbHhak=; b=Spd/i4tNNyNGf6KeGNb1ROUb2k3zscjNfEo7fzbAZRMhRHrwdLDYRGY1iYfY9Q6R/W 18VMc0l3rquneTbidfUZspo2AGhYCcAiqkb7mGJ64zYuiMtlSBJk7GyVH/ZBtJqCThfQ k9jRxee/SZYxHjIvp31O12qaL2Bg2UXaA5X9fTF+bQUaFaUiTesBSyKqIfxd6TbyDPm1 oGkTLY+1W41Lnc5zlE7OZ6TM+33FwAcS7nA/4TTBdPfM1kKgS+GxCEwK6wxSMAWGhuUZ I74xdq+duyyhQGXoJ3VwGjtl/ee9FnoUihTvCTqQVMkA1J/2awtYtA7iIC8SD4MaZdYU U8CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qivfKoQh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si31965427eda.575.2021.10.18.07.03.22; Mon, 18 Oct 2021 07:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qivfKoQh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233902AbhJROAE (ORCPT + 99 others); Mon, 18 Oct 2021 10:00:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:58186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234322AbhJRN54 (ORCPT ); Mon, 18 Oct 2021 09:57:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9411061A3F; Mon, 18 Oct 2021 13:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564471; bh=eHYOWKrClaFyIu88IKMatWBTTPoSX2145ljr+K/yZ+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qivfKoQhqoFNUjD2YZwO5lG4xp6vMoBwuRu2k3fnRqFSOO2k/LPYRZFjFR2DsECtg uhbZTleNeO0EOwOyKP3VlM9cCjql070GFJuIM0DV+fFguGsXlK+D0FPAyQ8JjKBM1I DSsGtIZudgKMmeznYUvHIdoyi3YmI+dQtInSDVZE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Petazzoni , Andy Shevchenko , Bartosz Golaszewski Subject: [PATCH 5.14 100/151] gpio: pca953x: Improve bias setting Date: Mon, 18 Oct 2021 15:24:39 +0200 Message-Id: <20211018132343.925150241@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko commit 55a9968c7e139209a9e93d4ca4321731bea5fc95 upstream. The commit 15add06841a3 ("gpio: pca953x: add ->set_config implementation") introduced support for bias setting. However this, due to being half-baked, brought potential issues: - the turning bias via disabling makes the pin floating for a while; - once enabled, bias can't be disabled. Fix all these by adding support for bias disabling and move the disabling part under the corresponding conditional. While at it, add support for default setting, since it's cheap to add. Fixes: 15add06841a3 ("gpio: pca953x: add ->set_config implementation") Cc: Thomas Petazzoni Signed-off-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-pca953x.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -559,21 +559,21 @@ static int pca953x_gpio_set_pull_up_down mutex_lock(&chip->i2c_lock); - /* Disable pull-up/pull-down */ - ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, 0); - if (ret) - goto exit; - /* Configure pull-up/pull-down */ if (config == PIN_CONFIG_BIAS_PULL_UP) ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, bit); else if (config == PIN_CONFIG_BIAS_PULL_DOWN) ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, 0); + else + ret = 0; if (ret) goto exit; - /* Enable pull-up/pull-down */ - ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, bit); + /* Disable/Enable pull-up/pull-down */ + if (config == PIN_CONFIG_BIAS_DISABLE) + ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, 0); + else + ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, bit); exit: mutex_unlock(&chip->i2c_lock); @@ -587,7 +587,9 @@ static int pca953x_gpio_set_config(struc switch (pinconf_to_config_param(config)) { case PIN_CONFIG_BIAS_PULL_UP: + case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: case PIN_CONFIG_BIAS_PULL_DOWN: + case PIN_CONFIG_BIAS_DISABLE: return pca953x_gpio_set_pull_up_down(chip, offset, config); default: return -ENOTSUPP;