All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] staging: iio: adc: ad7280a: don't cast type inside switch expression
@ 2018-10-26 16:53 Slawomir Stepien
  2018-10-28 18:59 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Slawomir Stepien @ 2018-10-26 16:53 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw
  Cc: linux-iio, gregkh, Slawomir Stepien

The type promotion will kick in, so the comparison will work.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
 drivers/staging/iio/adc/ad7280a.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index b736275c10f5..7de6be4f0c27 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -610,7 +610,7 @@ static ssize_t ad7280_read_channel_config(struct device *dev,
 	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
 	unsigned int val;
 
-	switch ((u32)this_attr->address) {
+	switch (this_attr->address) {
 	case AD7280A_CELL_OVERVOLTAGE:
 		val = 1000 + (st->cell_threshhigh * 1568) / 100;
 		break;
@@ -646,7 +646,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev,
 	if (ret)
 		return ret;
 
-	switch ((u32)this_attr->address) {
+	switch (this_attr->address) {
 	case AD7280A_CELL_OVERVOLTAGE:
 	case AD7280A_CELL_UNDERVOLTAGE:
 		val = ((val - 1000) * 100) / 1568; /* LSB 15.68mV */
@@ -662,7 +662,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev,
 	val = clamp(val, 0L, 0xFFL);
 
 	mutex_lock(&st->lock);
-	switch ((u32)this_attr->address) {
+	switch (this_attr->address) {
 	case AD7280A_CELL_OVERVOLTAGE:
 		st->cell_threshhigh = val;
 		break;
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] staging: iio: adc: ad7280a: don't cast type inside switch expression
  2018-10-26 16:53 [PATCH 1/1] staging: iio: adc: ad7280a: don't cast type inside switch expression Slawomir Stepien
@ 2018-10-28 18:59 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-10-28 18:59 UTC (permalink / raw)
  To: Slawomir Stepien
  Cc: lars, Michael.Hennerich, knaack.h, pmeerw, linux-iio, gregkh

On Fri, 26 Oct 2018 18:53:10 +0200
Slawomir Stepien <sst@poczta.fm> wrote:

> The type promotion will kick in, so the comparison will work.
> 
> Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Looks good to me.  Applied to the togreg branch of iio.git and pushed out as
testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/adc/ad7280a.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index b736275c10f5..7de6be4f0c27 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -610,7 +610,7 @@ static ssize_t ad7280_read_channel_config(struct device *dev,
>  	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
>  	unsigned int val;
>  
> -	switch ((u32)this_attr->address) {
> +	switch (this_attr->address) {
>  	case AD7280A_CELL_OVERVOLTAGE:
>  		val = 1000 + (st->cell_threshhigh * 1568) / 100;
>  		break;
> @@ -646,7 +646,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev,
>  	if (ret)
>  		return ret;
>  
> -	switch ((u32)this_attr->address) {
> +	switch (this_attr->address) {
>  	case AD7280A_CELL_OVERVOLTAGE:
>  	case AD7280A_CELL_UNDERVOLTAGE:
>  		val = ((val - 1000) * 100) / 1568; /* LSB 15.68mV */
> @@ -662,7 +662,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev,
>  	val = clamp(val, 0L, 0xFFL);
>  
>  	mutex_lock(&st->lock);
> -	switch ((u32)this_attr->address) {
> +	switch (this_attr->address) {
>  	case AD7280A_CELL_OVERVOLTAGE:
>  		st->cell_threshhigh = val;
>  		break;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-29  3:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-26 16:53 [PATCH 1/1] staging: iio: adc: ad7280a: don't cast type inside switch expression Slawomir Stepien
2018-10-28 18:59 ` 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.