Skip to contentSkip to conversation

iio:magnetometer:mag3110: Scale factor missing for temperature

PATCH Applied Dan Carpenter 3 participants 5 messages Feb 24, 2014 – Feb 25, 2014 IIO

lore
Share & tools
lore
#0 lore raw

Hello Peter Meerwald,

The patch f9279d3a8cc8: "iio:magnetometer:mag3110: Scale factor missing for temperature" from Oct 1, 2014, leads to the following

                              ^^^^^^^^^^^

[ just the other day people were searching the internet for time
travellers from the future ].

static checker warning:

	drivers/iio/magnetometer/mag3110.c:197 mag3110_read_raw()
	info: ignoring unreachable code.

drivers/iio/magnetometer/mag3110.c
185 case IIO_CHAN_INFO_SCALE:
186 switch (chan->type) {
187 case IIO_MAGN:

   188                          *val = 0;
   189                          *val2 = 1000;
   190                          return IIO_VAL_INT_PLUS_MICRO;
   191                  case IIO_TEMP:
   192                          *val = 1000;
   193                          return IIO_VAL_INT;
   194                  default:
   195                          return -EINVAL;
   196                  }
   197                  return IIO_VAL_INT_PLUS_MICRO;
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Was -EINVAL intended here?

regards,
dan carpenter

#1 lore raw

PATCH 1/1 iio:magnetometer:mag3110: Fix unreachable code

drivers/iio/magnetometer/mag3110.c:197 mag3110_read_raw()
info: ignoring unreachable code.

drivers/iio/magnetometer/mag3110.c
185 case IIO_CHAN_INFO_SCALE:
186 switch (chan->type) {
187 case IIO_MAGN:

   188                          *val = 0;
   189                          *val2 = 1000;
   190                          return IIO_VAL_INT_PLUS_MICRO;
   191                  case IIO_TEMP:
   192                          *val = 1000;
   193                          return IIO_VAL_INT;
   194                  default:
   195                          return -EINVAL;
   196                  }
   197                  return IIO_VAL_INT_PLUS_MICRO;
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

introduced by f9279d3a, mag3110: Scale factor missing

---
 drivers/iio/magnetometer/mag3110.c | 1 -
 1 file changed, 1 deletion(-)
drivers/iio/magnetometer/mag3110.c +0 -1
index 9f260a5..e3106b4 100644
@@ -194,7 +194,6 @@ static int mag3110_read_raw(struct iio_dev *indio_dev,
 		default:
 			return -EINVAL;
 		}
-		return IIO_VAL_INT_PLUS_MICRO;
 	case IIO_CHAN_INFO_SAMP_FREQ:
 		i = data->ctrl_reg1 >> MAG3110_CTRL_DR_SHIFT;
 		*val = mag3110_samp_freq[i][0];
Signature · 1 line
1.8.3.2
#3 lore raw
In reply to Dan Carpenter
Quoted 6 lines

The patch f9279d3a8cc8: "iio:magnetometer:mag3110: Scale factor missing for temperature" from Oct 1, 2014, leads to the following

                              ^^^^^^^^^^^

[ just the other day people were searching the internet for time
travellers from the future ].

this is indeed weird

Quoted 18 lines
	drivers/iio/magnetometer/mag3110.c:197 mag3110_read_raw()
	info: ignoring unreachable code.

drivers/iio/magnetometer/mag3110.c
185 case IIO_CHAN_INFO_SCALE:

   186                  switch (chan->type) {
   187                  case IIO_MAGN:
   188                          *val = 0;
   189                          *val2 = 1000;
   190                          return IIO_VAL_INT_PLUS_MICRO;
   191                  case IIO_TEMP:
   192                          *val = 1000;
   193                          return IIO_VAL_INT;
   194                  default:
   195                          return -EINVAL;
   196                  }
   197                  return IIO_VAL_INT_PLUS_MICRO;
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line

Was -EINVAL intended here?

no, this is dead code as the checker indicated

thanks for reporting, sent fix to linux-iio

p.

Signature · 2 lines
Peter Meerwald
+43-664-2444418 (mobile)
maintainer
#4 lore raw
Quoted 8 lines · Peter Meerwald
Quoted 6 lines

The patch f9279d3a8cc8: "iio:magnetometer:mag3110: Scale factor missing for temperature" from Oct 1, 2014, leads to the following

                               ^^^^^^^^^^^

[ just the other day people were searching the internet for time
travellers from the future ].

this is indeed weird

Quite. The interesting question is how did the date format get messed up.

Quoted 27 lines
Quoted 19 lines
	drivers/iio/magnetometer/mag3110.c:197 mag3110_read_raw()
	info: ignoring unreachable code.

drivers/iio/magnetometer/mag3110.c

    185          case IIO_CHAN_INFO_SCALE:
    186                  switch (chan->type) {
    187                  case IIO_MAGN:
    188                          *val = 0;
    189                          *val2 = 1000;
    190                          return IIO_VAL_INT_PLUS_MICRO;
    191                  case IIO_TEMP:
    192                          *val = 1000;
    193                          return IIO_VAL_INT;
    194                  default:
    195                          return -EINVAL;
    196                  }
    197                  return IIO_VAL_INT_PLUS_MICRO;
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line

Was -EINVAL intended here?

no, this is dead code as the checker indicated

thanks for reporting, sent fix to linux-iio

p.

maintainer Applied
#2 lore raw

Re: [PATCH] iio:magnetometer:mag3110: Fix unreachable code

In reply to Peter Meerwald
Quoted 19 lines · Peter Meerwald

drivers/iio/magnetometer/mag3110.c:197 mag3110_read_raw()
info: ignoring unreachable code.

drivers/iio/magnetometer/mag3110.c

    185          case IIO_CHAN_INFO_SCALE:
    186                  switch (chan->type) {
    187                  case IIO_MAGN:
    188                          *val = 0;
    189                          *val2 = 1000;
    190                          return IIO_VAL_INT_PLUS_MICRO;
    191                  case IIO_TEMP:
    192                          *val = 1000;
    193                          return IIO_VAL_INT;
    194                  default:
    195                          return -EINVAL;
    196                  }
    197                  return IIO_VAL_INT_PLUS_MICRO;
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 4 lines

introduced by f9279d3a, mag3110: Scale factor missing

Applied to the togreg branch of iio.git

Thanks,

Quoted 17 lines
---
  drivers/iio/magnetometer/mag3110.c | 1 -
  1 file changed, 1 deletion(-)
drivers/iio/magnetometer/mag3110.c +0 -1
index 9f260a5..e3106b4 100644
@@ -194,7 +194,6 @@ static int mag3110_read_raw(struct iio_dev *indio_dev,
  		default:
  			return -EINVAL;
  		}
-		return IIO_VAL_INT_PLUS_MICRO;
  	case IIO_CHAN_INFO_SAMP_FREQ:
  		i = data->ctrl_reg1 >> MAG3110_CTRL_DR_SHIFT;
  		*val = mag3110_samp_freq[i][0];