Skip to contentSkip to conversation

drivers: iio: light: Fix sparse warnings

PATCH Superseded Sandhya Bankar 4 participants 4 messages Sep 24, 2016 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: iio: light: Fix sparse warnings

Fixing below warnings:

drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16

---
 drivers/iio/light/max44000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/max44000.c +1 -1
index 6511b20..1ea9af9 100644
@@ -214,7 +214,7 @@ static int max44000_read_alsval(struct max44000_data *data)
 	if (ret < 0)
 		return ret;
 
-	regval = be16_to_cpu(regval);
+	be16_to_cpus(&regval);
 
 	/*
 	 * Overflow is explained on datasheet page 17.
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 8 lines · Sandhya Bankar

Fixing below warnings:

drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16

This is really just papering over the problem.
A better solution would be to introduce a __be16 local variable to do the initial read into. Then put it in regval via that be16_to_cpu call.

Jonathan

Quoted 18 lines
---
 drivers/iio/light/max44000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/max44000.c +1 -1
index 6511b20..1ea9af9 100644
@@ -214,7 +214,7 @@ static int max44000_read_alsval(struct max44000_data *data)
 	if (ret < 0)
 		return ret;
 
-	regval = be16_to_cpu(regval);
+	be16_to_cpus(&regval);
 
 	/*
 	 * Overflow is explained on datasheet page 17.
#2 lore raw
Quoted 8 lines · Jonathan Cameron
Quoted 7 lines · Sandhya Bankar

Fixing below warnings:

drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16

Quoted 7 lines
Quoted 1 line

This is really just papering over the problem.
A better solution would be to introduce a __be16 local variable to do the initial read into. Then put it in regval via that be16_to_cpu call.

Jonathan

CC'ing [email protected] since this is an Outreachy task, and others will benefit from Jonathan's feedback to be sure that we type the data correctly when it enters the system.

Sandhya, There are a few other patches from you in linux-iio that didn't go to the Outreachy group. Probably not worth bouncing at this point. Others can find them in linux-iio. CC group on all future postings.

Outreachy applicant patch creation reminders:
- use git log commands to decide on the commit path
- commit message says what is changing
- changelog says why it is changing
- changelog makes a reference to the tool used to find the issue and states the warning addresed.

Goal is not to fix checkpatch, sparse, 'insert-your-favorite-tool' warnings. Goal is to correct the valid coding issues that these tools report.

alisons

Quoted 23 lines
Quoted 10 lines
---
 drivers/iio/light/max44000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/max44000.c +0 -0
index 6511b20..1ea9af9 100644

drivers/iio/light/max44000.c static int max44000_read_alsval(struct max44000_data *data) · line 220

Quoted 8 lines
drivers/iio/light/max44000.c +1 -1
@@ -214,7 +214,7 @@ static int max44000_read_alsval(struct max44000_data *data)
 	if (ret < 0)
 		return ret;
 
-	regval = be16_to_cpu(regval);
+	be16_to_cpus(&regval);
 
 	/*
 	 * Overflow is explained on datasheet page 17.

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 18 lines · Alison Schofield
Quoted 8 lines · Jonathan Cameron
Quoted 7 lines · Sandhya Bankar

Fixing below warnings:

drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16 drivers/iio/light/max44000.c:217:18: warning: cast to restricted __be16

Quoted 7 lines
Quoted 1 line

This is really just papering over the problem.
A better solution would be to introduce a __be16 local variable to do the initial read into. Then put it in regval via that be16_to_cpu call.

Jonathan

Quoted 7 lines

CC'ing [email protected] since this is an Outreachy task, and others will benefit from Jonathan's feedback to be sure that we type the data correctly when it enters the system.

Sandhya, There are a few other patches from you in linux-iio that didn't go to the Outreachy group. Probably not worth bouncing at this point. Others can find them in linux-iio. CC group on all future postings.

Yes, please. All patches, staging or not, should be sent to the outreachy-kernel mailing list.

On the other hand, some non-patch small tasks may be better just discussed with the relevant mentor, to allow others to do the same task. Ask mentors what they prefer, if it is not clear.

julia

Quoted 48 lines

Outreachy applicant patch creation reminders:
- use git log commands to decide on the commit path
- commit message says what is changing
- changelog says why it is changing
- changelog makes a reference to the tool used to find the issue and states the warning addresed.

Goal is not to fix checkpatch, sparse, 'insert-your-favorite-tool' warnings. Goal is to correct the valid coding issues that these tools report.

alisons

Quoted 15 lines
Quoted 15 lines
---
 drivers/iio/light/max44000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/max44000.c +1 -1
index 6511b20..1ea9af9 100644
@@ -214,7 +214,7 @@ static int max44000_read_alsval(struct max44000_data *data)
 	if (ret < 0)
 		return ret;
 
-	regval = be16_to_cpu(regval);
+	be16_to_cpus(&regval);
 
Quoted 8 lines

drivers/iio/light/max44000.c static int max44000_read_alsval(struct max44000_data *data) · line 220

Quoted 3 lines
drivers/iio/light/max44000.c +0 -0
 	/*
 	 * Overflow is explained on datasheet page 17.

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160924185107.GA3190%40d830.WORKGROUP.
For more options, visit https://groups.google.com/d/optout.