* [PATCH v3 1/4] dt-bindings: media: ti,ds90ub953: Add new range for remote GPIO data
2025-09-16 9:43 [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
@ 2025-09-16 9:43 ` Guoniu Zhou
2025-09-16 14:23 ` Frank Li
2025-09-16 9:43 ` [PATCH v3 2/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Guoniu Zhou @ 2025-09-16 9:43 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Frank Li
Cc: linux-media, devicetree, linux-kernel, imx, Guoniu Zhou
The DS90UB953 supports four pins, GPIO0 through GPIO3. When enabled as an
output, it can be programed to output local data or remote data coming
from the remote compatible deserializer.
Make a different GPIO range for remote ones.
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
index 2e129bf573b79e0ca8f25b4ec5fc6ea76c50abd7..234276a8738a7fbe9fadad62f12366697da97b11 100644
--- a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
@@ -20,9 +20,13 @@ properties:
'#gpio-cells':
const: 2
- description:
+ description: |
First cell is the GPIO pin number, second cell is the flags. The GPIO pin
- number must be in range of [0, 3].
+ number must be in range of [0, 3] when enabled as an input.
+
+ If enabled as an output, the GPIO pin number must be in range of
+ [0, 7] and [0, 3] for local GPIO data, [4, 7] for GPIO data coming
+ from remote compatible deserializer.
gpio-controller: true
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v3 1/4] dt-bindings: media: ti,ds90ub953: Add new range for remote GPIO data
2025-09-16 9:43 ` [PATCH v3 1/4] dt-bindings: media: ti,ds90ub953: Add new range for remote GPIO data Guoniu Zhou
@ 2025-09-16 14:23 ` Frank Li
0 siblings, 0 replies; 8+ messages in thread
From: Frank Li @ 2025-09-16 14:23 UTC (permalink / raw)
To: Guoniu Zhou
Cc: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-media, devicetree,
linux-kernel, imx
On Tue, Sep 16, 2025 at 05:43:43PM +0800, Guoniu Zhou wrote:
> The DS90UB953 supports four pins, GPIO0 through GPIO3. When enabled as an
> output, it can be programed to output local data or remote data coming
> from the remote compatible deserializer.
>
> Make a different GPIO range for remote ones.
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
> Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
> index 2e129bf573b79e0ca8f25b4ec5fc6ea76c50abd7..234276a8738a7fbe9fadad62f12366697da97b11 100644
> --- a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
> @@ -20,9 +20,13 @@ properties:
>
> '#gpio-cells':
> const: 2
> - description:
> + description: |
suppose should be >
The second style is folded which is indicated by ">" character. In addition
to maintaining line breaks on double line breaks, the folded style also
maintains leading whitespace beyond indentation of the first line. The line
breaks on indented lines are also maintained.
Frank
> First cell is the GPIO pin number, second cell is the flags. The GPIO pin
> - number must be in range of [0, 3].
> + number must be in range of [0, 3] when enabled as an input.
> +
> + If enabled as an output, the GPIO pin number must be in range of
> + [0, 7] and [0, 3] for local GPIO data, [4, 7] for GPIO data coming
> + from remote compatible deserializer.
>
> gpio-controller: true
>
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 2/4] media: i2c: ds90ub953: Add back channel GPIO support
2025-09-16 9:43 [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
2025-09-16 9:43 ` [PATCH v3 1/4] dt-bindings: media: ti,ds90ub953: Add new range for remote GPIO data Guoniu Zhou
@ 2025-09-16 9:43 ` Guoniu Zhou
2025-09-16 9:43 ` [PATCH v3 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Guoniu Zhou @ 2025-09-16 9:43 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Frank Li
Cc: linux-media, devicetree, linux-kernel, imx, Guoniu Zhou
The ds90ub953 supports GPIO0 through GPIO3. When enabled as an output,
each GPIO pin can be programed to output remote data coming from the
compatible deserializer using the register LOCAL_GPIO_DATA[7:4] field.
Make GPIO range from 0-3 to 0-7 to support this case. 0-3 for local GPIO
and 4-7 for remote GPIO data.
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
drivers/media/i2c/ds90ub953.c | 47 +++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 11 deletions(-)
diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index e3fc9d66970a762d284955f14db48d7105b4b8c4..c6b77e4982a3449896e564a288ff1562cb1dcb79 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -32,7 +32,9 @@
#define UB953_PAD_SINK 0
#define UB953_PAD_SOURCE 1
-#define UB953_NUM_GPIOS 4
+#define UB953_NUM_LOCAL_GPIOS 4
+#define UB953_NUM_REMOTE_GPIOS 4
+#define UB953_NUM_GPIOS (UB953_NUM_LOCAL_GPIOS + UB953_NUM_REMOTE_GPIOS)
#define UB953_DEFAULT_CLKOUT_RATE 25000000UL
@@ -268,7 +270,7 @@ static int ub953_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
if (ret)
return ret;
- if (v & UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(offset))
+ if (v & UB953_REG_GPIO_INPUT_CTRL_INPUT_EN((offset % UB953_NUM_LOCAL_GPIOS)))
return GPIO_LINE_DIRECTION_IN;
else
return GPIO_LINE_DIRECTION_OUT;
@@ -277,6 +279,12 @@ static int ub953_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
static int ub953_gpio_direction_in(struct gpio_chip *gc, unsigned int offset)
{
struct ub953_data *priv = gpiochip_get_data(gc);
+ struct device *dev = &priv->client->dev;
+
+ if (offset > UB953_NUM_LOCAL_GPIOS) {
+ dev_err(dev, "GPIO%u can't be programed as input\n", offset);
+ return -EINVAL;
+ }
return regmap_update_bits(priv->regmap, UB953_REG_GPIO_INPUT_CTRL,
UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(offset) |
@@ -288,10 +296,14 @@ static int ub953_gpio_direction_out(struct gpio_chip *gc, unsigned int offset,
int value)
{
struct ub953_data *priv = gpiochip_get_data(gc);
+ unsigned int pin;
int ret;
+ pin = offset % UB953_NUM_LOCAL_GPIOS;
+
ret = regmap_update_bits(priv->regmap, UB953_REG_LOCAL_GPIO_DATA,
- UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset),
+ UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(pin) |
+ UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(pin),
value ? UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset) :
0);
@@ -299,9 +311,9 @@ static int ub953_gpio_direction_out(struct gpio_chip *gc, unsigned int offset,
return ret;
return regmap_update_bits(priv->regmap, UB953_REG_GPIO_INPUT_CTRL,
- UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(offset) |
- UB953_REG_GPIO_INPUT_CTRL_OUT_EN(offset),
- UB953_REG_GPIO_INPUT_CTRL_OUT_EN(offset));
+ UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(pin) |
+ UB953_REG_GPIO_INPUT_CTRL_OUT_EN(pin),
+ UB953_REG_GPIO_INPUT_CTRL_OUT_EN(pin));
}
static int ub953_gpio_get(struct gpio_chip *gc, unsigned int offset)
@@ -314,12 +326,19 @@ static int ub953_gpio_get(struct gpio_chip *gc, unsigned int offset)
if (ret)
return ret;
- return !!(v & UB953_REG_GPIO_PIN_STS_GPIO_STS(offset));
+ return !!(v & UB953_REG_GPIO_PIN_STS_GPIO_STS((offset % UB953_NUM_LOCAL_GPIOS)));
}
static int ub953_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
{
struct ub953_data *priv = gpiochip_get_data(gc);
+ struct device *dev = &priv->client->dev;
+
+ if (offset > UB953_NUM_LOCAL_GPIOS) {
+ dev_err(dev, "GPIO%u be programed to output remote data\n",
+ offset % UB953_NUM_LOCAL_GPIOS);
+ return -EINVAL;
+ }
return regmap_update_bits(priv->regmap, UB953_REG_LOCAL_GPIO_DATA,
UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset),
@@ -330,6 +349,9 @@ static int ub953_gpio_of_xlate(struct gpio_chip *gc,
const struct of_phandle_args *gpiospec,
u32 *flags)
{
+ if (gpiospec->args[0] >= UB953_NUM_GPIOS)
+ return -EINVAL;
+
if (flags)
*flags = gpiospec->args[1];
@@ -633,14 +655,17 @@ static int ub953_log_status(struct v4l2_subdev *sd)
return ret;
for (i = 0; i < UB953_NUM_GPIOS; i++) {
+ unsigned int pin = i % UB953_NUM_LOCAL_GPIOS;
+ bool rmt = (i >= UB953_NUM_LOCAL_GPIOS) ? true : false;
+
dev_info(dev,
"GPIO%u: remote: %u is_input: %u is_output: %u val: %u sts: %u\n",
i,
- !!(gpio_local_data & UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(i)),
- !!(gpio_input_ctrl & UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(i)),
- !!(gpio_input_ctrl & UB953_REG_GPIO_INPUT_CTRL_OUT_EN(i)),
+ rmt ? !!(gpio_local_data & UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(pin)) : 0,
+ rmt ? 0 : !!(gpio_input_ctrl & UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(pin)),
+ rmt ? 1 : !!(gpio_input_ctrl & UB953_REG_GPIO_INPUT_CTRL_OUT_EN(pin)),
!!(gpio_local_data & UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(i)),
- !!(gpio_pin_sts & UB953_REG_GPIO_PIN_STS_GPIO_STS(i)));
+ !!(gpio_pin_sts & UB953_REG_GPIO_PIN_STS_GPIO_STS(pin)));
}
return 0;
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v3 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code
2025-09-16 9:43 [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
2025-09-16 9:43 ` [PATCH v3 1/4] dt-bindings: media: ti,ds90ub953: Add new range for remote GPIO data Guoniu Zhou
2025-09-16 9:43 ` [PATCH v3 2/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
@ 2025-09-16 9:43 ` Guoniu Zhou
2025-09-16 14:26 ` Frank Li
2025-09-16 9:43 ` [PATCH v3 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
2025-10-23 8:41 ` [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support G.N. Zhou
4 siblings, 1 reply; 8+ messages in thread
From: Guoniu Zhou @ 2025-09-16 9:43 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Frank Li
Cc: linux-media, devicetree, linux-kernel, imx, Guoniu Zhou
Use devm_mutex_init() to simplify the code. No functional change.
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
drivers/media/i2c/ds90ub953.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index c6b77e4982a3449896e564a288ff1562cb1dcb79..47e7c0a5aae7737182e6a1f2797be01e7ecc8142 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -1342,7 +1342,9 @@ static int ub953_probe(struct i2c_client *client)
if (!priv->plat_data)
return dev_err_probe(dev, -ENODEV, "Platform data missing\n");
- mutex_init(&priv->reg_lock);
+ ret = devm_mutex_init(dev, &priv->reg_lock);
+ if (ret)
+ return ret;
/*
* Initialize to invalid values so that the first reg writes will
@@ -1351,32 +1353,26 @@ static int ub953_probe(struct i2c_client *client)
priv->current_indirect_target = 0xff;
priv->regmap = devm_regmap_init_i2c(client, &ub953_regmap_config);
- if (IS_ERR(priv->regmap)) {
- ret = PTR_ERR(priv->regmap);
- dev_err_probe(dev, ret, "Failed to init regmap\n");
- goto err_mutex_destroy;
- }
+ if (IS_ERR(priv->regmap))
+ return dev_err_probe(dev, PTR_ERR(priv->regmap),
+ "Failed to init regmap\n");
priv->clkin = devm_clk_get_optional(dev, "clkin");
- if (IS_ERR(priv->clkin)) {
- ret = PTR_ERR(priv->clkin);
- dev_err_probe(dev, ret, "failed to parse 'clkin'\n");
- goto err_mutex_destroy;
- }
+ if (IS_ERR(priv->clkin))
+ return dev_err_probe(dev, PTR_ERR(priv->clkin),
+ "Failed to parse 'clkin'\n");
ret = ub953_parse_dt(priv);
if (ret)
- goto err_mutex_destroy;
+ return ret;
ret = ub953_hw_init(priv);
if (ret)
- goto err_mutex_destroy;
+ return ret;
ret = ub953_gpiochip_probe(priv);
- if (ret) {
- dev_err_probe(dev, ret, "Failed to init gpiochip\n");
- goto err_mutex_destroy;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to init gpiochip\n");
ret = ub953_register_clkout(priv);
if (ret) {
@@ -1400,8 +1396,6 @@ static int ub953_probe(struct i2c_client *client)
ub953_subdev_uninit(priv);
err_gpiochip_remove:
ub953_gpiochip_remove(priv);
-err_mutex_destroy:
- mutex_destroy(&priv->reg_lock);
return ret;
}
@@ -1416,7 +1410,6 @@ static void ub953_remove(struct i2c_client *client)
ub953_subdev_uninit(priv);
ub953_gpiochip_remove(priv);
- mutex_destroy(&priv->reg_lock);
}
static const struct ub953_hw_data ds90ub953_hw = {
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v3 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code
2025-09-16 9:43 ` [PATCH v3 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
@ 2025-09-16 14:26 ` Frank Li
0 siblings, 0 replies; 8+ messages in thread
From: Frank Li @ 2025-09-16 14:26 UTC (permalink / raw)
To: Guoniu Zhou
Cc: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-media, devicetree,
linux-kernel, imx
On Tue, Sep 16, 2025 at 05:43:45PM +0800, Guoniu Zhou wrote:
> Use devm_mutex_init() to simplify the code. No functional change.
Use devm_mutex_init() and dev_err_probe() to ...
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Frank
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
> drivers/media/i2c/ds90ub953.c | 33 +++++++++++++--------------------
> 1 file changed, 13 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
> index c6b77e4982a3449896e564a288ff1562cb1dcb79..47e7c0a5aae7737182e6a1f2797be01e7ecc8142 100644
> --- a/drivers/media/i2c/ds90ub953.c
> +++ b/drivers/media/i2c/ds90ub953.c
> @@ -1342,7 +1342,9 @@ static int ub953_probe(struct i2c_client *client)
> if (!priv->plat_data)
> return dev_err_probe(dev, -ENODEV, "Platform data missing\n");
>
> - mutex_init(&priv->reg_lock);
> + ret = devm_mutex_init(dev, &priv->reg_lock);
> + if (ret)
> + return ret;
>
> /*
> * Initialize to invalid values so that the first reg writes will
> @@ -1351,32 +1353,26 @@ static int ub953_probe(struct i2c_client *client)
> priv->current_indirect_target = 0xff;
>
> priv->regmap = devm_regmap_init_i2c(client, &ub953_regmap_config);
> - if (IS_ERR(priv->regmap)) {
> - ret = PTR_ERR(priv->regmap);
> - dev_err_probe(dev, ret, "Failed to init regmap\n");
> - goto err_mutex_destroy;
> - }
> + if (IS_ERR(priv->regmap))
> + return dev_err_probe(dev, PTR_ERR(priv->regmap),
> + "Failed to init regmap\n");
>
> priv->clkin = devm_clk_get_optional(dev, "clkin");
> - if (IS_ERR(priv->clkin)) {
> - ret = PTR_ERR(priv->clkin);
> - dev_err_probe(dev, ret, "failed to parse 'clkin'\n");
> - goto err_mutex_destroy;
> - }
> + if (IS_ERR(priv->clkin))
> + return dev_err_probe(dev, PTR_ERR(priv->clkin),
> + "Failed to parse 'clkin'\n");
>
> ret = ub953_parse_dt(priv);
> if (ret)
> - goto err_mutex_destroy;
> + return ret;
>
> ret = ub953_hw_init(priv);
> if (ret)
> - goto err_mutex_destroy;
> + return ret;
>
> ret = ub953_gpiochip_probe(priv);
> - if (ret) {
> - dev_err_probe(dev, ret, "Failed to init gpiochip\n");
> - goto err_mutex_destroy;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to init gpiochip\n");
>
> ret = ub953_register_clkout(priv);
> if (ret) {
> @@ -1400,8 +1396,6 @@ static int ub953_probe(struct i2c_client *client)
> ub953_subdev_uninit(priv);
> err_gpiochip_remove:
> ub953_gpiochip_remove(priv);
> -err_mutex_destroy:
> - mutex_destroy(&priv->reg_lock);
>
> return ret;
> }
> @@ -1416,7 +1410,6 @@ static void ub953_remove(struct i2c_client *client)
> ub953_subdev_uninit(priv);
>
> ub953_gpiochip_remove(priv);
> - mutex_destroy(&priv->reg_lock);
> }
>
> static const struct ub953_hw_data ds90ub953_hw = {
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 4/4] media: i2c: ds90ub953: use guard() to simplify code
2025-09-16 9:43 [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
` (2 preceding siblings ...)
2025-09-16 9:43 ` [PATCH v3 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
@ 2025-09-16 9:43 ` Guoniu Zhou
2025-10-23 8:41 ` [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support G.N. Zhou
4 siblings, 0 replies; 8+ messages in thread
From: Guoniu Zhou @ 2025-09-16 9:43 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Frank Li
Cc: linux-media, devicetree, linux-kernel, imx, Guoniu Zhou
Use guard() to simplify mutex locking. No functional change.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
drivers/media/i2c/ds90ub953.c | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index 47e7c0a5aae7737182e6a1f2797be01e7ecc8142..19cb353bcf3eb62d30e73b2f157f2a5838db523e 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -113,20 +113,18 @@ static int ub953_read(struct ub953_data *priv, u8 reg, u8 *val, int *err)
if (err && *err)
return *err;
- mutex_lock(&priv->reg_lock);
+ guard(mutex)(&priv->reg_lock);
ret = regmap_read(priv->regmap, reg, &v);
if (ret) {
dev_err(&priv->client->dev, "Cannot read register 0x%02x: %d\n",
reg, ret);
- goto out_unlock;
+ goto err;
}
*val = v;
-out_unlock:
- mutex_unlock(&priv->reg_lock);
-
+err:
if (ret && err)
*err = ret;
@@ -140,15 +138,13 @@ static int ub953_write(struct ub953_data *priv, u8 reg, u8 val, int *err)
if (err && *err)
return *err;
- mutex_lock(&priv->reg_lock);
+ guard(mutex)(&priv->reg_lock);
ret = regmap_write(priv->regmap, reg, val);
if (ret)
dev_err(&priv->client->dev,
"Cannot write register 0x%02x: %d\n", reg, ret);
- mutex_unlock(&priv->reg_lock);
-
if (ret && err)
*err = ret;
@@ -185,18 +181,18 @@ static int ub953_read_ind(struct ub953_data *priv, u8 block, u8 reg, u8 *val,
if (err && *err)
return *err;
- mutex_lock(&priv->reg_lock);
+ guard(mutex)(&priv->reg_lock);
ret = ub953_select_ind_reg_block(priv, block);
if (ret)
- goto out_unlock;
+ goto err;
ret = regmap_write(priv->regmap, UB953_REG_IND_ACC_ADDR, reg);
if (ret) {
dev_err(&priv->client->dev,
"Write to IND_ACC_ADDR failed when reading %u:0x%02x: %d\n",
block, reg, ret);
- goto out_unlock;
+ goto err;
}
ret = regmap_read(priv->regmap, UB953_REG_IND_ACC_DATA, &v);
@@ -204,14 +200,12 @@ static int ub953_read_ind(struct ub953_data *priv, u8 block, u8 reg, u8 *val,
dev_err(&priv->client->dev,
"Write to IND_ACC_DATA failed when reading %u:0x%02x: %d\n",
block, reg, ret);
- goto out_unlock;
+ goto err;
}
*val = v;
-out_unlock:
- mutex_unlock(&priv->reg_lock);
-
+err:
if (ret && err)
*err = ret;
@@ -227,18 +221,18 @@ static int ub953_write_ind(struct ub953_data *priv, u8 block, u8 reg, u8 val,
if (err && *err)
return *err;
- mutex_lock(&priv->reg_lock);
+ guard(mutex)(&priv->reg_lock);
ret = ub953_select_ind_reg_block(priv, block);
if (ret)
- goto out_unlock;
+ goto err;
ret = regmap_write(priv->regmap, UB953_REG_IND_ACC_ADDR, reg);
if (ret) {
dev_err(&priv->client->dev,
"Write to IND_ACC_ADDR failed when writing %u:0x%02x: %d\n",
block, reg, ret);
- goto out_unlock;
+ goto err;
}
ret = regmap_write(priv->regmap, UB953_REG_IND_ACC_DATA, val);
@@ -248,9 +242,7 @@ static int ub953_write_ind(struct ub953_data *priv, u8 block, u8 reg, u8 val,
block, reg, ret);
}
-out_unlock:
- mutex_unlock(&priv->reg_lock);
-
+err:
if (ret && err)
*err = ret;
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* RE: [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support
2025-09-16 9:43 [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
` (3 preceding siblings ...)
2025-09-16 9:43 ` [PATCH v3 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
@ 2025-10-23 8:41 ` G.N. Zhou
4 siblings, 0 replies; 8+ messages in thread
From: G.N. Zhou @ 2025-10-23 8:41 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Frank Li
Cc: linux-media, devicetree, linux-kernel, imx
Hi Tomi,
Could you please help to review the patches? Your input will be appreciated.
Best Regards
G.N Zhou
> -----Original Message-----
> From: G.N. Zhou
> Sent: Tuesday, September 16, 2025 5:44 PM
> To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>; Mauro Carvalho
> Chehab <mchehab@kernel.org>; Rob Herring <robh@kernel.org>; Krzysztof
> Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org>; Frank
> Li <frank.li@nxp.com>
> Cc: linux-media@vger.kernel.org; devicetree@vger.kernel.org; linux-
> kernel@vger.kernel.org; imx@lists.linux.dev; G.N. Zhou
> <guoniu.zhou@nxp.com>
> Subject: [PATCH v3 0/4] media: i2c: ds90ub953: Add back channel GPIO
> support
>
> Add back channel GPIO support.
> dt-bindings: media: ti,ds90ub953: Add new range for remote GPIO data
> media: i2c: ds90ub953: Add back channel GPIO support
>
> Use helper macro to simplify code.
> media: i2c: ds90ub953: use devm_mutex_init() to simplify code
> media: i2c: ds90ub953: use guard() to simplify code
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
> Changes in v3:
> - Make GPIO range from 0-3 to 0-7 to support GPIO data from remote
> compatible deserializer suggested by Rob instead of adding third
> cell for GPIO controller.
> - Update driver to expand GPIO range.
> - Link to v2: https://lore.kernel.org/r/20250911-ds90ub953-v2-0-
> 03ee76eb6b59@nxp.com
>
> Changes in v2:
> - Remove new property ti,gpio-data added in patch 1.
> - Add third cell for GPIO controller to select GPIO output source.
> - Move PTR_ERR() in dev_err_probe();
> - Link to v1: https://lore.kernel.org/r/20250910-ds90ub953-v1-0-
> a7813ffbdf11@nxp.com
>
> ---
> Guoniu Zhou (4):
> dt-bindings: media: ti,ds90ub953: Add new range for remote GPIO data
> media: i2c: ds90ub953: Add back channel GPIO support
> media: i2c: ds90ub953: use devm_mutex_init() to simplify code
> media: i2c: ds90ub953: use guard() to simplify code
>
> .../bindings/media/i2c/ti,ds90ub953.yaml | 8 +-
> drivers/media/i2c/ds90ub953.c | 114 +++++++++++----------
> 2 files changed, 68 insertions(+), 54 deletions(-)
> ---
> base-commit: 34837c444cd42236b2b43ce871f30d83776a3431
> change-id: 20250901-ds90ub953-168628c53a00
>
> Best regards,
> --
> Guoniu Zhou <guoniu.zhou@nxp.com>
^ permalink raw reply [flat|nested] 8+ messages in thread