* [PATCH 0/2] iio: proximity: vcnl3020: make vcnl3020_property const
@ 2025-06-28 18:23 David Lechner
2025-06-28 18:23 ` [PATCH 1/2] iio: proximity: vcnl3020: pass struct vcnl3020_property by pointer David Lechner
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David Lechner @ 2025-06-28 18:23 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, David Lechner
We can make const struct vcnl3020_property vcnl3020_led_current_property
const since it is read-only data. For this to really be useful, we also
have another change to pass this struct by pointer instead of by value.
---
David Lechner (2):
iio: proximity: vcnl3020: pass struct vcnl3020_property by pointer
iio: proximity: vcnl3020: make vcnl3020_property const
drivers/iio/proximity/vcnl3020.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
---
base-commit: 14071b9cf2d751ff9bc8b5e43fa94fbf08aceea1
change-id: 20250628-iio-const-data-25-452e9458133b
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] iio: proximity: vcnl3020: pass struct vcnl3020_property by pointer
2025-06-28 18:23 [PATCH 0/2] iio: proximity: vcnl3020: make vcnl3020_property const David Lechner
@ 2025-06-28 18:23 ` David Lechner
2025-06-28 18:23 ` [PATCH 2/2] iio: proximity: vcnl3020: make vcnl3020_property const David Lechner
2025-06-29 17:22 ` [PATCH 0/2] " Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: David Lechner @ 2025-06-28 18:23 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, David Lechner
Pass struct vcnl3020_property by pointer instead of by value to avoid
copying the entire struct.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/proximity/vcnl3020.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/proximity/vcnl3020.c b/drivers/iio/proximity/vcnl3020.c
index 31e77d9e0c90e503e5e337f1ae7f17587624a785..234bdad543cc25e59ace336d2870356b9521f8c8 100644
--- a/drivers/iio/proximity/vcnl3020.c
+++ b/drivers/iio/proximity/vcnl3020.c
@@ -109,22 +109,22 @@ static struct vcnl3020_property vcnl3020_led_current_property = {
};
static int vcnl3020_get_and_apply_property(struct vcnl3020_data *data,
- struct vcnl3020_property prop)
+ struct vcnl3020_property *prop)
{
int rc;
u32 val;
- rc = device_property_read_u32(data->dev, prop.name, &val);
+ rc = device_property_read_u32(data->dev, prop->name, &val);
if (rc)
return 0;
- if (prop.conversion_func)
- prop.conversion_func(&val);
+ if (prop->conversion_func)
+ prop->conversion_func(&val);
- rc = regmap_write(data->regmap, prop.reg, val);
+ rc = regmap_write(data->regmap, prop->reg, val);
if (rc) {
dev_err(data->dev, "Error (%d) setting property (%s)\n",
- rc, prop.name);
+ rc, prop->name);
}
return rc;
@@ -153,7 +153,7 @@ static int vcnl3020_init(struct vcnl3020_data *data)
mutex_init(&data->lock);
return vcnl3020_get_and_apply_property(data,
- vcnl3020_led_current_property);
+ &vcnl3020_led_current_property);
};
static bool vcnl3020_is_in_periodic_mode(struct vcnl3020_data *data)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] iio: proximity: vcnl3020: make vcnl3020_property const
2025-06-28 18:23 [PATCH 0/2] iio: proximity: vcnl3020: make vcnl3020_property const David Lechner
2025-06-28 18:23 ` [PATCH 1/2] iio: proximity: vcnl3020: pass struct vcnl3020_property by pointer David Lechner
@ 2025-06-28 18:23 ` David Lechner
2025-06-29 17:22 ` [PATCH 0/2] " Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: David Lechner @ 2025-06-28 18:23 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, David Lechner
Add const qualifier to struct vcnl3020_property
vcnl3020_led_current_property. This is read-only data so it can be made
const.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/proximity/vcnl3020.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/proximity/vcnl3020.c b/drivers/iio/proximity/vcnl3020.c
index 234bdad543cc25e59ace336d2870356b9521f8c8..7f417372566a69e43a62accc1ce0cc1586bd8054 100644
--- a/drivers/iio/proximity/vcnl3020.c
+++ b/drivers/iio/proximity/vcnl3020.c
@@ -102,14 +102,14 @@ static u32 microamp_to_reg(u32 *val)
return *val /= 10000;
};
-static struct vcnl3020_property vcnl3020_led_current_property = {
+static const struct vcnl3020_property vcnl3020_led_current_property = {
.name = "vishay,led-current-microamp",
.reg = VCNL_LED_CURRENT,
.conversion_func = microamp_to_reg,
};
static int vcnl3020_get_and_apply_property(struct vcnl3020_data *data,
- struct vcnl3020_property *prop)
+ const struct vcnl3020_property *prop)
{
int rc;
u32 val;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] iio: proximity: vcnl3020: make vcnl3020_property const
2025-06-28 18:23 [PATCH 0/2] iio: proximity: vcnl3020: make vcnl3020_property const David Lechner
2025-06-28 18:23 ` [PATCH 1/2] iio: proximity: vcnl3020: pass struct vcnl3020_property by pointer David Lechner
2025-06-28 18:23 ` [PATCH 2/2] iio: proximity: vcnl3020: make vcnl3020_property const David Lechner
@ 2025-06-29 17:22 ` Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2025-06-29 17:22 UTC (permalink / raw)
To: David Lechner; +Cc: Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel
On Sat, 28 Jun 2025 13:23:47 -0500
David Lechner <dlechner@baylibre.com> wrote:
> We can make const struct vcnl3020_property vcnl3020_led_current_property
> const since it is read-only data. For this to really be useful, we also
> have another change to pass this struct by pointer instead of by value.
>
Applied to the testing branch of iio.git.
Thanks,
Jonathan
> ---
> David Lechner (2):
> iio: proximity: vcnl3020: pass struct vcnl3020_property by pointer
> iio: proximity: vcnl3020: make vcnl3020_property const
>
> drivers/iio/proximity/vcnl3020.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
> ---
> base-commit: 14071b9cf2d751ff9bc8b5e43fa94fbf08aceea1
> change-id: 20250628-iio-const-data-25-452e9458133b
>
> Best regards,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-29 17:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-28 18:23 [PATCH 0/2] iio: proximity: vcnl3020: make vcnl3020_property const David Lechner
2025-06-28 18:23 ` [PATCH 1/2] iio: proximity: vcnl3020: pass struct vcnl3020_property by pointer David Lechner
2025-06-28 18:23 ` [PATCH 2/2] iio: proximity: vcnl3020: make vcnl3020_property const David Lechner
2025-06-29 17:22 ` [PATCH 0/2] " Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).