public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/11] aw9523: number of cleanups
@ 2024-03-29 10:55 Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 01/11] pinctrl: aw9523: Destroy mutex on ->remove() Andy Shevchenko
                   ` (11 more replies)
  0 siblings, 12 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

Just noticed that the newly introduced driver has some leftovers or unneeded
customisation. Hence this series. It may (or may not :-) be sent as an update
for v6.9 cycle, but TBH there is nothing functional critical. 

In v2:
- fixed typo in patch 4 (LKP)

Andy Shevchenko (11):
  pinctrl: aw9523: Destroy mutex on ->remove()
  pinctrl: aw9523: Use correct error code for not supported
    functionality
  pinctrl: aw9523: Always try both ports in aw9523_gpio_set_multiple()
  pinctrl: aw9523: Make use of struct pinfunction and
    PINCTRL_PINFUNCTION()
  pinctrl: aw9523: Use temporary variable for HW IRQ number
  pinctrl: aw9523: Get rid of redundant ' & U8_MAX' pieces
  pinctrl: aw9523: Remove unused irqchip field in struct aw9523_irq
  pinctrl: aw9523: Make use of dev_err_probe()
  pinctrl: aw9523: Sort headers and group pinctrl/*
  pinctrl: aw9523: Fix indentation in a few places
  pinctrl: aw9523: Remove redundant dependency to OF

 drivers/pinctrl/Kconfig          |   2 +-
 drivers/pinctrl/pinctrl-aw9523.c | 132 +++++++++++--------------------
 2 files changed, 48 insertions(+), 86 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 01/11] pinctrl: aw9523: Destroy mutex on ->remove()
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 02/11] pinctrl: aw9523: Use correct error code for not supported functionality Andy Shevchenko
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

If aw9523_hw_init() fails on ->remove() the mutex left alive.
Destroy it in that case as well. While at it, remove never
true check at the beginning of the function.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index 4edd371c469fb..66629af0b88b4 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -1067,10 +1067,6 @@ static int aw9523_probe(struct i2c_client *client)
 static void aw9523_remove(struct i2c_client *client)
 {
 	struct aw9523 *awi = i2c_get_clientdata(client);
-	int ret;
-
-	if (!awi)
-		return;
 
 	/*
 	 * If the chip VIO is connected to a regulator that we can turn
@@ -1082,10 +1078,8 @@ static void aw9523_remove(struct i2c_client *client)
 		regulator_disable(awi->vio_vreg);
 	} else {
 		mutex_lock(&awi->i2c_lock);
-		ret = aw9523_hw_init(awi);
+		aw9523_hw_init(awi);
 		mutex_unlock(&awi->i2c_lock);
-		if (ret)
-			return;
 	}
 
 	mutex_destroy(&awi->i2c_lock);
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 02/11] pinctrl: aw9523: Use correct error code for not supported functionality
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 01/11] pinctrl: aw9523: Destroy mutex on ->remove() Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 03/11] pinctrl: aw9523: Always try both ports in aw9523_gpio_set_multiple() Andy Shevchenko
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

The pin control subsystem internally uses ENOTSUPP for the not supported
functionality. The checkpatch is false positive about this error code.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index 66629af0b88b4..65d523697b731 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -6,6 +6,7 @@
  */
 
 #include <linux/bitfield.h>
+#include <linux/errno.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/i2c.h>
@@ -239,7 +240,7 @@ static int aw9523_pcfg_param_to_reg(enum pin_config_param pcp, int pin, u8 *r)
 		reg = AW9523_REG_OUT_STATE(pin);
 		break;
 	default:
-		return -EOPNOTSUPP;
+		return -ENOTSUPP;
 	}
 	*r = reg;
 
@@ -290,7 +291,7 @@ static int aw9523_pconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
 			val = FIELD_GET(AW9523_GCR_GPOMD_MASK, val);
 		break;
 	default:
-		return -EOPNOTSUPP;
+		return -ENOTSUPP;
 	}
 	if (val < 1)
 		return -EINVAL;
@@ -344,7 +345,7 @@ static int aw9523_pconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
 		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
 			/* Open-Drain is supported only on port 0 */
 			if (pin >= AW9523_PINS_PER_PORT) {
-				rc = -EOPNOTSUPP;
+				rc = -ENOTSUPP;
 				goto end;
 			}
 			mask = AW9523_GCR_GPOMD_MASK;
@@ -361,7 +362,7 @@ static int aw9523_pconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
 			val = AW9523_GCR_GPOMD_MASK;
 			break;
 		default:
-			rc = -EOPNOTSUPP;
+			rc = -ENOTSUPP;
 			goto end;
 		}
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 03/11] pinctrl: aw9523: Always try both ports in aw9523_gpio_set_multiple()
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 01/11] pinctrl: aw9523: Destroy mutex on ->remove() Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 02/11] pinctrl: aw9523: Use correct error code for not supported functionality Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 04/11] pinctrl: aw9523: Make use of struct pinfunction and PINCTRL_PINFUNCTION() Andy Shevchenko
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

The ports are equivalent from the user's point of view. Don't limit
trying them both if writing to one fails.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index 65d523697b731..d93640a02d1d3 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -653,7 +653,7 @@ static void aw9523_gpio_set_multiple(struct gpio_chip *chip,
 	struct aw9523 *awi = gpiochip_get_data(chip);
 	u8 mask_lo, mask_hi, bits_lo, bits_hi;
 	unsigned int reg;
-	int ret = 0;
+	int ret;
 
 	mask_lo = *mask & U8_MAX;
 	mask_hi = (*mask >> 8) & U8_MAX;
@@ -663,10 +663,8 @@ static void aw9523_gpio_set_multiple(struct gpio_chip *chip,
 		bits_hi = (*bits >> 8) & U8_MAX;
 
 		ret = regmap_write_bits(awi->regmap, reg, mask_hi, bits_hi);
-		if (ret) {
+		if (ret)
 			dev_warn(awi->dev, "Cannot write port1 out level\n");
-			goto out;
-		}
 	}
 	if (mask_lo) {
 		reg = AW9523_REG_OUT_STATE(0);
@@ -675,7 +673,6 @@ static void aw9523_gpio_set_multiple(struct gpio_chip *chip,
 		if (ret)
 			dev_warn(awi->dev, "Cannot write port0 out level\n");
 	}
-out:
 	mutex_unlock(&awi->i2c_lock);
 }
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 04/11] pinctrl: aw9523: Make use of struct pinfunction and PINCTRL_PINFUNCTION()
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (2 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 03/11] pinctrl: aw9523: Always try both ports in aw9523_gpio_set_multiple() Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 05/11] pinctrl: aw9523: Use temporary variable for HW IRQ number Andy Shevchenko
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel
  Cc: Andy Shevchenko

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Since pin control provides a generic data type and a macro for
the pin function definition, use them in the driver.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 32 ++++++--------------------------
 1 file changed, 6 insertions(+), 26 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index d93640a02d1d3..7db901216a94c 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -66,18 +66,6 @@ struct aw9523_irq {
 	u16 cached_gpio;
 };
 
-/*
- * struct aw9523_pinmux - Pin mux params
- * @name: Name of the mux
- * @grps: Groups of the mux
- * @num_grps: Number of groups (sizeof array grps)
- */
-struct aw9523_pinmux {
-	const char *name;
-	const char * const *grps;
-	const u8 num_grps;
-};
-
 /*
  * struct aw9523 - Main driver structure
  * @dev: device handle
@@ -158,17 +146,9 @@ static const char * const gpio_pwm_groups[] = {
 };
 
 /* Warning: Do NOT reorder this array */
-static const struct aw9523_pinmux aw9523_pmx[] = {
-	{
-		.name = "pwm",
-		.grps = gpio_pwm_groups,
-		.num_grps = ARRAY_SIZE(gpio_pwm_groups),
-	},
-	{
-		.name = "gpio",
-		.grps = gpio_pwm_groups,
-		.num_grps = ARRAY_SIZE(gpio_pwm_groups),
-	},
+static const struct pinfunction aw9523_pmx[] = {
+	PINCTRL_PINFUNCTION("pwm", gpio_pwm_groups, ARRAY_SIZE(gpio_pwm_groups)),
+	PINCTRL_PINFUNCTION("gpio", gpio_pwm_groups, ARRAY_SIZE(gpio_pwm_groups)),
 };
 
 static int aw9523_pmx_get_funcs_count(struct pinctrl_dev *pctl)
@@ -184,10 +164,10 @@ static const char *aw9523_pmx_get_fname(struct pinctrl_dev *pctl,
 
 static int aw9523_pmx_get_groups(struct pinctrl_dev *pctl, unsigned int sel,
 				 const char * const **groups,
-				 unsigned int * const num_groups)
+				 unsigned int * const ngroups)
 {
-	*groups = aw9523_pmx[sel].grps;
-	*num_groups = aw9523_pmx[sel].num_grps;
+	*groups = aw9523_pmx[sel].groups;
+	*ngroups = aw9523_pmx[sel].ngroups;
 	return 0;
 }
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 05/11] pinctrl: aw9523: Use temporary variable for HW IRQ number
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (3 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 04/11] pinctrl: aw9523: Make use of struct pinfunction and PINCTRL_PINFUNCTION() Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 06/11] pinctrl: aw9523: Get rid of redundant ' & U8_MAX' pieces Andy Shevchenko
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

There are two different ways on how to get HW IRQ number in some functions.
Unify that by using temporary variable and irqd_to_hwirq() call.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index 7db901216a94c..0f3361fa9ed88 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -428,12 +428,12 @@ static int aw9523_gpio_irq_type(struct irq_data *d, unsigned int type)
 static void aw9523_irq_mask(struct irq_data *d)
 {
 	struct aw9523 *awi = gpiochip_get_data(irq_data_get_irq_chip_data(d));
-	unsigned int n = d->hwirq % AW9523_PINS_PER_PORT;
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
+	unsigned int n = hwirq % AW9523_PINS_PER_PORT;
 
-	regmap_update_bits(awi->regmap,
-			   AW9523_REG_INTR_DIS(d->hwirq),
+	regmap_update_bits(awi->regmap, AW9523_REG_INTR_DIS(hwirq),
 			   BIT(n), BIT(n));
-	gpiochip_disable_irq(&awi->gpio, irqd_to_hwirq(d));
+	gpiochip_disable_irq(&awi->gpio, hwirq);
 }
 
 /*
@@ -446,11 +446,11 @@ static void aw9523_irq_mask(struct irq_data *d)
 static void aw9523_irq_unmask(struct irq_data *d)
 {
 	struct aw9523 *awi = gpiochip_get_data(irq_data_get_irq_chip_data(d));
-	unsigned int n = d->hwirq % AW9523_PINS_PER_PORT;
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
+	unsigned int n = hwirq % AW9523_PINS_PER_PORT;
 
-	gpiochip_enable_irq(&awi->gpio, irqd_to_hwirq(d));
-	regmap_update_bits(awi->regmap,
-			   AW9523_REG_INTR_DIS(d->hwirq),
+	gpiochip_enable_irq(&awi->gpio, hwirq);
+	regmap_update_bits(awi->regmap, AW9523_REG_INTR_DIS(hwirq),
 			   BIT(n), 0);
 }
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 06/11] pinctrl: aw9523: Get rid of redundant ' & U8_MAX' pieces
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (4 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 05/11] pinctrl: aw9523: Use temporary variable for HW IRQ number Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 07/11] pinctrl: aw9523: Remove unused irqchip field in struct aw9523_irq Andy Shevchenko
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

When the variable is declared as u8, no need to perform ' & U8_MAX'
as it's implied anyway.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index 0f3361fa9ed88..8c615adb3d578 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -603,7 +603,7 @@ static int aw9523_gpio_get_multiple(struct gpio_chip *chip,
 	mutex_lock(&awi->i2c_lock);
 
 	/* Port 0 (gpio 0-7) */
-	m = *mask & U8_MAX;
+	m = *mask;
 	if (m) {
 		ret = _aw9523_gpio_get_multiple(awi, 0, &state, m);
 		if (ret)
@@ -612,7 +612,7 @@ static int aw9523_gpio_get_multiple(struct gpio_chip *chip,
 	*bits = state;
 
 	/* Port 1 (gpio 8-15) */
-	m = (*mask >> 8) & U8_MAX;
+	m = *mask >> 8;
 	if (m) {
 		ret = _aw9523_gpio_get_multiple(awi, AW9523_PINS_PER_PORT,
 						&state, m);
@@ -635,20 +635,20 @@ static void aw9523_gpio_set_multiple(struct gpio_chip *chip,
 	unsigned int reg;
 	int ret;
 
-	mask_lo = *mask & U8_MAX;
-	mask_hi = (*mask >> 8) & U8_MAX;
+	mask_lo = *mask;
+	mask_hi = *mask >> 8;
+	bits_lo = *bits;
+	bits_hi = *bits >> 8;
+
 	mutex_lock(&awi->i2c_lock);
 	if (mask_hi) {
 		reg = AW9523_REG_OUT_STATE(AW9523_PINS_PER_PORT);
-		bits_hi = (*bits >> 8) & U8_MAX;
-
 		ret = regmap_write_bits(awi->regmap, reg, mask_hi, bits_hi);
 		if (ret)
 			dev_warn(awi->dev, "Cannot write port1 out level\n");
 	}
 	if (mask_lo) {
 		reg = AW9523_REG_OUT_STATE(0);
-		bits_lo = *bits & U8_MAX;
 		ret = regmap_write_bits(awi->regmap, reg, mask_lo, bits_lo);
 		if (ret)
 			dev_warn(awi->dev, "Cannot write port0 out level\n");
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 07/11] pinctrl: aw9523: Remove unused irqchip field in struct aw9523_irq
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (5 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 06/11] pinctrl: aw9523: Get rid of redundant ' & U8_MAX' pieces Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 08/11] pinctrl: aw9523: Make use of dev_err_probe() Andy Shevchenko
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

The irqchip field is allocated, assigned but never used. Remove it.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index 8c615adb3d578..f084dad5c88f9 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -57,12 +57,10 @@
 /*
  * struct aw9523_irq - Interrupt controller structure
  * @lock: mutex locking for the irq bus
- * @irqchip: structure holding irqchip params
  * @cached_gpio: stores the previous gpio status for bit comparison
  */
 struct aw9523_irq {
 	struct mutex lock;
-	struct irq_chip *irqchip;
 	u16 cached_gpio;
 };
 
@@ -805,21 +803,15 @@ static int aw9523_init_irq(struct aw9523 *awi, int irq)
 {
 	struct device *dev = awi->dev;
 	struct gpio_irq_chip *girq;
-	struct irq_chip *irqchip;
 	int ret;
 
 	if (!device_property_read_bool(dev, "interrupt-controller"))
 		return 0;
 
-	irqchip = devm_kzalloc(dev, sizeof(*irqchip), GFP_KERNEL);
-	if (!irqchip)
-		return -ENOMEM;
-
 	awi->irq = devm_kzalloc(dev, sizeof(*awi->irq), GFP_KERNEL);
 	if (!awi->irq)
 		return -ENOMEM;
 
-	awi->irq->irqchip = irqchip;
 	mutex_init(&awi->irq->lock);
 
 	ret = devm_request_threaded_irq(dev, irq, NULL, aw9523_irq_thread_func,
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 08/11] pinctrl: aw9523: Make use of dev_err_probe()
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (6 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 07/11] pinctrl: aw9523: Remove unused irqchip field in struct aw9523_irq Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 09/11] pinctrl: aw9523: Sort headers and group pinctrl/* Andy Shevchenko
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel
  Cc: Andy Shevchenko

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Simplify the error handling in probe function by switching from
dev_err() to dev_err_probe().

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index f084dad5c88f9..fe398c59c2d11 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -816,10 +816,8 @@ static int aw9523_init_irq(struct aw9523 *awi, int irq)
 
 	ret = devm_request_threaded_irq(dev, irq, NULL, aw9523_irq_thread_func,
 					IRQF_ONESHOT, dev_name(dev), awi);
-	if (ret) {
-		dev_err(dev, "Failed to request irq %d\n", irq);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to request irq %d\n", irq);
 
 	girq = &awi->gpio.irq;
 	gpio_irq_chip_set_chip(girq, &aw9523_irq_chip);
@@ -1016,8 +1014,7 @@ static int aw9523_probe(struct i2c_client *client)
 
 	awi->pctl = devm_pinctrl_register(dev, pdesc, awi);
 	if (IS_ERR(awi->pctl)) {
-		ret = PTR_ERR(awi->pctl);
-		dev_err(dev, "Cannot register pinctrl: %d", ret);
+		ret = dev_err_probe(dev, PTR_ERR(awi->pctl), "Cannot register pinctrl");
 		goto err_disable_vregs;
 	}
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 09/11] pinctrl: aw9523: Sort headers and group pinctrl/*
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (7 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 08/11] pinctrl: aw9523: Make use of dev_err_probe() Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 10/11] pinctrl: aw9523: Fix indentation in a few places Andy Shevchenko
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

One header was misplaced and group pinctrl/* ones to show the relation
with the pin control subsystem.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index fe398c59c2d11..49d5035899227 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -13,17 +13,18 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/mutex.h>
 #include <linux/module.h>
-#include <linux/pinctrl/pinconf.h>
-#include <linux/pinctrl/pinctrl.h>
-#include <linux/pinctrl/pinmux.h>
-#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/mutex.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinconf.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+
 #define AW9523_MAX_FUNCS		2
 #define AW9523_NUM_PORTS		2
 #define AW9523_PINS_PER_PORT		8
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 10/11] pinctrl: aw9523: Fix indentation in a few places
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (8 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 09/11] pinctrl: aw9523: Sort headers and group pinctrl/* Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-03-29 10:55 ` [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF Andy Shevchenko
  2024-04-04 11:17 ` [PATCH v2 00/11] aw9523: number of cleanups Linus Walleij
  11 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

In the comment, function prototype, and array of strings indentation
is kinda broken. Reindent that.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-aw9523.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index 49d5035899227..b5e1c467625ba 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Awinic AW9523B i2c pin controller driver
- * Copyright (c) 2020, AngeloGioacchino Del Regno
- *                     <angelogioacchino.delregno@somainline.org>
+ * Copyright (c) 2020, AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
  */
 
 #include <linux/bitfield.h>
@@ -139,9 +138,10 @@ static const struct pinctrl_ops aw9523_pinctrl_ops = {
 };
 
 static const char * const gpio_pwm_groups[] = {
-	"gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5",
-	"gpio6", "gpio7", "gpio8", "gpio9", "gpio10", "gpio11",
-	"gpio12", "gpio13", "gpio14", "gpio15"
+	"gpio0", "gpio1", "gpio2", "gpio3",		/* 0-3 */
+	"gpio4", "gpio5", "gpio6", "gpio7",		/* 4-7 */
+	"gpio8", "gpio9", "gpio10", "gpio11",		/* 8-11 */
+	"gpio12", "gpio13", "gpio14", "gpio15",		/* 11-15 */
 };
 
 /* Warning: Do NOT reorder this array */
@@ -388,8 +388,8 @@ static int aw9523_get_pin_direction(struct regmap *regmap, u8 pin, u8 n)
  *
  * Return: Zero for success or negative number for error
  */
-static int aw9523_get_port_state(struct regmap *regmap, u8 pin,
-				   u8 regbit, unsigned int *state)
+static int aw9523_get_port_state(struct regmap *regmap, u8 pin, u8 regbit,
+				 unsigned int *state)
 {
 	u8 reg;
 	int dir;
@@ -984,8 +984,7 @@ static int aw9523_probe(struct i2c_client *client)
 	}
 
 	mutex_init(&awi->i2c_lock);
-	lockdep_set_subclass(&awi->i2c_lock,
-			     i2c_adapter_depth(client->adapter));
+	lockdep_set_subclass(&awi->i2c_lock, i2c_adapter_depth(client->adapter));
 
 	pdesc = devm_kzalloc(dev, sizeof(*pdesc), GFP_KERNEL);
 	if (!pdesc)
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (9 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 10/11] pinctrl: aw9523: Fix indentation in a few places Andy Shevchenko
@ 2024-03-29 10:55 ` Andy Shevchenko
  2024-04-02  8:34   ` kernel test robot
  2024-04-04 11:19   ` Linus Walleij
  2024-04-04 11:17 ` [PATCH v2 00/11] aw9523: number of cleanups Linus Walleij
  11 siblings, 2 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-03-29 10:55 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel

Driver does not dependent on OF, remove it.
While here, add missing mod_devicetable.h.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/Kconfig          | 2 +-
 drivers/pinctrl/pinctrl-aw9523.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index d45657aa986ae..c413109b1173b 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -129,7 +129,7 @@ config PINCTRL_AXP209
 
 config PINCTRL_AW9523
 	tristate "Awinic AW9523/AW9523B I2C GPIO expander pinctrl driver"
-	depends on OF && I2C
+	depends on I2C
 	select PINMUX
 	select PINCONF
 	select GENERIC_PINCONF
diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index b5e1c467625ba..1d0ce78115da7 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/property.h>
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF
  2024-03-29 10:55 ` [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF Andy Shevchenko
@ 2024-04-02  8:34   ` kernel test robot
  2024-04-04 11:19   ` Linus Walleij
  1 sibling, 0 replies; 16+ messages in thread
From: kernel test robot @ 2024-04-02  8:34 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, AngeloGioacchino Del Regno,
	linux-gpio, linux-kernel
  Cc: oe-kbuild-all

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next linus/master v6.9-rc2 next-20240402]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/pinctrl-aw9523-Destroy-mutex-on-remove/20240329-185957
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20240329105634.712457-12-andy.shevchenko%40gmail.com
patch subject: [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF
config: i386-randconfig-054-20240401 (https://download.01.org/0day-ci/archive/20240402/202404021642.1I0w7URO-lkp@intel.com/config)
compiler: gcc-12 (Ubuntu 12.3.0-9ubuntu2) 12.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240402/202404021642.1I0w7URO-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404021642.1I0w7URO-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: drivers/pinctrl/pinctrl-aw9523.o: in function `pinconf_generic_dt_node_to_map_pin':
   include/linux/pinctrl/pinconf-generic.h:216:(.text+0x891): undefined reference to `pinconf_generic_dt_node_to_map'
>> ld: drivers/pinctrl/pinctrl-aw9523.o:(.rodata+0x4f4): undefined reference to `pinconf_generic_dt_free_map'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 00/11] aw9523: number of cleanups
  2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
                   ` (10 preceding siblings ...)
  2024-03-29 10:55 ` [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF Andy Shevchenko
@ 2024-04-04 11:17 ` Linus Walleij
  11 siblings, 0 replies; 16+ messages in thread
From: Linus Walleij @ 2024-04-04 11:17 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: AngeloGioacchino Del Regno, linux-gpio, linux-kernel

On Fri, Mar 29, 2024 at 11:56 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:

> Just noticed that the newly introduced driver has some leftovers or unneeded
> customisation. Hence this series. It may (or may not :-) be sent as an update
> for v6.9 cycle, but TBH there is nothing functional critical.

Patches applied as low urgency fixes, thanks Andy!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF
  2024-03-29 10:55 ` [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF Andy Shevchenko
  2024-04-02  8:34   ` kernel test robot
@ 2024-04-04 11:19   ` Linus Walleij
  2024-04-04 11:32     ` Andy Shevchenko
  1 sibling, 1 reply; 16+ messages in thread
From: Linus Walleij @ 2024-04-04 11:19 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: AngeloGioacchino Del Regno, linux-gpio, linux-kernel

On Fri, Mar 29, 2024 at 11:56 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:

> Driver does not dependent on OF, remove it.
> While here, add missing mod_devicetable.h.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Oh the kbuild complains about this one because the driver uses some
DT-only helpers. How typical. I kept patches 1-10 and dropped this
one.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF
  2024-04-04 11:19   ` Linus Walleij
@ 2024-04-04 11:32     ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2024-04-04 11:32 UTC (permalink / raw)
  To: Linus Walleij; +Cc: AngeloGioacchino Del Regno, linux-gpio, linux-kernel

On Thu, Apr 4, 2024 at 2:20 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Mar 29, 2024 at 11:56 AM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
>
> > Driver does not dependent on OF, remove it.
> > While here, add missing mod_devicetable.h.
> >
> > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> Oh the kbuild complains about this one because the driver uses some
> DT-only helpers. How typical. I kept patches 1-10 and dropped this
> one.

Thanks, you beat me to it, I was wanting to ask you to do exactly this.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-04-04 11:33 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29 10:55 [PATCH v2 00/11] aw9523: number of cleanups Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 01/11] pinctrl: aw9523: Destroy mutex on ->remove() Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 02/11] pinctrl: aw9523: Use correct error code for not supported functionality Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 03/11] pinctrl: aw9523: Always try both ports in aw9523_gpio_set_multiple() Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 04/11] pinctrl: aw9523: Make use of struct pinfunction and PINCTRL_PINFUNCTION() Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 05/11] pinctrl: aw9523: Use temporary variable for HW IRQ number Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 06/11] pinctrl: aw9523: Get rid of redundant ' & U8_MAX' pieces Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 07/11] pinctrl: aw9523: Remove unused irqchip field in struct aw9523_irq Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 08/11] pinctrl: aw9523: Make use of dev_err_probe() Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 09/11] pinctrl: aw9523: Sort headers and group pinctrl/* Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 10/11] pinctrl: aw9523: Fix indentation in a few places Andy Shevchenko
2024-03-29 10:55 ` [PATCH v2 11/11] pinctrl: aw9523: Remove redundant dependency to OF Andy Shevchenko
2024-04-02  8:34   ` kernel test robot
2024-04-04 11:19   ` Linus Walleij
2024-04-04 11:32     ` Andy Shevchenko
2024-04-04 11:17 ` [PATCH v2 00/11] aw9523: number of cleanups Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox