From nobody Wed Dec 17 10:52:30 2025 Received: from fgw21-7.mail.saunalahti.fi (fgw21-7.mail.saunalahti.fi [62.142.5.82]) (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 A3B4B157487 for ; Sun, 10 Nov 2024 21:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.82 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272460; cv=none; b=MZgG2hHLKGzxYhvdRseVScQg8wMQwgwzGGCsUcBFElG3lLNDN9DPYTtA9VnizO/VBavFa+u+LAGSCZkDzD0mvo7aB+8p00cdQtj4766wYK4bFxWbrq9QtonrLPT1pZaeh5Cp1drFtEIxCdMIzWA4lGYzh0Z7QiIZK+MnEu6lE/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272460; c=relaxed/simple; bh=IAcBwFzWYVJh6SimAOjlIxXhGXkWE1ZKpdBpKfVlNUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TI1AhDmYmFKQvJuR+B/lVAqlFP8FgwbAhcbCoruTO2Rs62uXWoQJEhKQMtLeFR/ZZEGR/Oe8b3JW9auAwaIFgSNE+3Tp+o6YBV+Jdxpo7PvttnAUaHDkdTP5Ur9Z7B+3Cl1S/j49vK1GSNO3oVq2uyvSOY7zjguS1Zg09iiGFzw= 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.82 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 fgw20.mail.saunalahti.fi (Halon) with ESMTP id db5f26d3-9fa6-11ef-9b01-005056bd6ce9; Sun, 10 Nov 2024 23:00:46 +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 1/6] pinctrl: cy8c95x0: Use 2-argument strscpy() Date: Sun, 10 Nov 2024 22:59:41 +0200 Message-ID: <20241110210040.18918-2-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" Use 2-argument strscpy(), which is not only shorter but also provides an additional check that destination buffer is an array. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-cy8c95x0.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-c= y8c95x0.c index 5096ccdd459e..5f533dff4417 100644 --- a/drivers/pinctrl/pinctrl-cy8c95x0.c +++ b/drivers/pinctrl/pinctrl-cy8c95x0.c @@ -1424,7 +1424,7 @@ static int cy8c95x0_detect(struct i2c_client *client, } =20 dev_info(&client->dev, "Found a %s chip at 0x%02x.\n", name, client->addr= ); - strscpy(info->type, name, I2C_NAME_SIZE); + strscpy(info->type, name); =20 return 0; } @@ -1457,15 +1457,15 @@ static int cy8c95x0_probe(struct i2c_client *client) =20 switch (chip->tpin) { case 20: - strscpy(chip->name, cy8c95x0_id[0].name, I2C_NAME_SIZE); + strscpy(chip->name, cy8c95x0_id[0].name); regmap_range_conf.range_max =3D CY8C95X0_VIRTUAL + 3 * MUXED_STRIDE; break; case 40: - strscpy(chip->name, cy8c95x0_id[1].name, I2C_NAME_SIZE); + strscpy(chip->name, cy8c95x0_id[1].name); regmap_range_conf.range_max =3D CY8C95X0_VIRTUAL + 6 * MUXED_STRIDE; break; case 60: - strscpy(chip->name, cy8c95x0_id[2].name, I2C_NAME_SIZE); + strscpy(chip->name, cy8c95x0_id[2].name); regmap_range_conf.range_max =3D CY8C95X0_VIRTUAL + 8 * MUXED_STRIDE; break; default: --=20 2.47.0 From nobody Wed Dec 17 10:52:30 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 From nobody Wed Dec 17 10:52:30 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 E72FD13A3F3 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=GwXomeaTgzpzVtVwYafJs+bgj1qYxEoMqQt+NYIqSyPfeWqzG6E2dvqjFc4h65nsBtMDhnp7UOcwMMCGfb0k6pAgVxEmaROokyVXyEbC3RqbML+5JQdumqgbxaRTSfqC6jOXV/wZj5JBIt9VLdxvdAlgfljlvHzvrVyjfqrPHFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272456; c=relaxed/simple; bh=QZQswWBjiA6sKRY7WdJThEE2ZM5Xh2HKQzfY+W6JxpI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lF+diwrLbz4qt5kRUZKELE/puEIJEF8gDe5PPVqyoODoGbx7LJ7GHEY5RvgmxuXBpw7hrs3n3FiY3Pr9RL0TVUS6JMFzbL+6s3CtzFDFPIhDLeiPyqyo11ZrpCMP5pQcCBs8MnXgoXj3ahXGxzBo1adLlCY01ulCOroV4F/kQo4= 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 fgw20.mail.saunalahti.fi (Halon) with ESMTP id dd80ce7b-9fa6-11ef-9b01-005056bd6ce9; Sun, 10 Nov 2024 23:00:50 +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 3/6] pinctrl: cy8c95x0: use flexible sleeping in reset function Date: Sun, 10 Nov 2024 22:59:43 +0200 Message-ID: <20241110210040.18918-4-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 device reset assert and deassert length was created by usleep_range() but that does not ensure optimal handling of all the different values from device tree properties. By switching to the new flexible sleeping helper function, fsleep(), the correct delay function is called depending on delay length, e.g. udelay(), usleep_range() or msleep(). While at it, move out GPIO consumer name setting of the reset conditional, the all necessary checks are already done there, so logically that call is not related to the reset sequence. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-cy8c95x0.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-c= y8c95x0.c index cb6d9458c1e8..54b080f63226 100644 --- a/drivers/pinctrl/pinctrl-cy8c95x0.c +++ b/drivers/pinctrl/pinctrl-cy8c95x0.c @@ -1475,12 +1475,11 @@ static int cy8c95x0_probe(struct i2c_client *client) chip->gpio_reset =3D devm_gpiod_get_optional(&client->dev, "reset", GPIOD= _OUT_HIGH); if (IS_ERR(chip->gpio_reset)) return dev_err_probe(chip->dev, PTR_ERR(chip->gpio_reset), "Failed to ge= t GPIO 'reset'\n"); + gpiod_set_consumer_name(chip->gpio_reset, "CY8C95X0 RESET"); if (chip->gpio_reset) { - usleep_range(1000, 2000); + fsleep(1000); gpiod_set_value_cansleep(chip->gpio_reset, 0); - usleep_range(250000, 300000); - - gpiod_set_consumer_name(chip->gpio_reset, "CY8C95X0 RESET"); + fsleep(250000); } =20 /* Regmap for direct and paged registers */ --=20 2.47.0 From nobody Wed Dec 17 10:52:30 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 0119A154457 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=aECyTVdtrsMd8/4GUviqloUyh5Xw5yjn0rsyjX4+lkTIGbJYVJV8c24qudEq5UFDqjOV/c77Xeb6+t0f3F7tx8/Q9IjtV7LaCLApLCK9nugHoqUvQVd31xFvRhQmdLBYDZKaZQJSiy+iZ26TqSMLLmKHr/Q24OX1+27UU0c8N6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272456; c=relaxed/simple; bh=StWURDzPXrrNwdPZqNvuhg+95fYmCc2elITSw30Am9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=alNVLj9xgAudRL1uRYyF1nu0E3ow5tesoA1framzviYLzvhMrsPeGtYCqtZpcS+mkJuxVlCXa/sCb0Nz3TVjkRw9yyAgg9EM5JuFM2lUJ6qq3LYdEDqkSgNpaeAEEB0WZ4I7Qe4UhIxy0+2bLHL+B5gJdMMNHPA798n3OqgDItA= 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 fgw22.mail.saunalahti.fi (Halon) with ESMTP id de7c4074-9fa6-11ef-8261-005056bdf889; Sun, 10 Nov 2024 23:00:51 +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 4/6] pinctrl: cy8c95x0: Use temporary variable for struct device Date: Sun, 10 Nov 2024 22:59:44 +0200 Message-ID: <20241110210040.18918-5-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" Use a temporary variable for the struct device pointers to avoid dereferencing. This makes code a bit neater. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-cy8c95x0.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-c= y8c95x0.c index 54b080f63226..8b118fd09e9e 100644 --- a/drivers/pinctrl/pinctrl-cy8c95x0.c +++ b/drivers/pinctrl/pinctrl-cy8c95x0.c @@ -1429,16 +1429,17 @@ static int cy8c95x0_detect(struct i2c_client *clien= t, =20 static int cy8c95x0_probe(struct i2c_client *client) { + struct device *dev =3D &client->dev; struct cy8c95x0_pinctrl *chip; struct regmap_config regmap_conf; struct regmap_range_cfg regmap_range_conf; int ret; =20 - chip =3D devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); + chip =3D devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; =20 - chip->dev =3D &client->dev; + chip->dev =3D dev; =20 /* Set the device type */ chip->driver_data =3D (uintptr_t)i2c_get_match_data(client); @@ -1467,14 +1468,14 @@ static int cy8c95x0_probe(struct i2c_client *client) return -ENODEV; } =20 - ret =3D devm_regulator_get_enable(&client->dev, "vdd"); + ret =3D devm_regulator_get_enable(dev, "vdd"); if (ret) - return dev_err_probe(&client->dev, ret, "failed to enable regulator vdd\= n"); + return dev_err_probe(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); + chip->gpio_reset =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH= ); if (IS_ERR(chip->gpio_reset)) - return dev_err_probe(chip->dev, PTR_ERR(chip->gpio_reset), "Failed to ge= t GPIO 'reset'\n"); + return dev_err_probe(dev, PTR_ERR(chip->gpio_reset), "Failed to get GPIO= 'reset'\n"); gpiod_set_consumer_name(chip->gpio_reset, "CY8C95X0 RESET"); if (chip->gpio_reset) { fsleep(1000); --=20 2.47.0 From nobody Wed Dec 17 10:52:30 2025 Received: from fgw22-7.mail.saunalahti.fi (fgw22-7.mail.saunalahti.fi [62.142.5.83]) (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 EEE8E155325 for ; Sun, 10 Nov 2024 21:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272471; cv=none; b=gQGXmMcvpbn3hrGCwDVKv5aV/6J0SyVXlFNwLqwA+r7AbZhF0DWhY4P5W8A2+LxPr+A/YrYjcWSyHxXgI38KQfJy37mOSWutOfrDwIzZj4Eitz4cd3Qb5hxAoJrcqW0O5UnetFp9P5BRqojqq7P60Vh7Mjn+5dzFcYSkgJo0+5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272471; c=relaxed/simple; bh=I1PF87o/v3duEmVol3hK5Hn3dWDF6plXuD4SahJVq1A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sBiyT5zZgXLC7tA2vHCYDLvcs/xyK6hvVjStvsmB5aW6BRWUcP7ZPNt7YdtI3Je0FIzq1YfbGfpboaF62i23Zl545XGLsoVEQXMQ31zpRoivNaXbgCbjXFuWthYuMnikly8JrWv1LauJM3dA8xO9+AkNixc8l1CIg87aOOKWtZg= 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.83 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 df906ca3-9fa6-11ef-8874-005056bdd08f; Sun, 10 Nov 2024 23:00:53 +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 5/6] pinctrl: cy8c95x0: embed iterator to the for-loop Date: Sun, 10 Nov 2024 22:59:45 +0200 Message-ID: <20241110210040.18918-6-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" When we iterate through nports the iterator variable is effectively being not used outside of the loop. Make it clear by moving its definition into the for-loop. This makes code cleaner as well. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-cy8c95x0.c | 36 +++++++++++++----------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-c= y8c95x0.c index 8b118fd09e9e..8c611abd4745 100644 --- a/drivers/pinctrl/pinctrl-cy8c95x0.c +++ b/drivers/pinctrl/pinctrl-cy8c95x0.c @@ -159,7 +159,7 @@ struct cy8c95x0_pinctrl { DECLARE_BITMAP(irq_trig_high, MAX_LINE); DECLARE_BITMAP(push_pull, MAX_LINE); DECLARE_BITMAP(shiftmask, MAX_LINE); - int nport; + unsigned int nport; struct gpio_chip gpio_chip; unsigned long driver_data; struct device *dev; @@ -610,9 +610,8 @@ static int cy8c95x0_write_regs_mask(struct cy8c95x0_pin= ctrl *chip, int reg, DECLARE_BITMAP(tmask, MAX_LINE); DECLARE_BITMAP(tval, MAX_LINE); int write_val; - int ret =3D 0; - int i; u8 bits; + int ret; =20 /* Add the 4 bit gap of Gport2 */ bitmap_andnot(tmask, mask, chip->shiftmask, MAX_LINE); @@ -623,7 +622,7 @@ static int cy8c95x0_write_regs_mask(struct cy8c95x0_pin= ctrl *chip, int reg, bitmap_shift_left(tval, tval, 4, MAX_LINE); bitmap_replace(tval, tval, val, chip->shiftmask, BANK_SZ * 3); =20 - for (i =3D 0; i < chip->nport; i++) { + for (unsigned int i =3D 0; i < chip->nport; i++) { /* Skip over unused banks */ bits =3D bitmap_get_value8(tmask, i * BANK_SZ); if (!bits) @@ -632,15 +631,13 @@ static int cy8c95x0_write_regs_mask(struct cy8c95x0_p= inctrl *chip, int reg, write_val =3D bitmap_get_value8(tval, i * BANK_SZ); =20 ret =3D cy8c95x0_regmap_update_bits(chip, reg, i, bits, write_val); - if (ret < 0) - goto out; + if (ret < 0) { + dev_err(chip->dev, "failed writing register %d, port %u: err %d\n", reg= , i, ret); + return ret; + } } -out: =20 - if (ret < 0) - dev_err(chip->dev, "failed writing register %d, port %d: err %d\n", reg,= i, ret); - - return ret; + return 0; } =20 static int cy8c95x0_read_regs_mask(struct cy8c95x0_pinctrl *chip, int reg, @@ -650,9 +647,8 @@ static int cy8c95x0_read_regs_mask(struct cy8c95x0_pinc= trl *chip, int reg, DECLARE_BITMAP(tval, MAX_LINE); DECLARE_BITMAP(tmp, MAX_LINE); int read_val; - int ret =3D 0; - int i; u8 bits; + int ret; =20 /* Add the 4 bit gap of Gport2 */ bitmap_andnot(tmask, mask, chip->shiftmask, MAX_LINE); @@ -663,15 +659,17 @@ static int cy8c95x0_read_regs_mask(struct cy8c95x0_pi= nctrl *chip, int reg, bitmap_shift_left(tval, tval, 4, MAX_LINE); bitmap_replace(tval, tval, val, chip->shiftmask, BANK_SZ * 3); =20 - for (i =3D 0; i < chip->nport; i++) { + for (unsigned int i =3D 0; i < chip->nport; i++) { /* Skip over unused banks */ bits =3D bitmap_get_value8(tmask, i * BANK_SZ); if (!bits) continue; =20 ret =3D cy8c95x0_regmap_read(chip, reg, i, &read_val); - if (ret < 0) - goto out; + if (ret < 0) { + dev_err(chip->dev, "failed reading register %d, port %u: err %d\n", reg= , i, ret); + return ret; + } =20 read_val &=3D bits; read_val |=3D bitmap_get_value8(tval, i * BANK_SZ) & ~bits; @@ -682,11 +680,7 @@ static int cy8c95x0_read_regs_mask(struct cy8c95x0_pin= ctrl *chip, int reg, bitmap_shift_right(tmp, tval, 4, MAX_LINE); bitmap_replace(val, tmp, tval, chip->shiftmask, MAX_LINE); =20 -out: - if (ret < 0) - dev_err(chip->dev, "failed reading register %d, port %d: err %d\n", reg,= i, ret); - - return ret; + return 0; } =20 static int cy8c95x0_gpio_direction_input(struct gpio_chip *gc, unsigned in= t off) --=20 2.47.0 From nobody Wed Dec 17 10:52:30 2025 Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) (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 CE9891531C0 for ; Sun, 10 Nov 2024 21:01:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272464; cv=none; b=mvAjsCNFbBr0Z1T2+bPQvQsDcwYwUFwAO33cgwZWHG7oc+XJPploJj011NtscyYREdnG7COx8qKnJACktEBXhIG4P9cZhvHJeNhGYneuwJrzS6BgBopCqurk3jJG3jexo6Pt4NvNSyMcz/vQv9bsAvMpkeYiIZQC1mXV8ipkpNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731272464; c=relaxed/simple; bh=EQt3n3i1KyUDZRw+vpApQXPdDqecwrKAyC+BRjzPnP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kY0CFNeFdxovin/6umhdXoqk4VRZoF98ZhIQvFxKGt7iK/awCyu6/+Bwe79TboiBA7J6ce+gcNPiZumibRfax5y6Q9zRW6H9s2VVI/ynGNFtloAbRUn/a2u1dmTt0E0VncAXRjSC1KDea5YWPXqvkCNtAoN5OWTqblt7HpGkwMo= 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.84 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 e093f038-9fa6-11ef-8874-005056bdd08f; Sun, 10 Nov 2024 23:00:55 +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 6/6] pinctrl: cy8c95x0: remove unneeded goto labels Date: Sun, 10 Nov 2024 22:59:46 +0200 Message-ID: <20241110210040.18918-7-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" In some cases the code uses goto labels to just return an error code. Replace those with direct return:s and drop unneeded goto labels. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-cy8c95x0.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-c= y8c95x0.c index 8c611abd4745..0d6c2027d4c1 100644 --- a/drivers/pinctrl/pinctrl-cy8c95x0.c +++ b/drivers/pinctrl/pinctrl-cy8c95x0.c @@ -746,14 +746,12 @@ static int cy8c95x0_gpio_get_direction(struct gpio_ch= ip *gc, unsigned int off) =20 ret =3D cy8c95x0_regmap_read(chip, CY8C95X0_DIRECTION, port, ®_val); if (ret < 0) - goto out; + return ret; =20 if (reg_val & bit) return GPIO_LINE_DIRECTION_IN; =20 return GPIO_LINE_DIRECTION_OUT; -out: - return ret; } =20 static int cy8c95x0_gpio_get_pincfg(struct cy8c95x0_pinctrl *chip, @@ -815,8 +813,7 @@ static int cy8c95x0_gpio_get_pincfg(struct cy8c95x0_pin= ctrl *chip, case PIN_CONFIG_SLEEP_HARDWARE_STATE: case PIN_CONFIG_SLEW_RATE: default: - ret =3D -ENOTSUPP; - goto out; + return -ENOTSUPP; } /* * Writing 1 to one of the drive mode registers will automatically @@ -824,7 +821,7 @@ static int cy8c95x0_gpio_get_pincfg(struct cy8c95x0_pin= ctrl *chip, */ ret =3D cy8c95x0_regmap_read(chip, reg, port, ®_val); if (ret < 0) - goto out; + return ret; =20 if (reg_val & bit) arg =3D 1; @@ -832,8 +829,7 @@ static int cy8c95x0_gpio_get_pincfg(struct cy8c95x0_pin= ctrl *chip, arg =3D !arg; =20 *config =3D pinconf_to_config_packed(param, (u16)arg); -out: - return ret; + return 0; } =20 static int cy8c95x0_gpio_set_pincfg(struct cy8c95x0_pinctrl *chip, @@ -845,7 +841,6 @@ static int cy8c95x0_gpio_set_pincfg(struct cy8c95x0_pin= ctrl *chip, unsigned long param =3D pinconf_to_config_param(config); unsigned long arg =3D pinconf_to_config_argument(config); unsigned int reg; - int ret; =20 switch (param) { case PIN_CONFIG_BIAS_PULL_UP: @@ -876,22 +871,17 @@ static int cy8c95x0_gpio_set_pincfg(struct cy8c95x0_p= inctrl *chip, reg =3D CY8C95X0_PWMSEL; break; case PIN_CONFIG_OUTPUT_ENABLE: - ret =3D cy8c95x0_pinmux_direction(chip, off, !arg); - goto out; + return cy8c95x0_pinmux_direction(chip, off, !arg); case PIN_CONFIG_INPUT_ENABLE: - ret =3D cy8c95x0_pinmux_direction(chip, off, arg); - goto out; + return cy8c95x0_pinmux_direction(chip, off, arg); default: - ret =3D -ENOTSUPP; - goto out; + return -ENOTSUPP; } /* * Writing 1 to one of the drive mode registers will automatically * clear conflicting set bits in the other drive mode registers. */ - ret =3D cy8c95x0_regmap_write_bits(chip, reg, port, bit, bit); -out: - return ret; + return cy8c95x0_regmap_write_bits(chip, reg, port, bit, bit); } =20 static int cy8c95x0_gpio_get_multiple(struct gpio_chip *gc, --=20 2.47.0