Skip to contentSkip to conversation

iio:potentiostat:lmp91000: Adjust codestyle, and minor cleanup changes

PATCH In review Lucas Oshiro 3 participants 13 messages Feb 18, 2019 – Mar 3, 2019 IIO

lore
Share & tools
lore
#0 lore raw

cover iio:potentiostat:lmp91000: Adjust codestyle, and minor cleanup changes

Hi,

We solved some checkpath.el CHECKs and WARNINGs. We also inverted the arms of an if statement, in order to make the code smaller as the else statement was supressed. We added a missing '\n' on a dev_err message.

Lucas Oshiro (5):
iio:potentiostat:lmp91000: remove unnecessary parentheses iio:potentiostat:lmp91000: insert braces around if arms iio:potentiostat:lmp91000: reduce line width and remove blank line iio:potentiostat:lmp91000: invert if statement iio:potentiostat:lmp91000: add '\n' on dev_err

 drivers/iio/potentiostat/lmp91000.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/5 iio:potentiostat:lmp91000: remove unnecessary parentheses

Remove unnecessary parentheses on line 116, and solve these checkpatch.pl CHECKs:

- lmp91000.c:116: CHECK: Unnecessary parentheses around 'state != channel'
- lmp91000.c:116: CHECK: Unnecessary parentheses around 'channel == LMP91000_REG_MODECN_TEMP'

---
 drivers/iio/potentiostat/lmp91000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/potentiostat/lmp91000.c +1 -1
index 90e895adf997..03d277621861 100644
@@ -113,7 +113,7 @@ static int lmp91000_read(struct lmp91000_data *data, int channel, int *val)
 		return -EINVAL;
 
 	/* delay till first temperature reading is complete */
-	if ((state != channel) && (channel == LMP91000_REG_MODECN_TEMP))
+	if (state != channel && channel == LMP91000_REG_MODECN_TEMP)
 		usleep_range(3000, 4000);
 
 	data->chan_select = channel != LMP91000_REG_MODECN_3LEAD;
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/5 iio:potentiostat:lmp91000: insert braces around if arms

In reply to Lucas Oshiro

Insert braces around all arms of if statement starting on line 214, and solve these checkpath.el CHECKs:

- lmp91000.c:214: CHECK: braces {} should be used on all arms of this statement
- lmp91000.c:216: CHECK: Unbalanced braces around else statement

---
 drivers/iio/potentiostat/lmp91000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/potentiostat/lmp91000.c +2 -2
index 03d277621861..ca31be510940 100644
@@ -211,9 +211,9 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 
 	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
 	if (ret) {
-		if (of_property_read_bool(np, "ti,external-tia-resistor"))
+		if (of_property_read_bool(np, "ti,external-tia-resistor")) {
 			val = 0;
-		else {
+		} else {
 			dev_err(dev, "no ti,tia-gain-ohm defined");
 			return ret;
 		}
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/5 iio:potentiostat:lmp91000: reduce line width and remove blank line

In reply to Lucas Oshiro

Break the line 258 in order fit the line width on 80 characters. Remove the blank line 279, as the line before is also a blank line. Solve these checkpath.el WARNING and CHECK:

- lmp91000.c:258: WARNING: line over 80 characters
- lmp91000.c:279: CHECK: Please don't use multiple blank lines

---
 drivers/iio/potentiostat/lmp91000.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/potentiostat/lmp91000.c +2 -3
index ca31be510940..6dba26121a62 100644
@@ -255,8 +255,8 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 
 	regmap_write(data->regmap, LMP91000_REG_LOCK, 0);
 	regmap_write(data->regmap, LMP91000_REG_TIACN, reg);
-	regmap_write(data->regmap, LMP91000_REG_REFCN, LMP91000_REG_REFCN_EXT_REF
-					| LMP91000_REG_REFCN_50_ZERO);
+	regmap_write(data->regmap, LMP91000_REG_REFCN,
+		     LMP91000_REG_REFCN_EXT_REF	| LMP91000_REG_REFCN_50_ZERO);
 	regmap_write(data->regmap, LMP91000_REG_LOCK, 1);
 
 	return 0;
@@ -276,7 +276,6 @@ static int lmp91000_buffer_cb(const void *val, void *private)
 static const struct iio_trigger_ops lmp91000_trigger_ops = {
 };
 
-
 static int lmp91000_buffer_preenable(struct iio_dev *indio_dev)
 {
 	struct lmp91000_data *data = iio_priv(indio_dev);
Signature · 1 line
2.20.1
#4 lore raw

PATCH 4/5 iio:potentiostat:lmp91000: invert if statement

In reply to Lucas Oshiro

Invert if statement arms in line 214, in order to make the code cleaner

---
 drivers/iio/potentiostat/lmp91000.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/potentiostat/lmp91000.c +2 -3
index 6dba26121a62..7229ef59590a 100644
@@ -211,12 +211,11 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 
 	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
 	if (ret) {
-		if (of_property_read_bool(np, "ti,external-tia-resistor")) {
-			val = 0;
-		} else {
+		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
 			dev_err(dev, "no ti,tia-gain-ohm defined");
 			return ret;
 		}
+		val = 0;
 	}
 
 	ret = -EINVAL;
Signature · 1 line
2.20.1
maintainer
#5 lore raw

Re: [PATCH 4/5] iio:potentiostat:lmp91000: invert if statement

Quoted 4 lines · On Mon, 18 Feb 2019 14:22:35 -0300 Lucas Oshiro <[email protected]>…

Invert if statement arms in line 214, in order to make the code cleaner

Given this undoes one of the earlier changes, please merge them.

Jonathan

Quoted 23 lines
---
 drivers/iio/potentiostat/lmp91000.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/potentiostat/lmp91000.c +2 -3
index 6dba26121a62..7229ef59590a 100644
@@ -211,12 +211,11 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 
 	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
 	if (ret) {
-		if (of_property_read_bool(np, "ti,external-tia-resistor")) {
-			val = 0;
-		} else {
+		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
 			dev_err(dev, "no ti,tia-gain-ohm defined");
 			return ret;
 		}
+		val = 0;
 	}
 
 	ret = -EINVAL;
#6 lore raw

PATCH 5/5 iio:potentiostat:lmp91000: add '\n' on dev_err

In reply to Lucas Oshiro

Add missing '\n' at the end of dev_err message on line 215.

---
 drivers/iio/potentiostat/lmp91000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/potentiostat/lmp91000.c +1 -1
index 7229ef59590a..aecdda757586 100644
@@ -212,7 +212,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
 	if (ret) {
 		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
-			dev_err(dev, "no ti,tia-gain-ohm defined");
+			dev_err(dev, "no ti,tia-gain-ohm defined\n");
 			return ret;
 		}
 		val = 0;
Signature · 1 line
2.20.1
#7 lore raw

Re: [PATCH 5/5] iio:potentiostat:lmp91000: add '\n' on dev_err

Quoted 1 line · Lucas Oshiro

Add missing '\n' at the end of dev_err message on line 215.

[]

drivers/iio/potentiostat/lmp91000.c

Quoted 1 line
drivers/iio/potentiostat/lmp91000.c +0 -0

[]

drivers/iio/potentiostat/lmp91000.c static int lmp91000_read_config(struct lmp91000_data *data) · line 215

Quoted 6 lines
drivers/iio/potentiostat/lmp91000.c +1 -1
@@ -212,7 +212,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
 	if (ret) {
 		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
-			dev_err(dev, "no ti,tia-gain-ohm defined");
+			dev_err(dev, "no ti,tia-gain-ohm defined\n");

Perhaps a copy/paste error as the test is for
external-tia-resistor and not tia-gain-ohm

maintainer
#8 lore raw

Re: [PATCH 5/5] iio:potentiostat:lmp91000: add '\n' on dev_err

Quoted 5 lines · On Mon, 18 Feb 2019 13:01:23 -0800 Joe Perches <[email protected]> wrote:
Quoted 1 line · Lucas Oshiro

Add missing '\n' at the end of dev_err message on line 215.

[]

drivers/iio/potentiostat/lmp91000.c

Quoted 1 line
drivers/iio/potentiostat/lmp91000.c +0 -0

[]

Quoted 10 lines

drivers/iio/potentiostat/lmp91000.c static int lmp91000_read_config(struct lmp91000_data *data) · line 215

Quoted 6 lines
drivers/iio/potentiostat/lmp91000.c +1 -1
@@ -212,7 +212,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
 	if (ret) {
 		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
-			dev_err(dev, "no ti,tia-gain-ohm defined");
+			dev_err(dev, "no ti,tia-gain-ohm defined\n");  

Perhaps a copy/paste error as the test is for
external-tia-resistor and not tia-gain-ohm

It is an odd construct, but I think this is correct. What it is actually saying is that, given that we don't have an external resistor, we care that the tia-gain-ohm isn't set (otherwise it wouldn't matter).

From the docs
- ti,external-tia-resistor: if the property ti,tia-gain-ohm is not defined this needs to be set to signal that an external resistor value is being used.

So, it might be ideal to say that tia-gain-ohm is not defined and we do not have an external resistor specified.

So not wrong, but could be more informative! So perhaps a follow up patch to tidy that up would be good.

Jonathan

Quoted 1 line
#9 lore raw

Re: [PATCH 5/5] iio:potentiostat:lmp91000: add '\n' on dev_err

Quoted 24 lines · Jonathan Cameron
Quoted 5 lines · On Mon, 18 Feb 2019 13:01:23 -0800 Joe Perches <[email protected]> wrote:
Quoted 1 line · Lucas Oshiro

Add missing '\n' at the end of dev_err message on line 215.

[]

drivers/iio/potentiostat/lmp91000.c

Quoted 1 line
drivers/iio/potentiostat/lmp91000.c +0 -0

[]

Quoted 10 lines

drivers/iio/potentiostat/lmp91000.c static int lmp91000_read_config(struct lmp91000_data *data) · line 215

Quoted 6 lines
drivers/iio/potentiostat/lmp91000.c +1 -1
@@ -212,7 +212,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)
 	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
 	if (ret) {
 		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
-			dev_err(dev, "no ti,tia-gain-ohm defined");
+			dev_err(dev, "no ti,tia-gain-ohm defined\n");  

Perhaps a copy/paste error as the test is for
external-tia-resistor and not tia-gain-ohm

It is an odd construct, but I think this is correct. What it is actually saying is that, given that we don't have an external resistor, we care that the tia-gain-ohm isn't set (otherwise it wouldn't matter).

From the docs
- ti,external-tia-resistor: if the property ti,tia-gain-ohm is not defined this needs to be set to signal that an external resistor value is being used.

Quoted 5 lines

So, it might be ideal to say that tia-gain-ohm is not defined and we do not have an external resistor specified.

So not wrong, but could be more informative! So perhaps a follow up patch to tidy that up would be good.

Then thanks in advance for doing that.
cheers, Joe

#10 lore raw

Re: [PATCH 5/5] iio:potentiostat:lmp91000: add '\n' on dev_err

Thanks for the review!

Quoted 25 lines · Joe Perches
Quoted 24 lines · Jonathan Cameron
Quoted 5 lines · On Mon, 18 Feb 2019 13:01:23 -0800 Joe Perches <[email protected]> wrote:
Quoted 1 line · Lucas Oshiro

Add missing '\n' at the end of dev_err message on line 215.

[]

drivers/iio/potentiostat/lmp91000.c

Quoted 1 line
drivers/iio/potentiostat/lmp91000.c +0 -0

[]

Quoted 10 lines

drivers/iio/potentiostat/lmp91000.c static int lmp91000_read_config(struct lmp91000_data *data) · line 215

Quoted 6 lines
drivers/iio/potentiostat/lmp91000.c +1 -1
@@ -212,7 +212,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)
  	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
  	if (ret) {
  		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
-			dev_err(dev, "no ti,tia-gain-ohm defined");
+			dev_err(dev, "no ti,tia-gain-ohm defined\n");

Perhaps a copy/paste error as the test is for
external-tia-resistor and not tia-gain-ohm

It is an odd construct, but I think this is correct. What it is actually saying is that, given that we don't have an external resistor, we care that the tia-gain-ohm isn't set (otherwise it wouldn't matter).

From the docs
- ti,external-tia-resistor: if the property ti,tia-gain-ohm is not defined this needs to be set to signal that an external resistor value is being used.

Quoted 5 lines
Quoted 5 lines

So, it might be ideal to say that tia-gain-ohm is not defined and we do not have an external resistor specified.

So not wrong, but could be more informative! So perhaps a follow up patch to tidy that up would be good.

So, this means that it's a good idea to change the dev_err message to something like "no ti,tia-gain-ohm defined and external resistor not specified"?

Quoted 4 lines

Then thanks in advance for doing that.
cheers, Joe

maintainer
#11 lore raw

Re: [PATCH 5/5] iio:potentiostat:lmp91000: add '\n' on dev_err

Quoted 28 lines · On Tue, 26 Feb 2019 17:15:52 -0300 Lucas Oshiro <[email protected]>…

Thanks for the review!

Quoted 25 lines · Joe Perches
Quoted 24 lines · Jonathan Cameron
Quoted 5 lines · On Mon, 18 Feb 2019 13:01:23 -0800 Joe Perches <[email protected]> wrote:
Quoted 1 line · Lucas Oshiro

Add missing '\n' at the end of dev_err message on line 215.

[]

drivers/iio/potentiostat/lmp91000.c

Quoted 1 line
drivers/iio/potentiostat/lmp91000.c +0 -0

[]

Quoted 10 lines

drivers/iio/potentiostat/lmp91000.c static int lmp91000_read_config(struct lmp91000_data *data) · line 215

Quoted 6 lines
drivers/iio/potentiostat/lmp91000.c +1 -1
@@ -212,7 +212,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)
  	ret = of_property_read_u32(np, "ti,tia-gain-ohm", &val);
  	if (ret) {
  		if (!of_property_read_bool(np, "ti,external-tia-resistor")) {
-			dev_err(dev, "no ti,tia-gain-ohm defined");
+			dev_err(dev, "no ti,tia-gain-ohm defined\n");  

Perhaps a copy/paste error as the test is for
external-tia-resistor and not tia-gain-ohm

It is an odd construct, but I think this is correct. What it is actually saying is that, given that we don't have an external resistor, we care that the tia-gain-ohm isn't set (otherwise it wouldn't matter).

From the docs
- ti,external-tia-resistor: if the property ti,tia-gain-ohm is not defined this needs to be set to signal that an external resistor value is being used.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

So, it might be ideal to say that tia-gain-ohm is not defined and we do not have an external resistor specified.

So not wrong, but could be more informative! So perhaps a follow up patch to tidy that up would be good.

So, this means that it's a good idea to change the dev_err message to something like "no ti,tia-gain-ohm defined and external resistor not specified"?

Exactly. Thanks,

Jonathan

Quoted 5 lines
Quoted 5 lines

Then thanks in advance for doing that.
cheers, Joe

maintainer
#12 lore raw
In reply to Lucas Oshiro
Quoted 5 lines · On Mon, 18 Feb 2019 14:22:31 -0300 Lucas Oshiro <[email protected]>…

Hi,

We solved some checkpath.el CHECKs and WARNINGs. We also inverted the arms of an if statement, in order to make the code smaller as the else statement was supressed. We added a missing '\n' on a dev_err message.

Please try to identify the original author. Matt is still definitely about, and he is obviously likely to be able to provide the most detailed review of changes to this driver.

Thanks,

Jonathan

Quoted 11 lines

Lucas Oshiro (5):
iio:potentiostat:lmp91000: remove unnecessary parentheses iio:potentiostat:lmp91000: insert braces around if arms iio:potentiostat:lmp91000: reduce line width and remove blank line iio:potentiostat:lmp91000: invert if statement iio:potentiostat:lmp91000: add '\n' on dev_err

 drivers/iio/potentiostat/lmp91000.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)