* [PATCH v2 1/2] iio: st_sensors: Make use of the helper function dev_err_probe()
@ 2021-09-28 1:40 Cai Huoqing
2021-09-28 1:40 ` [PATCH v2 2/2] iio: st_lsm9ds0: " Cai Huoqing
2021-10-07 17:28 ` [PATCH v2 1/2] iio: st_sensors: " Jonathan Cameron
0 siblings, 2 replies; 6+ messages in thread
From: Cai Huoqing @ 2021-09-28 1:40 UTC (permalink / raw)
To: caihuoqing; +Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio, linux-kernel
When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
v1->v2: Remove the separate line of PTR_ERR().
.../iio/common/st_sensors/st_sensors_core.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index a5a140de9a23..732d0f8f99f6 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -228,10 +228,10 @@ int st_sensors_power_enable(struct iio_dev *indio_dev)
/* Regulators not mandatory, but if requested we should enable them. */
pdata->vdd = devm_regulator_get(parent, "vdd");
- if (IS_ERR(pdata->vdd)) {
- dev_err(&indio_dev->dev, "unable to get Vdd supply\n");
- return PTR_ERR(pdata->vdd);
- }
+ if (IS_ERR(pdata->vdd))
+ return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd),
+ "unable to get Vdd supply\n");
+
err = regulator_enable(pdata->vdd);
if (err != 0) {
dev_warn(&indio_dev->dev,
@@ -243,10 +245,10 @@ int st_sensors_power_enable(struct iio_dev *indio_dev)
return err;
pdata->vdd_io = devm_regulator_get(parent, "vddio");
- if (IS_ERR(pdata->vdd_io)) {
- dev_err(&indio_dev->dev, "unable to get Vdd_IO supply\n");
- return PTR_ERR(pdata->vdd_io);
- }
+ if (IS_ERR(pdata->vdd_io))
+ return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd_io),
+ "unable to get Vdd_IO supply\n");
+
err = regulator_enable(pdata->vdd_io);
if (err != 0) {
dev_warn(&indio_dev->dev,
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] iio: st_lsm9ds0: Make use of the helper function dev_err_probe()
2021-09-28 1:40 [PATCH v2 1/2] iio: st_sensors: Make use of the helper function dev_err_probe() Cai Huoqing
@ 2021-09-28 1:40 ` Cai Huoqing
2021-09-29 17:06 ` Jonathan Cameron
2021-10-07 17:28 ` [PATCH v2 1/2] iio: st_sensors: " Jonathan Cameron
1 sibling, 1 reply; 6+ messages in thread
From: Cai Huoqing @ 2021-09-28 1:40 UTC (permalink / raw)
To: caihuoqing; +Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio, linux-kernel
When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
index b3a43a3b04ff..9fb06b7cde3c 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
@@ -24,10 +24,10 @@ static int st_lsm9ds0_power_enable(struct device *dev, struct st_lsm9ds0 *lsm9ds
/* Regulators not mandatory, but if requested we should enable them. */
lsm9ds0->vdd = devm_regulator_get(dev, "vdd");
- if (IS_ERR(lsm9ds0->vdd)) {
- dev_err(dev, "unable to get Vdd supply\n");
- return PTR_ERR(lsm9ds0->vdd);
- }
+ if (IS_ERR(lsm9ds0->vdd))
+ return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd),
+ "unable to get Vdd supply\n");
+
ret = regulator_enable(lsm9ds0->vdd);
if (ret) {
dev_warn(dev, "Failed to enable specified Vdd supply\n");
@@ -36,9 +36,9 @@ static int st_lsm9ds0_power_enable(struct device *dev, struct st_lsm9ds0 *lsm9ds
lsm9ds0->vdd_io = devm_regulator_get(dev, "vddio");
if (IS_ERR(lsm9ds0->vdd_io)) {
- dev_err(dev, "unable to get Vdd_IO supply\n");
regulator_disable(lsm9ds0->vdd);
- return PTR_ERR(lsm9ds0->vdd_io);
+ return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd_io),
+ "unable to get Vdd_IO supply\n");
}
ret = regulator_enable(lsm9ds0->vdd_io);
if (ret) {
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] iio: st_lsm9ds0: Make use of the helper function dev_err_probe()
2021-09-28 1:40 ` [PATCH v2 2/2] iio: st_lsm9ds0: " Cai Huoqing
@ 2021-09-29 17:06 ` Jonathan Cameron
2021-10-07 17:30 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2021-09-29 17:06 UTC (permalink / raw)
To: Cai Huoqing; +Cc: Lars-Peter Clausen, linux-iio, linux-kernel
On Tue, 28 Sep 2021 09:40:54 +0800
Cai Huoqing <caihuoqing@baidu.com> wrote:
> When possible use dev_err_probe help to properly deal with the
> PROBE_DEFER error, the benefit is that DEFER issue will be logged
> in the devices_deferred debugfs file.
> Using dev_err_probe() can reduce code size, and the error value
> gets printed.
>
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Hi Cai,
Picking a random patch to reply to...
Thanks for your hard work on these. The ones I haven't replied to look
fine to me. It might have been slightly better to slow down your initial
submission of these as then we could perhaps have avoided 2-3 versions
of every patch by identifying shared elements to improve in a smaller set.
Still that's the benefit of hindsight!
I'll not apply these quite yet so as to allow time for driver maintainers
and others to take a look.
If you could tidy up those few minor comments I have that would be great.
Thanks,
Jonathan
> ---
> drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> index b3a43a3b04ff..9fb06b7cde3c 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> @@ -24,10 +24,10 @@ static int st_lsm9ds0_power_enable(struct device *dev, struct st_lsm9ds0 *lsm9ds
>
> /* Regulators not mandatory, but if requested we should enable them. */
> lsm9ds0->vdd = devm_regulator_get(dev, "vdd");
> - if (IS_ERR(lsm9ds0->vdd)) {
> - dev_err(dev, "unable to get Vdd supply\n");
> - return PTR_ERR(lsm9ds0->vdd);
> - }
> + if (IS_ERR(lsm9ds0->vdd))
> + return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd),
> + "unable to get Vdd supply\n");
> +
> ret = regulator_enable(lsm9ds0->vdd);
> if (ret) {
> dev_warn(dev, "Failed to enable specified Vdd supply\n");
> @@ -36,9 +36,9 @@ static int st_lsm9ds0_power_enable(struct device *dev, struct st_lsm9ds0 *lsm9ds
>
> lsm9ds0->vdd_io = devm_regulator_get(dev, "vddio");
> if (IS_ERR(lsm9ds0->vdd_io)) {
> - dev_err(dev, "unable to get Vdd_IO supply\n");
> regulator_disable(lsm9ds0->vdd);
> - return PTR_ERR(lsm9ds0->vdd_io);
> + return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd_io),
> + "unable to get Vdd_IO supply\n");
> }
> ret = regulator_enable(lsm9ds0->vdd_io);
> if (ret) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] iio: st_sensors: Make use of the helper function dev_err_probe()
2021-09-28 1:40 [PATCH v2 1/2] iio: st_sensors: Make use of the helper function dev_err_probe() Cai Huoqing
2021-09-28 1:40 ` [PATCH v2 2/2] iio: st_lsm9ds0: " Cai Huoqing
@ 2021-10-07 17:28 ` Jonathan Cameron
1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2021-10-07 17:28 UTC (permalink / raw)
To: Cai Huoqing; +Cc: Lars-Peter Clausen, linux-iio, linux-kernel, Denis CIOCCA
On Tue, 28 Sep 2021 09:40:53 +0800
Cai Huoqing <caihuoqing@baidu.com> wrote:
> When possible use dev_err_probe help to properly deal with the
> PROBE_DEFER error, the benefit is that DEFER issue will be logged
> in the devices_deferred debugfs file.
> Using dev_err_probe() can reduce code size, and the error value
> gets printed.
>
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
+CC Denis though this looks simple enough I'll take it now.
Applied to the togreg branch of iio.git and pushed out as testing for all the
normal reasons.
Thanks,
Jonathan
> ---
> v1->v2: Remove the separate line of PTR_ERR().
>
> .../iio/common/st_sensors/st_sensors_core.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index a5a140de9a23..732d0f8f99f6 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -228,10 +228,10 @@ int st_sensors_power_enable(struct iio_dev *indio_dev)
>
> /* Regulators not mandatory, but if requested we should enable them. */
> pdata->vdd = devm_regulator_get(parent, "vdd");
> - if (IS_ERR(pdata->vdd)) {
> - dev_err(&indio_dev->dev, "unable to get Vdd supply\n");
> - return PTR_ERR(pdata->vdd);
> - }
> + if (IS_ERR(pdata->vdd))
> + return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd),
> + "unable to get Vdd supply\n");
> +
> err = regulator_enable(pdata->vdd);
> if (err != 0) {
> dev_warn(&indio_dev->dev,
> @@ -243,10 +245,10 @@ int st_sensors_power_enable(struct iio_dev *indio_dev)
> return err;
>
> pdata->vdd_io = devm_regulator_get(parent, "vddio");
> - if (IS_ERR(pdata->vdd_io)) {
> - dev_err(&indio_dev->dev, "unable to get Vdd_IO supply\n");
> - return PTR_ERR(pdata->vdd_io);
> - }
> + if (IS_ERR(pdata->vdd_io))
> + return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd_io),
> + "unable to get Vdd_IO supply\n");
> +
> err = regulator_enable(pdata->vdd_io);
> if (err != 0) {
> dev_warn(&indio_dev->dev,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] iio: st_lsm9ds0: Make use of the helper function dev_err_probe()
2021-10-07 17:30 ` Jonathan Cameron
@ 2021-10-07 17:30 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-10-07 17:30 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Cai Huoqing, Lars-Peter Clausen, linux-iio, Linux Kernel Mailing List
On Thu, Oct 7, 2021 at 8:26 PM Jonathan Cameron <jic23@kernel.org> wrote:
> On Wed, 29 Sep 2021 18:06:38 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
> > On Tue, 28 Sep 2021 09:40:54 +0800
> > Cai Huoqing <caihuoqing@baidu.com> wrote:
> >
> > > When possible use dev_err_probe help to properly deal with the
> > > PROBE_DEFER error, the benefit is that DEFER issue will be logged
> > > in the devices_deferred debugfs file.
> > > Using dev_err_probe() can reduce code size, and the error value
> > > gets printed.
> > >
> > > Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
>
> +CC Andy who wrote this particular driver.
Thanks, Jonathan!
> Change looks simple enough I'll apply it though and at least get 0-day building it.
>
> Applied to the togreg branch of iio.git and pushed out as testing for 0-day to
> work it's magic,
...
> > > + return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd),
> > > + "unable to get Vdd supply\n");
> > > + return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd_io),
> > > + "unable to get Vdd_IO supply\n");
I prefer seeing them as one liners, but I've no strong opinion.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] iio: st_lsm9ds0: Make use of the helper function dev_err_probe()
2021-09-29 17:06 ` Jonathan Cameron
@ 2021-10-07 17:30 ` Jonathan Cameron
2021-10-07 17:30 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2021-10-07 17:30 UTC (permalink / raw)
To: Cai Huoqing; +Cc: Lars-Peter Clausen, linux-iio, linux-kernel, Andy Shevchenko
On Wed, 29 Sep 2021 18:06:38 +0100
Jonathan Cameron <jic23@kernel.org> wrote:
> On Tue, 28 Sep 2021 09:40:54 +0800
> Cai Huoqing <caihuoqing@baidu.com> wrote:
>
> > When possible use dev_err_probe help to properly deal with the
> > PROBE_DEFER error, the benefit is that DEFER issue will be logged
> > in the devices_deferred debugfs file.
> > Using dev_err_probe() can reduce code size, and the error value
> > gets printed.
> >
> > Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
+CC Andy who wrote this particular driver.
Change looks simple enough I'll apply it though and at least get 0-day building it.
Applied to the togreg branch of iio.git and pushed out as testing for 0-day to
work it's magic,
Thanks,
Jonathan
>
> Hi Cai,
>
> Picking a random patch to reply to...
>
> Thanks for your hard work on these. The ones I haven't replied to look
> fine to me. It might have been slightly better to slow down your initial
> submission of these as then we could perhaps have avoided 2-3 versions
> of every patch by identifying shared elements to improve in a smaller set.
> Still that's the benefit of hindsight!
>
> I'll not apply these quite yet so as to allow time for driver maintainers
> and others to take a look.
>
> If you could tidy up those few minor comments I have that would be great.
>
> Thanks,
>
> Jonathan
>
> > ---
> > drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> > index b3a43a3b04ff..9fb06b7cde3c 100644
> > --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> > +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> > @@ -24,10 +24,10 @@ static int st_lsm9ds0_power_enable(struct device *dev, struct st_lsm9ds0 *lsm9ds
> >
> > /* Regulators not mandatory, but if requested we should enable them. */
> > lsm9ds0->vdd = devm_regulator_get(dev, "vdd");
> > - if (IS_ERR(lsm9ds0->vdd)) {
> > - dev_err(dev, "unable to get Vdd supply\n");
> > - return PTR_ERR(lsm9ds0->vdd);
> > - }
> > + if (IS_ERR(lsm9ds0->vdd))
> > + return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd),
> > + "unable to get Vdd supply\n");
> > +
> > ret = regulator_enable(lsm9ds0->vdd);
> > if (ret) {
> > dev_warn(dev, "Failed to enable specified Vdd supply\n");
> > @@ -36,9 +36,9 @@ static int st_lsm9ds0_power_enable(struct device *dev, struct st_lsm9ds0 *lsm9ds
> >
> > lsm9ds0->vdd_io = devm_regulator_get(dev, "vddio");
> > if (IS_ERR(lsm9ds0->vdd_io)) {
> > - dev_err(dev, "unable to get Vdd_IO supply\n");
> > regulator_disable(lsm9ds0->vdd);
> > - return PTR_ERR(lsm9ds0->vdd_io);
> > + return dev_err_probe(dev, PTR_ERR(lsm9ds0->vdd_io),
> > + "unable to get Vdd_IO supply\n");
> > }
> > ret = regulator_enable(lsm9ds0->vdd_io);
> > if (ret) {
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-07 17:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 1:40 [PATCH v2 1/2] iio: st_sensors: Make use of the helper function dev_err_probe() Cai Huoqing
2021-09-28 1:40 ` [PATCH v2 2/2] iio: st_lsm9ds0: " Cai Huoqing
2021-09-29 17:06 ` Jonathan Cameron
2021-10-07 17:30 ` Jonathan Cameron
2021-10-07 17:30 ` Andy Shevchenko
2021-10-07 17:28 ` [PATCH v2 1/2] iio: st_sensors: " Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.