Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3021011pxb; Mon, 18 Oct 2021 06:45:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNgw1WmbI3dXHMOzqvluCaPI/YjAKvEWWT8UYf9zNNTbhIuC0E6MCZHUhQlPDPQkZAfcqW X-Received: by 2002:a17:90a:7e90:: with SMTP id j16mr33473078pjl.139.1634564746152; Mon, 18 Oct 2021 06:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564746; cv=none; d=google.com; s=arc-20160816; b=ZbnhaAenanBU2qGPRny0J2ZWxKivY5ZzfJTZvpZdgujS/R5w3f/m6N1krBrWEAP6CE wKs0bqA5Uj9auRZ2hnfRwSoT55W40HsUQOkiIJ6cZwn8oCqHC11KbsYZGiNvQium9CyL sav2NYmF7Xb1j3vpwyIzMFCNDK27AbEI7Kty9tSvSgKpJen6g+8G7VMmynjvEvpeBlfT NVG2bUBv19IFo0HvS9E/vSlnFHek9UtxXga6lzsYc7u93QSq56I++kUQPV3EpelLpwnP w8yxZM7DWuvsl0x35sv6eW53jX7Lf0pqV2cUWuYMkuo+EbJaDZfwLSprTM4Iu40pZ4wf 2WAA== 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=iYEEXAB1GsVgMNXLd9FolmbcCKkHpaqgPJVVC+XBMPg=; b=VZRgAoSSpM0rWVIceNm/rk7190D4Gz9Z1aTjXwvWplma4RTuNp+NkSYwmPRpXPifRS ir6uNuhA2x2RSGy2TIrtQjYRZtZt1jIhZ1GaSz0k3Nd6FIuo+IVnHprhExanZgaLGxlJ JeplMnSl2rOqUzw4GfhaRajwUZQ6keZq7NOhal9uJbRPp6Zs9Ndqx6H0oMQ4cpjM47o1 6M6pEwKpm5aoc+/hTDzh92ugvHSPbErdYDP92Oz6/0tIKTv3tdfmxYDrq9pLt+MVLijN ezzVxHIn6jX/HFJL/vcg4KPnEeZC72Dn7Tbmfb+8SDXvV3x6HKFisVUREyOAMnS3t5D/ MIuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MFNh2ZTf; 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 g1si20581398pjl.47.2021.10.18.06.45.31; Mon, 18 Oct 2021 06:45:46 -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=MFNh2ZTf; 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 S233062AbhJRNqo (ORCPT + 99 others); Mon, 18 Oct 2021 09:46:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233362AbhJRNoS (ORCPT ); Mon, 18 Oct 2021 09:44:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76E0861555; Mon, 18 Oct 2021 13:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564112; bh=EaJiCsQkskJy9Eb1jN+tXdmqh+FPtP3FV9yEANXb8yM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MFNh2ZTfEGDWBhQgKk7D61W83FuCk2TF/OWW9K+sosAL7ChPnP74k7TSJ7pm1Q+kQ ZRBh6Jfe75SY50KUiptUFrEklJ5slAbfknree8iqb9GMxQqSe9vMtPsmBf4OB/ZWXX r5SNFdn2tvaBpqM4rE8evTMnR0LvBJtAa+IsEkgA= 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.10 069/103] gpio: pca953x: Improve bias setting Date: Mon, 18 Oct 2021 15:24:45 +0200 Message-Id: <20211018132337.058947845@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132334.702559133@linuxfoundation.org> References: <20211018132334.702559133@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 @@ -558,21 +558,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); @@ -586,7 +586,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;