From nobody Wed Dec 17 12:16:58 2025 Received: from fgw20-7.mail.saunalahti.fi (fgw20-7.mail.saunalahti.fi [62.142.5.81]) (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 011EA1547C8 for ; Sun, 10 Nov 2024 21:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272456; cv=none; b=mzcsQKAtAwgDQvbyu04Mpw5yghsnVCeuHsXssf7o35MEol8gXq6M4Giw50elxos24GUqsnPmITwXdHCNysZKLI4JgEt4itt1ykD2zF6x64Kux6PavRVieH3p/8/gphGxjMwV5ciekRlSAV4yJog2Kaf9KuL2jywpy2S0qw3vBwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272456; c=relaxed/simple; bh=xT1oVb9NpWC5R2d9TuBbIB+PsiQJSZuYSy4aGbdjdFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aVi5IOsETk1aqlyNPBymxPXyCRJlr4z9tkWAOHOvFCarGyHuzc+15l3vPpVzLVF635buzjyTuAHWKLj/gTqpPD4ZaaA31MYrUSVyMF7S+5Tj9Weg3wJgzpIOiBQdZ5bmBAnZ5QQkY9cqZZ/FzOpHsjIj1hs/fPgEaCDlJ1lgmFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-24-75.elisa-laajakaista.fi [88.113.24.75]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id dc5d416a-9fa6-11ef-8874-005056bdd08f; Sun, 10 Nov 2024 23:00:48 +0200 (EET) From: Andy Shevchenko To: Patrick Rudolph , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Andy Shevchenko Subject: [PATCH v1 2/6] pinctrl: cy8c95x0: switch to using devm_regulator_get_enable() Date: Sun, 10 Nov 2024 22:59:42 +0200 Message-ID: <20241110210040.18918-3-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241110210040.18918-1-andy.shevchenko@gmail.com> References: <20241110210040.18918-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The driver does not actively manage regulator state past probe() time, so we can use devm_regulator_get_enable() to simplify the code. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-cy8c95x0.c | 58 ++++++------------------------ 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-c= y8c95x0.c index 5f533dff4417..cb6d9458c1e8 100644 --- a/drivers/pinctrl/pinctrl-cy8c95x0.c +++ b/drivers/pinctrl/pinctrl-cy8c95x0.c @@ -141,7 +141,6 @@ static const struct dmi_system_id cy8c95x0_dmi_acpi_irq= _info[] =3D { * @nport: Number of Gports in this chip * @gpio_chip: gpiolib chip * @driver_data: private driver data - * @regulator: Pointer to the regulator for the IC * @dev: struct device * @pctldev: pin controller device * @pinctrl_desc: pin controller description @@ -163,7 +162,6 @@ struct cy8c95x0_pinctrl { int nport; struct gpio_chip gpio_chip; unsigned long driver_data; - struct regulator *regulator; struct device *dev; struct pinctrl_dev *pctldev; struct pinctrl_desc pinctrl_desc; @@ -1434,7 +1432,6 @@ static int cy8c95x0_probe(struct i2c_client *client) struct cy8c95x0_pinctrl *chip; struct regmap_config regmap_conf; struct regmap_range_cfg regmap_range_conf; - struct regulator *reg; int ret; =20 chip =3D devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); @@ -1448,8 +1445,6 @@ static int cy8c95x0_probe(struct i2c_client *client) if (!chip->driver_data) return -ENODEV; =20 - i2c_set_clientdata(client, chip); - chip->tpin =3D chip->driver_data & CY8C95X0_GPIO_MASK; chip->nport =3D DIV_ROUND_UP(CY8C95X0_PIN_TO_OFFSET(chip->tpin), BANK_SZ); =20 @@ -1472,26 +1467,15 @@ static int cy8c95x0_probe(struct i2c_client *client) return -ENODEV; } =20 - reg =3D devm_regulator_get(&client->dev, "vdd"); - if (IS_ERR(reg)) { - if (PTR_ERR(reg) =3D=3D -EPROBE_DEFER) - return -EPROBE_DEFER; - } else { - ret =3D regulator_enable(reg); - if (ret) { - dev_err(&client->dev, "failed to enable regulator vdd: %d\n", ret); - return ret; - } - chip->regulator =3D reg; - } + ret =3D devm_regulator_get_enable(&client->dev, "vdd"); + if (ret) + return dev_err_probe(&client->dev, ret, "failed to enable regulator vdd\= n"); =20 /* bring the chip out of reset if reset pin is provided */ chip->gpio_reset =3D devm_gpiod_get_optional(&client->dev, "reset", GPIOD= _OUT_HIGH); - if (IS_ERR(chip->gpio_reset)) { - ret =3D dev_err_probe(chip->dev, PTR_ERR(chip->gpio_reset), - "Failed to get GPIO 'reset'\n"); - goto err_exit; - } else if (chip->gpio_reset) { + if (IS_ERR(chip->gpio_reset)) + return dev_err_probe(chip->dev, PTR_ERR(chip->gpio_reset), "Failed to ge= t GPIO 'reset'\n"); + if (chip->gpio_reset) { usleep_range(1000, 2000); gpiod_set_value_cansleep(chip->gpio_reset, 0); usleep_range(250000, 300000); @@ -1506,10 +1490,8 @@ static int cy8c95x0_probe(struct i2c_client *client) regmap_conf.num_reg_defaults_raw =3D regmap_range_conf.range_max; =20 chip->regmap =3D devm_regmap_init_i2c(client, ®map_conf); - if (IS_ERR(chip->regmap)) { - ret =3D PTR_ERR(chip->regmap); - goto err_exit; - } + if (IS_ERR(chip->regmap)) + return PTR_ERR(chip->regmap); =20 bitmap_zero(chip->push_pull, MAX_LINE); bitmap_zero(chip->shiftmask, MAX_LINE); @@ -1525,31 +1507,14 @@ static int cy8c95x0_probe(struct i2c_client *client) if (client->irq) { ret =3D cy8c95x0_irq_setup(chip, client->irq); if (ret) - goto err_exit; + return ret; } =20 ret =3D cy8c95x0_setup_pinctrl(chip); if (ret) - goto err_exit; + return ret; =20 - ret =3D cy8c95x0_setup_gpiochip(chip); - if (ret) - goto err_exit; - - return 0; - -err_exit: - if (!IS_ERR_OR_NULL(chip->regulator)) - regulator_disable(chip->regulator); - return ret; -} - -static void cy8c95x0_remove(struct i2c_client *client) -{ - struct cy8c95x0_pinctrl *chip =3D i2c_get_clientdata(client); - - if (!IS_ERR_OR_NULL(chip->regulator)) - regulator_disable(chip->regulator); + return cy8c95x0_setup_gpiochip(chip); } =20 static const struct acpi_device_id cy8c95x0_acpi_ids[] =3D { @@ -1565,7 +1530,6 @@ static struct i2c_driver cy8c95x0_driver =3D { .acpi_match_table =3D cy8c95x0_acpi_ids, }, .probe =3D cy8c95x0_probe, - .remove =3D cy8c95x0_remove, .id_table =3D cy8c95x0_id, .detect =3D cy8c95x0_detect, }; --=20 2.47.0