Skip to contentSkip to conversation

iio: ad9523: Fix argument type mismatch

PATCH In review [email protected] 3 participants 6 messages Jun 11, 2012

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 iio: ad9523: Fix argument type mismatch

From: Michael Hennerich <[email protected]>

drivers/iio/frequency/ad9523.c:378 ad9523_vco_out_map()
warn: value 2 can't fit into 1 'out'

---
 drivers/iio/frequency/ad9523.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/iio/frequency/ad9523.c +1 -1
index 7272924..43f47d9 100644
@@ -361,7 +361,7 @@ static int ad9523_io_update(struct iio_dev *indio_dev)
 }
 
 static int ad9523_vco_out_map(struct iio_dev *indio_dev,
-			      unsigned ch, bool out)
+			      unsigned ch, unsigned out)
 {
 	struct ad9523_state *st = iio_priv(indio_dev);
 	int ret;
Signature · 1 line
1.7.0.4
#1 lore raw

Hi Michael,

drivers/iio/frequency/ad952=

Quoted 12 lines · On Mon, Jun 11, 2012 at 1:21 PM, <[email protected]> wrote:

From: Michael Hennerich <[email protected]>

drivers/iio/frequency/ad9523.c:378 ad9523_vco_out_map() =A0 =A0 =A0 =A0 warn: value 2 can't fit into 1 'out'

---
=A0drivers/iio/frequency/ad9523.c | =A0 =A02 +- =A01 files changed, 1 insertions(+), 1 deletions(-)

drivers/iio/frequency/ad952= renamed from drivers/iio/frequency/ad9523.c +0 -0

3.c

drivers/iio/frequency/ad9523.c static int ad9523_io_update(struct iio_dev *indio_dev=

Quoted 4 lines

index 7272924..43f47d9 100644

drivers/iio/frequency/ad9523.c +0 -0
@@ -361,7 +361,7 @@ static int ad9523_io_update(struct iio_dev *indio_dev=

)

drivers/iio/frequency/ad9523.c static int ad9523_io_update(struct iio_dev *indio_dev= · line 364

Quoted 4 lines
drivers/iio/frequency/ad9523.c +0 -1
 =A0}
 
 =A0static int ad9523_vco_out_map(struct iio_dev *indio_dev,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned ch, bo=

ol out)

drivers/iio/frequency/ad9523.c static int ad9523_io_update(struct iio_dev *indio_dev= · line 364

Quoted 1 line
drivers/iio/frequency/ad9523.c +1 -0
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned ch, un=

signed out)

Unsigned defaults to unsigned int right shouldnt it be a char? Or am I missing something.

author maintainer
#2 lore raw
Quoted 21 lines · Shubhrajyoti Datta

Hi Michael,

Quoted 18 lines · On Mon, Jun 11, 2012 at 1:21 PM,<[email protected]> wrote:

From: Michael Hennerich<[email protected]>

drivers/iio/frequency/ad9523.c:378 ad9523_vco_out_map()
warn: value 2 can't fit into 1 'out'

---
  drivers/iio/frequency/ad9523.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/iio/frequency/ad9523.c +0 -0
index 7272924..43f47d9 100644
@@ -361,7 +361,7 @@ static int ad9523_io_update(struct iio_dev *indio_dev)
  }
 
Quoted 6 lines

drivers/iio/frequency/ad9523.c static int ad9523_io_update(struct iio_dev *indio_dev) · line 364

Quoted 3 lines
drivers/iio/frequency/ad9523.c +1 -1
  static int ad9523_vco_out_map(struct iio_dev *indio_dev,
-                             unsigned ch, bool out)
+                             unsigned ch, unsigned out)

Unsigned defaults to unsigned int right shouldnt it be a char? Or am I missing something.

Hi Shubhrajyoti,

can you explain why this matters?
If you take a closer look at the disassembly -
you will notice that 'unsigned int' will generate nicer code.

Signature · 8 lines
Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
#3 lore raw

Hi Michael,

On Mon, Jun 11, 2012 at 2:45 PM, Michael Hennerich <[email protected]> wrote:
[..]

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

=A0static int ad9523_vco_out_map(struct iio_dev *indio_dev,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned ch, =

bool out)

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned ch, =

unsigned out)

Quoted 10 lines
Quoted 4 lines

Unsigned defaults to unsigned int right shouldnt it be a char? Or am I missing something.

Hi Shubhrajyoti,

can you explain why this matters?
If you take a closer look at the disassembly -
you will notice that 'unsigned int' will generate nicer code.

What I was thinking is that

+ }
+
+ st->vco_out_map[ch] =3D out;
+
+ return ret;
+}
Here

and
+struct ad9523_state {

+       struct spi_device               *spi;
+       struct regulator                *reg;
+       struct ad9523_platform_data     *pdata;
+       struct iio_chan_spec            ad9523_channels[AD9523_NUM_CHAN];
+
+       unsigned long           vcxo_freq;
+       unsigned long           vco_freq;
+       unsigned long           vco_out_freq[AD9523_NUM_CLK_SRC];
+       unsigned char           vco_out_map[AD9523_NUM_CHAN_ALT_CLK_SRC];

So that may not work well with all the endianness etc,

#4 lore raw
Quoted 42 lines · Shubhrajyoti Datta

Hi Michael,

On Mon, Jun 11, 2012 at 2:45 PM, Michael Hennerich <[email protected]> wrote:
[..]

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

static int ad9523_vco_out_map(struct iio_dev *indio_dev,

drivers/iio/frequency/ad9523.c +1 -1
-                             unsigned ch, bool out)
+                             unsigned ch, unsigned out)
Quoted 9 lines
Quoted 3 lines

Unsigned defaults to unsigned int right shouldnt it be a char? Or am I missing something.

Hi Shubhrajyoti,

can you explain why this matters?
If you take a closer look at the disassembly -
you will notice that 'unsigned int' will generate nicer code.

What I was thinking is that

(quoted diff) +6 -0
+       }
+
+       st->vco_out_map[ch] = out;
+
+       return ret;
+}

Here

and

(quoted diff) +10 -0
+struct ad9523_state {
+       struct spi_device               *spi;
+       struct regulator                *reg;
+       struct ad9523_platform_data     *pdata;
+       struct iio_chan_spec            ad9523_channels[AD9523_NUM_CHAN];
+
+       unsigned long           vcxo_freq;
+       unsigned long           vco_freq;
+       unsigned long           vco_out_freq[AD9523_NUM_CLK_SRC];
+       unsigned char           vco_out_map[AD9523_NUM_CHAN_ALT_CLK_SRC];
Quoted 1 line

So that may not work well with all the endianness etc,

The code is fine as it is, the assignment does an implicit type cast.

#5 lore raw

On Mon, Jun 11, 2012 at 5:06 PM, Lars-Peter Clausen <[email protected]> wrote= :

Quoted 8 lines · Shubhrajyoti Datta
Quoted 7 lines

Hi Michael,

On Mon, Jun 11, 2012 at 2:45 PM, Michael Hennerich <[email protected]> wrote:
[..]

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

=A0static int ad9523_vco_out_map(struct iio_dev *indio_dev,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned ch=

, bool out)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned ch=

, unsigned out)

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Unsigned defaults to unsigned int right shouldnt it be a char? Or am I missing something.

The code is fine as it is, the assignment does an implicit type cast.

Ok got is now . Apologies for the noise.