Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3015051pxb; Mon, 18 Oct 2021 06:38:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynsUAmQmjlDBDFvE0RI8G0DYlYQ/ihBYBbFQJA8PJFbkPxgeHOK05D2uOyDJBF86fZqUgK X-Received: by 2002:aa7:983a:0:b0:44d:8bc8:b0ac with SMTP id q26-20020aa7983a000000b0044d8bc8b0acmr23807238pfl.83.1634564318876; Mon, 18 Oct 2021 06:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564318; cv=none; d=google.com; s=arc-20160816; b=d7jYpnFE5Ehu9TCtDZTvM0oWfh4BWN0D7neR124K3/HUg7yc3UnNh9n1LXrw83Q7QI cQt7K3XksOiVigGNKcG4nVD4ngDQTWYysX5ZklJV8rHk34rSDkYeVmB0iCyI7CcB9OS4 BpPIXGxPYyfFPZHwmV9etuuu9/sZjlSIN3GmOSDQl1sKEl3hfSTuMliASmi+oB3Pq2S+ qkSKUuJNuCsx+Jz2ktNpNMqXjuQFGlt+F03V+Er+cT9XyAC7p8yUJZnPJ0JwUItCryTD vHWT62JO2ERPty7dh3c6FJhBnAup2b3C2UZP2pxhc9FmkXOxUJylTh3YPEJxNMcve8h3 i+3g== 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=mSWrWb2+/WinUfnoF9RIVJBALPLZUwMKE3aCUT/yxto=; b=dJcdS0fBnUC9rw80CupakCH79/7s0a1VtBKk0FUeHHbuvry/QnP28wxOgYA+nLhQPa D76/qroq5w6J8pGUffmocLU5j9y0cLl0/w/mqtm4cSBjbIDK/KjzX+Hls+JMddc9UvHn J+Slg6dWwNhhG1J1VIpBisiUXxj3AT/9cO+QSL3uTIioaPY2Dp0MOdOBd/qpUddEqPK6 Lz36XIkDBQOLvpKOv+Z65Sj5DhQpo/OcBt/qZ0jtTgvGpNkUFB/JIlutI1z9BDePhGEK HhB6XUhK5NswM/mtHMoDQJQK+fzHPo3tGhgQDB0CYewADLDj1i77tk1Jqz7KSy9xpyQr fIFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nJBQ0Q83; 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 e25si22667159pgv.106.2021.10.18.06.38.25; Mon, 18 Oct 2021 06:38:38 -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=nJBQ0Q83; 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 S232439AbhJRNjY (ORCPT + 99 others); Mon, 18 Oct 2021 09:39:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:55956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbhJRNgo (ORCPT ); Mon, 18 Oct 2021 09:36:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE9D2613DA; Mon, 18 Oct 2021 13:31:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563872; bh=p0lay8XH4+8x+Vzh4zc8p837cdO7Qn1/dacKp/icL0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nJBQ0Q83ur2mEYoIaPu0ypuEhLKODQPt1dqffS7+z2WI7gxzzXbTVJ7LSHrajBbjh 7zHk3fpKU9PzdPp2Jrk1WrT8K/LNxK8IcTyjwRAGoJOLu0iS1XETcf9urB1Hxsvvic Z5glcDhvefmWdor1QfTcEGm3/y1Ga2/WRs2e+luA= 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.4 46/69] gpio: pca953x: Improve bias setting Date: Mon, 18 Oct 2021 15:24:44 +0200 Message-Id: <20211018132331.005101750@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@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 @@ -583,21 +583,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); @@ -611,7 +611,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;