iio: light: stk3310: support powering off during suspend
Subsystems (3)
v3 cover iio: light: stk3310: support powering off during suspend
In the Pine64 PinePhone, the stk3310 chip is powered by a regulator that is disabled at system boot and can be shut off during suspend. To ensure that the chip properly initializes, both after boot and suspend, we need to manage this regulator.
Additionally if the chip is shut off in suspend, we need to make sure that it gets reinitialized with the same parameters after resume.
Major changes in v3:
- Use bulk regulators instead of two individual ones
- Replace stk3310_remove with devm callbacks
- Hopefully I haven't missed anything, it's been a while since I worked on this patch, and I didn't take good enough notes
Major changes in v2:
- Add handling of the IR LED. I was hesitant to include this as it is the same as pull-up regulator for the i2c bus on the hardware I have, so I can't test it well. I think leaving it out is more likely to cause issues than including it.
- Convert stk3310 to use dev_err_probe for errors.
- Always enable / disable regulators and rely on dummy devices if they're not specified.
- more listed in individual patches
Aren Moynihan (5):
dt-bindings: iio: light: stk33xx: add vdd and leda regulators
iio: light: stk3310: handle all remove logic with devm callbacks
iio: light: stk3310: Implement vdd and leda supplies
iio: light: stk3310: use dev_err_probe where possible
iio: light: stk3310: log error if reading the chip id fails
Ondrej Jirman (1):
arm64: dts: allwinner: pinephone: Add power supplies to stk3311
.../bindings/iio/light/stk33xx.yaml | 4 + .../dts/allwinner/sun50i-a64-pinephone.dtsi | 2 + drivers/iio/light/stk3310.c | 156 +++++++++++++----- 3 files changed, 118 insertions(+), 44 deletions(-)
Signature · 1 line
2.47.0
PATCH v3 1/6 dt-bindings: iio: light: stk33xx: add vdd and leda regulators
stk3310 and stk3311 are typically connected to power supplies for the chip (vdd) and the infrared LED (leda). Add properties so we can power these up / down appropriately.
---
Notes:
Changes in v2:
- add leda-supply
- add supplies to examples
Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/iio/light/stk33xx.yaml +4 -0
@@ -34,6 +34,8 @@ properties: interrupts: maxItems: 1 + vdd-supply: true + leda-supply: true proximity-near-level: true required:
@@ -57,6 +59,8 @@ examples: proximity-near-level = <25>; interrupt-parent = <&gpio1>; interrupts = <5 IRQ_TYPE_LEVEL_LOW>; + vdd-supply = <&vdd_regulator>; + leda-supply = <&led_regulator>; }; }; ...
Signature · 1 line
2.47.0
PATCH v3 2/6 iio: light: stk3310: handle all remove logic with devm callbacks
In reply to Aren MoynihanUsing devm callbacks helps to make the ordering of probe / remove operations easier to reason about and removes some duplicate code between the probe error path and driver remove.
---
Notes:
Added in v3
drivers/iio/light/stk3310.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/iio/light/stk3310.c +19 -16
@@ -484,6 +484,17 @@ static int stk3310_set_state(struct stk3310_data *data, u8 state)return ret; } +static void stk3310_set_state_disable (void *private) +{ +int ret; +struct stk3310_data *data = private; +struct device *dev = &data->client->dev; + + ret =stk3310_set_state (data,STK3310_STATE_STANDBY ); +if (ret) +dev_err (dev,"failed to set state to standby: %d\n" , ret); +} +static int stk3310_init (struct iio_dev *indio_dev) {int ret;
@@ -507,6 +518,11 @@ static int stk3310_init(struct iio_dev *indio_dev)return ret; } + ret =devm_add_action_or_reset (&client->dev, stk3310_set_state_disable, data); +if (ret) +return dev_err_probe (&client->dev, ret, +"failed to register cleanup function\n" ); +/* Enable PS interrupts */ ret =regmap_field_write (data->reg_int_ps,STK3310_PSINT_EN );if (ret <0 )
@@ -650,29 +666,17 @@ static int stk3310_probe(struct i2c_client *client)if (ret <0 ) {dev_err (&client->dev,"request irq %d failed\n" , client->irq); - goto err_standby; +return ret; } } - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (&client->dev, indio_dev);if (ret <0 ) {dev_err (&client->dev,"device_register failed\n" ); - goto err_standby; +return ret; }return 0 ; - -err_standby: -stk3310_set_state (data,STK3310_STATE_STANDBY ); -return ret; -} - -static void stk3310_remove (struct i2c_client *client) -{ -struct iio_dev *indio_dev =i2c_get_clientdata (client); - -iio_device_unregister (indio_dev); -stk3310_set_state (iio_priv (indio_dev),STK3310_STATE_STANDBY ); }static int stk3310_suspend (struct device *dev)
@@ -736,7 +740,6 @@ static struct i2c_driver stk3310_driver = { .acpi_match_table = stk3310_acpi_id, }, .probe = stk3310_probe, - .remove = stk3310_remove, .id_table = stk3310_i2c_id, };
Signature · 1 line
2.47.0
PATCH v3 3/6 iio: light: stk3310: Implement vdd and leda supplies
In reply to Aren MoynihanThe vdd and leda supplies must be powered on for the chip to function and can be powered off during system suspend.
---
Notes:
I'm not sure what the proper way to handle attribution for this patch is. It was origionally based on a patch by Ondrej Jirman[1], but I have rewritten a large portion if it. I have included a Co-developed-by tag to indicate this, but haven't sent him this patch, so I'm not sure what to do about a Signed-off-by.
1: https://codeberg.org/megi/linux/commit/a933aff8b7a0e6e3c9cf1d832dcba07022bbfa82
Changes in v3:
- use bulk regulators instead of two individual ones
- handle cleanup using devm callbacks instead of the remove function
Changes in v2:
- always enable / disable regulators and rely on a dummy regulator if one isn't specified
- replace usleep_range with fsleep
- reorder includes so iio headers are last
- add missing error handling to resume
drivers/iio/light/stk3310.c | 76 ++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/iio/light/stk3310.c +74 -2
@@ -13,6 +13,8 @@#include <linux/module.h> #include <linux/mod_devicetable.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> +#include <linux/iio/events.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -130,6 +132,7 @@ struct stk3310_data {struct regmap_field *reg_int_ps;struct regmap_field *reg_flag_psint;struct regmap_field *reg_flag_nf; +struct regulator_bulk_data supplies[2 ]; };static const struct iio_event_spec stk3310_events[] = {
@@ -621,6 +624,31 @@ static irqreturn_t stk3310_irq_event_handler(int irq, void *private)return IRQ_HANDLED ; } +static int stk3310_regulators_enable (struct stk3310_data *data) +{ +int ret; + + ret =regulator_bulk_enable (ARRAY_SIZE (data->supplies), data->supplies); +if (ret) +return ret; + +/* we need a short delay to allow the chip time to power on */ +fsleep (1000 ); + +return 0 ; +} + +static void stk3310_regulators_disable (void *private) +{ +int ret; +struct stk3310_data *data = private; +struct device *dev = &data->client->dev; + + ret =regulator_bulk_disable (ARRAY_SIZE (data->supplies), data->supplies); +if (ret) +dev_err (dev,"failed to disable regulators: %d\n" , ret); +} +static int stk3310_probe (struct i2c_client *client) {int ret;
@@ -642,6 +670,13 @@ static int stk3310_probe(struct i2c_client *client)mutex_init (&data->lock); + data->supplies[0 ].supply ="vdd" ; + data->supplies[1 ].supply ="leda" ; + ret =devm_regulator_bulk_get (&client->dev,ARRAY_SIZE (data->supplies), + data->supplies); +if (ret) +return dev_err_probe (&client->dev, ret,"get regulators failed\n" ); + ret =stk3310_regmap_init (data);if (ret <0 )return ret;
@@ -652,6 +687,16 @@ static int stk3310_probe(struct i2c_client *client) indio_dev->channels = stk3310_channels; indio_dev->num_channels =ARRAY_SIZE (stk3310_channels); + ret =stk3310_regulators_enable (data); +if (ret) +return dev_err_probe (&client->dev, ret, +"regulator enable failed\n" ); + + ret =devm_add_action_or_reset (&client->dev, stk3310_regulators_disable, data); +if (ret) +return dev_err_probe (&client->dev, ret, +"failed to register regulator cleanup\n" ); + ret =stk3310_init (indio_dev);if (ret <0 )return ret;
@@ -682,18 +727,45 @@ static int stk3310_probe(struct i2c_client *client)static int stk3310_suspend (struct device *dev) {struct stk3310_data *data; +int ret; data =iio_priv (i2c_get_clientdata (to_i2c_client (dev))); -return stk3310_set_state (data,STK3310_STATE_STANDBY ); + ret =stk3310_set_state (data,STK3310_STATE_STANDBY ); +if (ret) +return ret; + +regcache_mark_dirty (data->regmap); + + ret =regulator_bulk_disable (ARRAY_SIZE (data->supplies), data->supplies); +if (ret) { +dev_err (dev,"failed to disable regulators: %d\n" , ret); +return ret; + } + +return 0 ; }static int stk3310_resume (struct device *dev) { -u8 state =0 ;struct stk3310_data *data; +u8 state =0 ; +int ret; data =iio_priv (i2c_get_clientdata (to_i2c_client (dev))); + + ret =stk3310_regulators_enable (data); +if (ret) { +dev_err (dev,"Failed to re-enable regulators: %d" , ret); +return ret; + } + + ret =regcache_sync (data->regmap); +if (ret) { +dev_err (dev,"Failed to restore registers: %d\n" , ret); +return ret; + } +if (data->ps_enabled) state |=STK3310_STATE_EN_PS ;if (data->als_enabled)
Signature · 1 line
2.47.0
Re: [PATCH v3 3/6] iio: light: stk3310: Implement vdd and leda supplies
Quoted 4 lines · Aren Moynihan
The vdd and leda supplies must be powered on for the chip to function and can be powered off during system suspend.
Co-developed-by Ondrej Jirman <[email protected]>
Missing SoB. Please, read Submitting Patches documentation for understanding what has to be done here.
Quoted 1 line
Signed-off-by Aren Moynihan <[email protected]>
...
Quoted 6 lines
Notes:
I'm not sure what the proper way to handle attribution for this patch is. It was origionally based on a patch by Ondrej Jirman[1], but I have rewritten a large portion if it. I have included a Co-developed-by tag to indicate this, but haven't sent him this patch, so I'm not sure what to do about a Signed-off-by.
Ah, seems you already aware of this issue. So, either drop Co-developed-by (and if you wish you may give a credit in a free form inside commit message) or make sure you get his SoB tag.
...
Quoted 1 line
mutex_init(&data->lock);
Somewhere (in the previous patch?) you want to switch to devm_mutex_init().
...
drivers/iio/light/stk3310.c static int stk3310_probe(struct i2c_client *client) · line 698
Quoted 12 lines
drivers/iio/light/stk3310.c +10
-0+ ret =devm_regulator_bulk_get (&client->dev,ARRAY_SIZE (data->supplies), + data->supplies); +if (ret) +return dev_err_probe (&client->dev, ret,"get regulators failed\n" ); +return dev_err_probe (&client->dev, ret, +"regulator enable failed\n" ); + ret =devm_add_action_or_reset (&client->dev, stk3310_regulators_disable, data); +if (ret) +return dev_err_probe (&client->dev, ret, +"failed to register regulator cleanup\n" );
With
struct devuce *dev = &client->dev;
at the top of the function makes these and more lines neater.
...
drivers/iio/light/stk3310.c static int stk3310_probe(struct i2c_client *client) · line 753
Quoted 6 lines
static int
stk3310_resume(struct device *dev)
{drivers/iio/light/stk3310.c +2
-1-u8 state =0 ;struct stk3310_data *data; +u8 state =0 ; +int ret;
While changing to RCT order here, it seems you have inconsistent approach elsewhere (in your own patches!). Please, be consistent with chosen style.
Quoted 1 line
data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 3/6] iio: light: stk3310: Implement vdd and leda supplies
Quoted 20 lines · Andy Shevchenko
Quoted 4 lines · Aren Moynihan
The vdd and leda supplies must be powered on for the chip to function and can be powered off during system suspend.
Co-developed-by Ondrej Jirman <[email protected]>Missing SoB. Please, read Submitting Patches documentation for understanding what has to be done here.
Quoted 1 line
Signed-off-by Aren Moynihan <[email protected]>...
Quoted 6 lines
Notes:
I'm not sure what the proper way to handle attribution for this patch is. It was origionally based on a patch by Ondrej Jirman[1], but I have rewritten a large portion if it. I have included a Co-developed-by tag to indicate this, but haven't sent him this patch, so I'm not sure what to do about a Signed-off-by.
Quoted 3 lines
Ah, seems you already aware of this issue. So, either drop Co-developed-by (and if you wish you may give a credit in a free form inside commit message) or make sure you get his SoB tag.
Alright, thanks for clarifying that.
Quoted 3 lines
Quoted 1 line
mutex_init(&data->lock);Somewhere (in the previous patch?) you want to switch to
devm_mutex_init().
Good catch, it looks like that was being leaked before this refactor. Yeah that sounds like the right place, I'll include it in v4.
Quoted 19 lines
drivers/iio/light/stk3310.c static int stk3310_probe(struct i2c_client *client) · line 698
Quoted 12 lines
drivers/iio/light/stk3310.c +10
-0+ ret =devm_regulator_bulk_get (&client->dev,ARRAY_SIZE (data->supplies), + data->supplies); +if (ret) +return dev_err_probe (&client->dev, ret,"get regulators failed\n" ); +return dev_err_probe (&client->dev, ret, +"regulator enable failed\n" ); + ret =devm_add_action_or_reset (&client->dev, stk3310_regulators_disable, data); +if (ret) +return dev_err_probe (&client->dev, ret, +"failed to register regulator cleanup\n" );With
struct devuce *dev = &client->dev;at the top of the function makes these and more lines neater.
[snip]
Quoted 3 lines
While changing to RCT order here, it seems you have inconsistent approach elsewhere (in your own patches!). Please, be consistent with chosen style.
Sounds easy enough to fix, I'll include these in v4.
Thanks taking the time to review
- Aren
Jonathan Cameron
maintainerRe: [PATCH v3 3/6] iio: light: stk3310: Implement vdd and leda supplies
Quoted 25 lines · On Mon, 28 Oct 2024 12:37:14 -0400 Aren Moynihan <[email protected]> wrote:
Quoted 20 lines · Andy Shevchenko
Quoted 4 lines · Aren Moynihan
The vdd and leda supplies must be powered on for the chip to function and can be powered off during system suspend.
Co-developed-by Ondrej Jirman <[email protected]>Missing SoB. Please, read Submitting Patches documentation for understanding what has to be done here.
Quoted 1 line
Signed-off-by Aren Moynihan <[email protected]>...
Quoted 6 lines
Notes:
I'm not sure what the proper way to handle attribution for this patch is. It was origionally based on a patch by Ondrej Jirman[1], but I have rewritten a large portion if it. I have included a Co-developed-by tag to indicate this, but haven't sent him this patch, so I'm not sure what to do about a Signed-off-by.Quoted 3 lines
Ah, seems you already aware of this issue. So, either drop Co-developed-by (and if you wish you may give a credit in a free form inside commit message) or make sure you get his SoB tag.
Quoted 8 lines
Alright, thanks for clarifying that.
Quoted 3 lines
Quoted 1 line
mutex_init(&data->lock);Somewhere (in the previous patch?) you want to switch to
devm_mutex_init().Good catch, it looks like that was being leaked before this refactor. Yeah that sounds like the right place, I'll include it in v4.
Not really on the leaking. Take a look at the cleanup for devm_mutex_init(). It's debug only and not all that useful in most cases.
However, it is good to not assume that now we have a devm_mutex_init() available that is easy to use.
Quoted 29 lines
Quoted 20 lines
drivers/iio/light/stk3310.c static int stk3310_probe(struct i2c_client *client) · line 698
Quoted 13 lines
drivers/iio/light/stk3310.c +10
-0+ ret =devm_regulator_bulk_get (&client->dev,ARRAY_SIZE (data->supplies), + data->supplies); +if (ret) +return dev_err_probe (&client->dev, ret,"get regulators failed\n" ); +return dev_err_probe (&client->dev, ret, +"regulator enable failed\n" ); + ret =devm_add_action_or_reset (&client->dev, stk3310_regulators_disable, data); +if (ret) +return dev_err_probe (&client->dev, ret, +"failed to register regulator cleanup\n" );With
struct devuce *dev = &client->dev;at the top of the function makes these and more lines neater.
[snip]
Quoted 3 lines
While changing to RCT order here, it seems you have inconsistent approach elsewhere (in your own patches!). Please, be consistent with chosen style.
Sounds easy enough to fix, I'll include these in v4.
Thanks taking the time to review
- Aren
Re: [PATCH v3 3/6] iio: light: stk3310: Implement vdd and leda supplies
In reply to Andy ShevchenkoHello Aren,
Quoted 24 lines · Andy Shevchenko
Quoted 4 lines · Aren Moynihan
The vdd and leda supplies must be powered on for the chip to function and can be powered off during system suspend.
Co-developed-by Ondrej Jirman <[email protected]>Missing SoB. Please, read Submitting Patches documentation for understanding what has to be done here.
Quoted 1 line
Signed-off-by Aren Moynihan <[email protected]>...
Quoted 10 lines
Notes:
I'm not sure what the proper way to handle attribution for this
patch
is. It was origionally based on a patch by Ondrej Jirman[1], but I
have
rewritten a large portion if it. I have included a Co-developed-by
tag
to indicate this, but haven't sent him this patch, so I'm not sure
what
to do about a Signed-off-by.
Quoted 3 lines
Ah, seems you already aware of this issue. So, either drop Co-developed-by (and if you wish you may give a credit in a free form inside commit message) or make sure you get his SoB tag.
Perhaps the best and also easiest solution would be to provide an Originally-by tag for Ondrej, because that's what it is. The patch was written originally by Ondrej, but you've changed many parts of the patch while upstreaming it.
PATCH v3 4/6 iio: light: stk3310: use dev_err_probe where possible
In reply to Aren MoynihanUsing dev_err_probe instead of dev_err and return makes the errors easier to understand by including the error name, and saves a little code.
---
Notes:
Added in v2
drivers/iio/light/stk3310.c | 47 ++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-)
drivers/iio/light/stk3310.c +20 -27
@@ -63,10 +63,10 @@ data->reg_##name = \ devm_regmap_field_alloc(&client->dev, regmap, \ stk3310_reg_field_##name); \ - if (IS_ERR(data->reg_##name)) { \ - dev_err(&client->dev, "reg field alloc failed.\n"); \ - return PTR_ERR(data->reg_##name); \ - } \ + if (IS_ERR(data->reg_##name)) \ + return dev_err_probe(&client->dev, \ + PTR_ERR(data->reg_##name), \ + "reg field alloc failed.\n"); \ } while (0) static const struct reg_field stk3310_reg_field_state =
@@ -516,10 +516,8 @@ static int stk3310_init(struct iio_dev *indio_dev) state =STK3310_STATE_EN_ALS |STK3310_STATE_EN_PS ; ret =stk3310_set_state (data, state); -if (ret <0 ) { -dev_err (&client->dev,"failed to enable sensor" ); -return ret; - } +if (ret <0 ) +return dev_err_probe (&client->dev, ret,"failed to enable sensor\n" ); ret =devm_add_action_or_reset (&client->dev, stk3310_set_state_disable, data);if (ret)
@@ -529,9 +527,10 @@ static int stk3310_init(struct iio_dev *indio_dev)/* Enable PS interrupts */ ret =regmap_field_write (data->reg_int_ps,STK3310_PSINT_EN );if (ret <0 ) -dev_err (&client->dev,"failed to enable interrupts!\n" ); +return dev_err_probe (&client->dev, ret, +"failed to enable interrupts!\n" ); -return ret; +return 0 ; }static bool stk3310_is_volatile_reg (struct device *dev,unsigned int reg)
@@ -564,10 +563,10 @@ static int stk3310_regmap_init(struct stk3310_data *data) client = data->client; regmap =devm_regmap_init_i2c (client, &stk3310_regmap_config); -if (IS_ERR (regmap)) { -dev_err (&client->dev,"regmap initialization failed.\n" ); -return PTR_ERR (regmap); - } +if (IS_ERR (regmap)) +return dev_err_probe (&client->dev,PTR_ERR (regmap), +"regmap initialization failed.\n" ); + data->regmap = regmap;STK3310_REGFIELD (state);
@@ -656,10 +655,8 @@ static int stk3310_probe(struct i2c_client *client)struct stk3310_data *data; indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data)); -if (!indio_dev) { -dev_err (&client->dev,"iio allocation failed!\n" ); -return -ENOMEM ; - } +if (!indio_dev) +return dev_err_probe (&client->dev, -ENOMEM ,"iio allocation failed!\n" ); data =iio_priv (indio_dev); data->client = client;
@@ -708,18 +705,14 @@ static int stk3310_probe(struct i2c_client *client)IRQF_TRIGGER_FALLING |IRQF_ONESHOT , STK3310_EVENT, indio_dev); -if (ret <0 ) { -dev_err (&client->dev,"request irq %d failed\n" , - client->irq); -return ret; - } +if (ret <0 ) +return dev_err_probe (&client->dev, ret,"request irq %d failed\n" , + client->irq); } ret =devm_iio_device_register (&client->dev, indio_dev); -if (ret <0 ) { -dev_err (&client->dev,"device_register failed\n" ); -return ret; - } +if (ret <0 ) +return dev_err_probe (&client->dev, ret,"device_register failed\n" );return 0 ; }
Signature · 1 line
2.47.0
Re: [PATCH v3 4/6] iio: light: stk3310: use dev_err_probe where possible
Quoted 3 lines · Aren Moynihan
Using
dev_err_probeinstead ofdev_errand return makes the errors easier to understand by including the error name, and saves a little code.
...
drivers/iio/light/stk3310.c line 70
Quoted 12 lines
drivers/iio/light/stk3310.c +4
-4data->reg_##name = \ devm_regmap_field_alloc(&client->dev, regmap, \ stk3310_reg_field_##name); \ - if (IS_ERR(data->reg_##name)) { \ - dev_err(&client->dev, "reg field alloc failed.\n"); \ - return PTR_ERR(data->reg_##name); \ - } \ + if (IS_ERR(data->reg_##name)) \ + return dev_err_probe(&client->dev, \ + PTR_ERR(data->reg_##name), \ + "reg field alloc failed.\n"); \ } while (0)
Same remark, if client is not used here, supply struct device pointer directly and make these all lines better to read.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 5/6 iio: light: stk3310: log error if reading the chip id fails
In reply to Aren MoynihanIf the chip isn't powered, this call is likely to return an error. Without a log here the driver will silently fail to probe. Common errors are ENXIO (when the chip isn't powered) and ETIMEDOUT (when the i2c bus isn't powered).
---
Notes:
Changes in v2:
- use dev_err_probe
drivers/iio/light/stk3310.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/stk3310.c +1 -1
@@ -508,7 +508,7 @@ static int stk3310_init(struct iio_dev *indio_dev) ret =regmap_read (data->regmap,STK3310_REG_ID , &chipid);if (ret <0 ) -return ret; +return dev_err_probe (&client->dev, ret,"failed to read chip id\n" ); ret =stk3310_check_chip_id (chipid);if (ret <0 )
Signature · 1 line
2.47.0
Re: [PATCH v3 5/6] iio: light: stk3310: log error if reading the chip id fails
Quoted 4 lines · Aren Moynihan
If the chip isn't powered, this call is likely to return an error. Without a log here the driver will silently fail to probe. Common errors are ENXIO (when the chip isn't powered) and ETIMEDOUT (when the i2c bus isn't powered).
The commit message does not explain why dev_err_probe() has been chosen and not simple dev_err().
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 5/6] iio: light: stk3310: log error if reading the chip id fails
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Aren Moynihan
If the chip isn't powered, this call is likely to return an error. Without a log here the driver will silently fail to probe. Common errors are ENXIO (when the chip isn't powered) and ETIMEDOUT (when the i2c bus isn't powered).
The commit message does not explain why
dev_err_probe()has been chosen and not simpledev_err().
This function is only called from stk3310_probe, and this condition should propagate it's error, so it fits what dev_err_probe is designed for. dev_err would be pretty much equivalent just longer, like this:
if (ret < 0) {
dev_err(&client->dev, "failed to read chip it: %d\n", ret);
return ret;
}Regards
- Aren
Re: [PATCH v3 5/6] iio: light: stk3310: log error if reading the chip id fails
Quoted 10 lines · Aren
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Aren Moynihan
If the chip isn't powered, this call is likely to return an error. Without a log here the driver will silently fail to probe. Common errors are ENXIO (when the chip isn't powered) and ETIMEDOUT (when the i2c bus isn't powered).
The commit message does not explain why
dev_err_probe()has been chosen and not simpledev_err().
Quoted 8 lines
This function is only called from
stk3310_probe, and this condition should propagate it's error, so it fits whatdev_err_probeis designed for.dev_errwould be pretty much equivalent just longer, like this:if (ret < 0) { dev_err(&client->dev, "failed to read chip it: %d\n", ret); return ret; }
It's fine, the problem is the commit message in the patch. Please, update the commit message accordingly.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 6/6 arm64: dts: allwinner: pinephone: Add power supplies to stk3311
In reply to Aren MoynihanFrom: Ondrej Jirman <[email protected]>
This allows the driver to properly handle powering this device, and disable power during suspend.
---
Notes:
Changes in v2:
- add leda-supply
arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +2 -0
@@ -260,6 +260,8 @@ light-sensor@48 { reg = <0x48>; interrupt-parent = <&pio>; interrupts = <1 0 IRQ_TYPE_EDGE_FALLING>; /* PB0 */ + vdd-supply = <®_ldo_io0>; + leda-supply = <®_dldo1>; }; /* Accelerometer/gyroscope */
Signature · 1 line
2.47.0
Jonathan Cameron
maintainerQuoted 8 lines · On Mon, 28 Oct 2024 10:19:54 -0400 Aren Moynihan <[email protected]> wrote:
In the Pine64 PinePhone, the stk3310 chip is powered by a regulator that is disabled at system boot and can be shut off during suspend. To ensure that the chip properly initializes, both after boot and suspend, we need to manage this regulator.
Additionally if the chip is shut off in suspend, we need to make sure that it gets reinitialized with the same parameters after resume.
I took a quick look and nothing to add to Andy's excellent review.
J
Quoted 31 lines
Major changes in v3:
- Use bulk regulators instead of two individual ones
- Replacestk3310_removewith devm callbacks
- Hopefully I haven't missed anything, it's been a while since I worked on this patch, and I didn't take good enough notesMajor changes in v2:
- Add handling of the IR LED. I was hesitant to include this as it is the same as pull-up regulator for the i2c bus on the hardware I have, so I can't test it well. I think leaving it out is more likely to cause issues than including it.
- Convert stk3310 to usedev_err_probefor errors.
- Always enable / disable regulators and rely on dummy devices if they're not specified.
- more listed in individual patchesAren Moynihan (5):
dt-bindings: iio: light: stk33xx: add vdd and leda regulators
iio: light: stk3310: handle all remove logic with devm callbacks
iio: light: stk3310: Implement vdd and leda supplies
iio: light: stk3310: usedev_err_probewhere possible
iio: light: stk3310: log error if reading the chip id failsOndrej Jirman (1):
arm64: dts: allwinner: pinephone: Add power supplies to stk3311.../bindings/iio/light/stk33xx.yaml | 4 + .../dts/allwinner/sun50i-a64-pinephone.dtsi | 2 + drivers/iio/light/stk3310.c | 156 +++++++++++++----- 3 files changed, 118 insertions(+), 44 deletions(-)