staging: iio: dummy: clean up the define and usage of dummy_scan_elements
Subsystems (3)
PATCH 1/1 staging: iio: dummy: clean up the define and usage of dummy_scan_elements
Cleanups related to the usage of dummy_scan_elements in the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum for IIO_CHAN_SOFT_TIMESTAMP (rm hard coded value)
- comment edited to match changes & follow preferred kernel style
--- drivers/staging/iio/iio_simple_dummy.c | 22 ++++++++++++---------- drivers/staging/iio/iio_simple_dummy.h | 20 +++++++++++--------- drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 28 insertions(+), 23 deletions(-)
drivers/staging/iio/iio_simple_dummy.c +12 -10
@@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2011 Jonathan Cameron * * This program is free software; you can redistribute it and/or modify it
@@ -137,7 +137,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {*/ .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), /* The ordering of elements in the buffer via an enum */ - .scan_index = voltage0, + .scan_index = INDEX_VOLTAGE_0, .scan_type = { /* Description of storage in buffer */ .sign = 'u', /* unsigned */ .realbits = 13, /* 13 bits */
@@ -176,7 +176,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {* sampling_frequency * The frequency in Hz at which the channels are sampled */ - .scan_index = diffvoltage1m2, + .scan_index = INDEX_DIFFVOLTAGE_1M2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 12, /* 12 bits */
@@ -194,7 +194,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = diffvoltage3m4, + .scan_index = INDEX_DIFFVOLTAGE_3M4, .scan_type = { .sign = 's', .realbits = 11,
@@ -221,7 +221,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {BIT (IIO_CHAN_INFO_CALIBSCALE ) | BIT(IIO_CHAN_INFO_CALIBBIAS), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = accelx, + .scan_index = INDEX_ACCELX, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 16, /* 16 bits */
@@ -230,10 +230,10 @@ static const struct iio_chan_spec iio_dummy_channels[] = { }, },/* -* Convenience macro for timestamps. 4 is the index in -* the buffer. +* Convenience macro for timestamps. +* INDEX_TIMESTAMP is the index in the buffer. */ -IIO_CHAN_SOFT_TIMESTAMP (4 ), +IIO_CHAN_SOFT_TIMESTAMP (INDEX_TIMESTAMP ),/* DAC channel out_voltage0_raw */ { .type = IIO_VOLTAGE,
@@ -364,8 +364,10 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret =IIO_VAL_INT_PLUS_MICRO ;break ;case 1 : -/* all differential adc channels -> -* 0.000001344 */ +/* +* all differential adc +* channels -> 0.000001344 +*/ *val =0 ; *val2 =1344 ; ret =IIO_VAL_INT_PLUS_NANO ;
drivers/staging/iio/iio_simple_dummy.h +11 -9
@@ -96,20 +96,22 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ -/** +/* * enum iio_simple_dummy_scan_elements - scan index enum -* @voltage0: the single ended voltage channel -* @diffvoltage1m2: first differential channel -* @diffvoltage3m4: second differenial channel -* @accelx: acceleration channel +* @INDEX_VOLTAGE_0: the single ended voltage channel +* @INDEX_DIFFVOLTAGE_1M2: first differential channel +* @INDEX_DIFFVOLTAGE_3M4: second differential channel +* @INDEX_ACCELX: acceleration channel +* @INDEX_TIMESTAMP: timestamp channel * * Enum provides convenient numbering for the scan index. */ enum iio_simple_dummy_scan_elements { - voltage0, - diffvoltage1m2, - diffvoltage3m4, - accelx, +INDEX_VOLTAGE_0 , +INDEX_DIFFVOLTAGE_1M2 , +INDEX_DIFFVOLTAGE_3M4 , +INDEX_ACCELX , +INDEX_TIMESTAMP , };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
drivers/staging/iio/iio_simple_dummy_buffer.c +5 -4
@@ -27,10 +27,11 @@/* Some fake data */ static const s16 fakedata[] = { - [voltage0] =7 , - [diffvoltage1m2] =-33 , - [diffvoltage3m4] =-2 , - [accelx] =344 , + [INDEX_VOLTAGE_0 ] =7 , + [INDEX_DIFFVOLTAGE_1M2 ] =-33 , + [INDEX_DIFFVOLTAGE_3M4 ] =-2 , + [INDEX_ACCELX ] =344 , + [INDEX_TIMESTAMP ] =50 , };/**
Signature · 1 line
2.1.4
Quoted 5 lines · Alison Schofield
Cleanups related to the usage of
dummy_scan_elementsin the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum forIIO_CHAN_SOFT_TIMESTAMP(rm hard coded value)
- comment edited to match changes & follow preferred kernel style
That's 3 different things, so this should be 3 different patches, right?
Please break it up and resend.
thanks,
greg k-h
Jonathan Cameron
maintainerQuoted 6 lines · Alison Schofield
Cleanups related to the usage of
dummy_scan_elementsin the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum forIIO_CHAN_SOFT_TIMESTAMP(rm hard coded value)
- comment edited to match changes & follow preferred kernel style
As Greg observed this would be better as three separate patches. Comment inline as well.
Jonathan
Quoted 99 lines
Signed-off-by Alison Schofield <[email protected]>--- drivers/staging/iio/iio_simple_dummy.c | 22 ++++++++++++---------- drivers/staging/iio/iio_simple_dummy.h | 20 +++++++++++--------- drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 28 insertions(+), 23 deletions(-)drivers/staging/iio/iio_simple_dummy.c +12
-10@@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2011 Jonathan Cameron * * This program is free software; you can redistribute it and/or modify it @@ -137,7 +137,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {*/ .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), /* The ordering of elements in the buffer via an enum */ - .scan_index = voltage0, + .scan_index = INDEX_VOLTAGE_0, .scan_type = { /* Description of storage in buffer */ .sign = 'u', /* unsigned */ .realbits = 13, /* 13 bits */@@ -176,7 +176,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {* sampling_frequency * The frequency in Hz at which the channels are sampled */ - .scan_index = diffvoltage1m2, + .scan_index = INDEX_DIFFVOLTAGE_1M2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 12, /* 12 bits */@@ -194,7 +194,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = diffvoltage3m4, + .scan_index = INDEX_DIFFVOLTAGE_3M4, .scan_type = { .sign = 's', .realbits = 11,@@ -221,7 +221,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {BIT (IIO_CHAN_INFO_CALIBSCALE ) | BIT(IIO_CHAN_INFO_CALIBBIAS), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = accelx, + .scan_index = INDEX_ACCELX, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 16, /* 16 bits */@@ -230,10 +230,10 @@ static const struct iio_chan_spec iio_dummy_channels[] = { }, },/* -* Convenience macro for timestamps. 4 is the index in -* the buffer. +* Convenience macro for timestamps. +* INDEX_TIMESTAMP is the index in the buffer. */ -IIO_CHAN_SOFT_TIMESTAMP (4 ), +IIO_CHAN_SOFT_TIMESTAMP (INDEX_TIMESTAMP ),/* DAC channel out_voltage0_raw */ { .type = IIO_VOLTAGE,@@ -364,8 +364,10 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret =IIO_VAL_INT_PLUS_MICRO ;break ;case 1 : -/* all differential adc channels -> -* 0.000001344 */ +/* +* all differential adc +* channels -> 0.000001344 +*/ *val =0 ; *val2 =1344 ; ret =IIO_VAL_INT_PLUS_NANO ;drivers/staging/iio/iio_simple_dummy.h +5
-5@@ -96,20 +96,22 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ -/** +/* * enum iio_simple_dummy_scan_elements - scan index enum -* @voltage0: the single ended voltage channel -* @diffvoltage1m2: first differential channel -* @diffvoltage3m4: second differenial channel -* @accelx: acceleration channel +* @INDEX_VOLTAGE_0: the single ended voltage channel +* @INDEX_DIFFVOLTAGE_1M2: first differential channel +* @INDEX_DIFFVOLTAGE_3M4: second differential channel +* @INDEX_ACCELX: acceleration channel
drivers/staging/iio/iio_simple_dummy.h iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) · line 110
Quoted 10 lines
drivers/staging/iio/iio_simple_dummy.h +2
-4+* @INDEX_TIMESTAMP: timestamp channel * * Enum provides convenient numbering for the scan index. */ enum iio_simple_dummy_scan_elements { - voltage0, - diffvoltage1m2, - diffvoltage3m4, - accelx, +INDEX_VOLTAGE_0 ,
Even better would be to prefix these to make it clear they are driver specific. With such generic names one might suspect they come from somewhere in the core.
PerhapsDUMMY_INDEX_...
?
Quoted 28 lines
drivers/staging/iio/iio_simple_dummy.h +4
-0+INDEX_DIFFVOLTAGE_1M2 , +INDEX_DIFFVOLTAGE_3M4 , +INDEX_ACCELX , + INDEX_TIMESTAMP, };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER drivers/staging/iio/iio_simple_dummy_buffer.c +5
-4@@ -27,10 +27,11 @@/* Some fake data */ static const s16 fakedata[] = { - [voltage0] =7 , - [diffvoltage1m2] =-33 , - [diffvoltage3m4] =-2 , - [accelx] =344 , + [INDEX_VOLTAGE_0 ] =7 , + [INDEX_DIFFVOLTAGE_1M2 ] =-33 , + [INDEX_DIFFVOLTAGE_3M4 ] =-2 , + [INDEX_ACCELX ] =344 , + [INDEX_TIMESTAMP ] =50 , };/**
Quoted 11 lines · Jonathan Cameron
Quoted 6 lines · Alison Schofield
Cleanups related to the usage of
dummy_scan_elementsin the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum forIIO_CHAN_SOFT_TIMESTAMP(rm hard coded value)
- comment edited to match changes & follow preferred kernel styleAs Greg observed this would be better as three separate patches. Comment inline as well.
Jonathan
Greg, Jonathan,
Thanks for the review. I understand it needs to be a set.
I only see 2 patches:
1) change enum names to be upper case.
2) replace hardcoded scan_index in IIO_CHAN_SOFT_TIMESTAMP
I don't see the comments as a 3rd, they go with each change. ie. when I change the enum names, I update the comments right above it to match. Same with Patch 2.
OK?
alison
Quoted 145 lines
Quoted 99 lines
Signed-off-by Alison Schofield <[email protected]>--- drivers/staging/iio/iio_simple_dummy.c | 22 ++++++++++++---------- drivers/staging/iio/iio_simple_dummy.h | 20 +++++++++++--------- drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 28 insertions(+), 23 deletions(-)drivers/staging/iio/iio_simple_dummy.c +12
-10@@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2011 Jonathan Cameron * * This program is free software; you can redistribute it and/or modify it @@ -137,7 +137,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {*/ .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), /* The ordering of elements in the buffer via an enum */ - .scan_index = voltage0, + .scan_index = INDEX_VOLTAGE_0, .scan_type = { /* Description of storage in buffer */ .sign = 'u', /* unsigned */ .realbits = 13, /* 13 bits */@@ -176,7 +176,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {* sampling_frequency * The frequency in Hz at which the channels are sampled */ - .scan_index = diffvoltage1m2, + .scan_index = INDEX_DIFFVOLTAGE_1M2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 12, /* 12 bits */@@ -194,7 +194,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = diffvoltage3m4, + .scan_index = INDEX_DIFFVOLTAGE_3M4, .scan_type = { .sign = 's', .realbits = 11,@@ -221,7 +221,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {BIT (IIO_CHAN_INFO_CALIBSCALE ) | BIT(IIO_CHAN_INFO_CALIBBIAS), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = accelx, + .scan_index = INDEX_ACCELX, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 16, /* 16 bits */@@ -230,10 +230,10 @@ static const struct iio_chan_spec iio_dummy_channels[] = { }, },/* -* Convenience macro for timestamps. 4 is the index in -* the buffer. +* Convenience macro for timestamps. +* INDEX_TIMESTAMP is the index in the buffer. */ -IIO_CHAN_SOFT_TIMESTAMP (4 ), +IIO_CHAN_SOFT_TIMESTAMP (INDEX_TIMESTAMP ),/* DAC channel out_voltage0_raw */ { .type = IIO_VOLTAGE,@@ -364,8 +364,10 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret =IIO_VAL_INT_PLUS_MICRO ;break ;case 1 : -/* all differential adc channels -> -* 0.000001344 */ +/* +* all differential adc +* channels -> 0.000001344 +*/ *val =0 ; *val2 =1344 ; ret =IIO_VAL_INT_PLUS_NANO ;drivers/staging/iio/iio_simple_dummy.h +5
-5@@ -96,20 +96,22 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ -/** +/* * enum iio_simple_dummy_scan_elements - scan index enum -* @voltage0: the single ended voltage channel -* @diffvoltage1m2: first differential channel -* @diffvoltage3m4: second differenial channel -* @accelx: acceleration channel +* @INDEX_VOLTAGE_0: the single ended voltage channel +* @INDEX_DIFFVOLTAGE_1M2: first differential channel +* @INDEX_DIFFVOLTAGE_3M4: second differential channel +* @INDEX_ACCELX: acceleration channel drivers/staging/iio/iio_simple_dummy.h iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) · line 110
Quoted 10 lines
drivers/staging/iio/iio_simple_dummy.h +2
-4+* @INDEX_TIMESTAMP: timestamp channel * * Enum provides convenient numbering for the scan index. */ enum iio_simple_dummy_scan_elements { - voltage0, - diffvoltage1m2, - diffvoltage3m4, - accelx, +INDEX_VOLTAGE_0 ,Even better would be to prefix these to make it clear they are driver specific. With such generic names one might suspect they come from somewhere in the core.
Perhaps
DUMMY_INDEX_...
?Quoted 28 lines
drivers/staging/iio/iio_simple_dummy.h +4
-0+INDEX_DIFFVOLTAGE_1M2 , +INDEX_DIFFVOLTAGE_3M4 , +INDEX_ACCELX , + INDEX_TIMESTAMP, };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER drivers/staging/iio/iio_simple_dummy_buffer.c +5
-4@@ -27,10 +27,11 @@/* Some fake data */ static const s16 fakedata[] = { - [voltage0] =7 , - [diffvoltage1m2] =-33 , - [diffvoltage3m4] =-2 , - [accelx] =344 , + [INDEX_VOLTAGE_0 ] =7 , + [INDEX_DIFFVOLTAGE_1M2 ] =-33 , + [INDEX_DIFFVOLTAGE_3M4 ] =-2 , + [INDEX_ACCELX ] =344 , + [INDEX_TIMESTAMP ] =50 , };/**
Quoted 21 lines · Alison Schofield
Quoted 11 lines · Jonathan Cameron
Quoted 6 lines · Alison Schofield
Cleanups related to the usage of
dummy_scan_elementsin the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum forIIO_CHAN_SOFT_TIMESTAMP(rm hard coded value)
- comment edited to match changes & follow preferred kernel styleAs Greg observed this would be better as three separate patches. Comment inline as well.
Jonathan
Greg, Jonathan,
Thanks for the review. I understand it needs to be a set.
I only see 2 patches:
1) change enum names to be upper case.
2) replace hardcodedscan_indexinIIO_CHAN_SOFT_TIMESTAMP
Quoted 5 lines
I don't see the comments as a 3rd, they go with each change. ie. when I change the enum names, I update the comments right above it to match. Same with Patch 2.
OK?
There are a few other comment syntax changes that should really be in a third patch, trivial though they are.
Quoted 161 lines
alison
Quoted 3 lines
Quoted 3 lines
Signed-off-by Alison Schofield <[email protected]>--- drivers/staging/iio/iio_simple_dummy.c | 22++++++++++++----------
Quoted 1 line
Quoted 1 line
drivers/staging/iio/iio_simple_dummy.h | 20+++++++++++---------
Quoted 4 lines
Review
Quoted 4 lines
drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 28 insertions(+), 23 deletions(-)(quoted diff) +0
-0
b/drivers/staging/iio/iio_simple_dummy.cQuoted 9 lines
drivers/staging/iio/iio_simple_dummy.c line 4
Quoted 9 lines
index 381f90f..5e19068 100644
drivers/staging/iio/iio_simple_dummy.c +1
-1@@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2011 Jonathan Cameron * * This program is free software; you can redistribute it and/or modify it
Quoted 1 line
drivers/staging/iio/iio_simple_dummy.c static const struct iio_chan_spec
Quoted 1 line
drivers/staging/iio/iio_simple_dummy.c +0
-0@@ -137,7 +137,7 @@ static const struct iio_chan_speciio_dummy_channels[] = {
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c static const struct iio_chan_spec
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c +1
-1*/ .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), /* The ordering of elements in the buffer via an enum */ - .scan_index = voltage0, + .scan_index = INDEX_VOLTAGE_0, .scan_type = { /* Description of storage in buffer */ .sign = 'u', /* unsigned */ .realbits = 13, /* 13 bits */@@ -176,7 +176,7 @@ static const struct iio_chan_speciio_dummy_channels[] = {
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c static const struct iio_chan_spec
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c +1
-1* sampling_frequency * The frequency in Hz at which the channels are sampled */ - .scan_index = diffvoltage1m2, + .scan_index = INDEX_DIFFVOLTAGE_1M2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 12, /* 12 bits */@@ -194,7 +194,7 @@ static const struct iio_chan_speciio_dummy_channels[] = {
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c static const struct iio_chan_spec
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c +1
-1.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = diffvoltage3m4, + .scan_index = INDEX_DIFFVOLTAGE_3M4, .scan_type = { .sign = 's', .realbits = 11,@@ -221,7 +221,7 @@ static const struct iio_chan_speciio_dummy_channels[] = {
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c static const struct iio_chan_spec
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c +1
-1BIT (IIO_CHAN_INFO_CALIBSCALE ) | BIT(IIO_CHAN_INFO_CALIBBIAS), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = accelx, + .scan_index = INDEX_ACCELX, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 16, /* 16 bits */@@ -230,10 +230,10 @@ static const struct iio_chan_speciio_dummy_channels[] = {
Quoted 6 lines
Quoted 6 lines
drivers/staging/iio/iio_simple_dummy.c +1
-2}, },/* -* Convenience macro for timestamps. 4 is the index in -* the buffer. +* Convenience macro for timestamps. Quoted 8 lines
drivers/staging/iio/iio_simple_dummy.c static int iio_dummy_read_raw(struct iio_dev
Quoted 8 lines
drivers/staging/iio/iio_simple_dummy.c +2
-1+* INDEX_TIMESTAMP is the index in the buffer. */ -IIO_CHAN_SOFT_TIMESTAMP (4 ), +IIO_CHAN_SOFT_TIMESTAMP (INDEX_TIMESTAMP ),/* DAC channel out_voltage0_raw */ { .type = IIO_VOLTAGE,@@ -364,8 +364,10 @@ static int iio_dummy_read_raw(struct iio_dev
*indio_dev,Quoted 5 lines
Quoted 5 lines
drivers/staging/iio/iio_simple_dummy.c +0
-2ret =IIO_VAL_INT_PLUS_MICRO ;break ;case 1 : -/* all differential adc channels -> -* 0.000001344 */ Quoted 8 lines
Review
Quoted 8 lines
drivers/staging/iio/iio_simple_dummy.c +4
-0+/* +* all differential adc +* channels -> 0.000001344 +*/ *val =0 ; *val2 =1344 ; ret =IIO_VAL_INT_PLUS_NANO ;(quoted diff) +0
-0
b/drivers/staging/iio/iio_simple_dummy.hQuoted 4 lines
drivers/staging/iio/iio_simple_dummy.h iio_simple_dummy_events_unregister(struct
Quoted 4 lines
index 5c2f4d0..31b62ad 100644
drivers/staging/iio/iio_simple_dummy.h +0
-0@@ -96,20 +96,22 @@ iio_simple_dummy_events_unregister(struct
iio_dev*indio_dev)Quoted 31 lines
Quoted 14 lines
drivers/staging/iio/iio_simple_dummy.h +5
-5#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ -/** +/* * enum iio_simple_dummy_scan_elements - scan index enum -* @voltage0: the single ended voltage channel -* @diffvoltage1m2: first differential channel -* @diffvoltage3m4: second differenial channel -* @accelx: acceleration channel +* @INDEX_VOLTAGE_0: the single ended voltage channel +* @INDEX_DIFFVOLTAGE_1M2: first differential channel +* @INDEX_DIFFVOLTAGE_3M4: second differential channel +* @INDEX_ACCELX: acceleration channel drivers/staging/iio/iio_simple_dummy.h iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) · line 110
Quoted 10 lines
drivers/staging/iio/iio_simple_dummy.h +2
-4+* @INDEX_TIMESTAMP: timestamp channel * * Enum provides convenient numbering for the scan index. */ enum iio_simple_dummy_scan_elements { - voltage0, - diffvoltage1m2, - diffvoltage3m4, - accelx, +INDEX_VOLTAGE_0 ,Even better would be to prefix these to make it clear they are driver specific. With such generic names one might suspect they come from somewhere in the core.
Perhaps
DUMMY_INDEX_...
?Quoted 8 lines
Review
Quoted 8 lines
drivers/staging/iio/iio_simple_dummy.h +4
-0+INDEX_DIFFVOLTAGE_1M2 , +INDEX_DIFFVOLTAGE_3M4 , +INDEX_ACCELX , + INDEX_TIMESTAMP, };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER (quoted diff) +0
-0
b/drivers/staging/iio/iio_simple_dummy_buffer.cQuoted 21 lines
Quoted 20 lines
index 00ed774..7516835 100644
drivers/staging/iio/iio_simple_dummy_buffer.c +5
-4@@ -27,10 +27,11 @@/* Some fake data */ static const s16 fakedata[] = { - [voltage0] =7 , - [diffvoltage1m2] =-33 , - [diffvoltage3m4] =-2 , - [accelx] =344 , + [INDEX_VOLTAGE_0 ] =7 , + [INDEX_DIFFVOLTAGE_1M2 ] =-33 , + [INDEX_DIFFVOLTAGE_3M4 ] =-2 , + [INDEX_ACCELX ] =344 , + [INDEX_TIMESTAMP ] =50 , };/**
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 18 lines · Alison Schofield
Cleanups related to the usage of
dummy_scan_elementsin the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum forIIO_CHAN_SOFT_TIMESTAMP(rm hard coded value)
- comment edited to match changes & follow preferred kernel styleSigned-off-by Alison Schofield <[email protected]>--- drivers/staging/iio/iio_simple_dummy.c | 22 ++++++++++++---------- drivers/staging/iio/iio_simple_dummy.h | 20 +++++++++++--------- drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 28 insertions(+), 23 deletions(-)drivers/staging/iio/iio_simple_dummy.c +0
-0
drivers/staging/iio/iio_simple_dummy.c line 1
Quoted 2 lines
drivers/staging/iio/iio_simple_dummy.c +1
-1@@ -1,4 +1,4 @@ -/** +/*
This change should be in the 3rd patch.
Quoted 54 lines
drivers/staging/iio/iio_simple_dummy.c +7
-7* Copyright (c) 2011 Jonathan Cameron * * This program is free software; you can redistribute it and/or modify it @@ -137,7 +137,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {*/ .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), /* The ordering of elements in the buffer via an enum */ - .scan_index = voltage0, + .scan_index = INDEX_VOLTAGE_0, .scan_type = { /* Description of storage in buffer */ .sign = 'u', /* unsigned */ .realbits = 13, /* 13 bits */@@ -176,7 +176,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {* sampling_frequency * The frequency in Hz at which the channels are sampled */ - .scan_index = diffvoltage1m2, + .scan_index = INDEX_DIFFVOLTAGE_1M2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 12, /* 12 bits */@@ -194,7 +194,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = diffvoltage3m4, + .scan_index = INDEX_DIFFVOLTAGE_3M4, .scan_type = { .sign = 's', .realbits = 11,@@ -221,7 +221,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {BIT (IIO_CHAN_INFO_CALIBSCALE ) | BIT(IIO_CHAN_INFO_CALIBBIAS), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = accelx, + .scan_index = INDEX_ACCELX, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 16, /* 16 bits */@@ -230,10 +230,10 @@ static const struct iio_chan_spec iio_dummy_channels[] = { }, },/* -* Convenience macro for timestamps. 4 is the index in -* the buffer. +* Convenience macro for timestamps. +* INDEX_TIMESTAMP is the index in the buffer. */ -IIO_CHAN_SOFT_TIMESTAMP (4 ), +IIO_CHAN_SOFT_TIMESTAMP (INDEX_TIMESTAMP ),/* DAC channel out_voltage0_raw */ { .type = IIO_VOLTAGE,
drivers/staging/iio/iio_simple_dummy.c static int iio_dummy_read_raw(struct iio_dev *indio_dev, · line 370
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c +4
-2@@ -364,8 +364,10 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret =IIO_VAL_INT_PLUS_MICRO ;break ;case 1 : -/* all differential adc channels -> -* 0.000001344 */ +/* +* all differential adc +* channels -> 0.000001344 +*/
Also this one. Could this be a one line comment?
Quoted 60 lines
drivers/staging/iio/iio_simple_dummy.c +0
-0*val =0 ; *val2 =1344 ; ret =IIO_VAL_INT_PLUS_NANO ;drivers/staging/iio/iio_simple_dummy.h +11
-9@@ -96,20 +96,22 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ -/** +/* * enum iio_simple_dummy_scan_elements - scan index enum -* @voltage0: the single ended voltage channel -* @diffvoltage1m2: first differential channel -* @diffvoltage3m4: second differenial channel -* @accelx: acceleration channel +* @INDEX_VOLTAGE_0: the single ended voltage channel +* @INDEX_DIFFVOLTAGE_1M2: first differential channel +* @INDEX_DIFFVOLTAGE_3M4: second differential channel +* @INDEX_ACCELX: acceleration channel +* @INDEX_TIMESTAMP: timestamp channel * * Enum provides convenient numbering for the scan index. */ enum iio_simple_dummy_scan_elements { - voltage0, - diffvoltage1m2, - diffvoltage3m4, - accelx, +INDEX_VOLTAGE_0 , +INDEX_DIFFVOLTAGE_1M2 , +INDEX_DIFFVOLTAGE_3M4 , +INDEX_ACCELX , +INDEX_TIMESTAMP , };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER drivers/staging/iio/iio_simple_dummy_buffer.c +5
-4@@ -27,10 +27,11 @@/* Some fake data */ static const s16 fakedata[] = { - [voltage0] =7 , - [diffvoltage1m2] =-33 , - [diffvoltage3m4] =-2 , - [accelx] =344 , + [INDEX_VOLTAGE_0 ] =7 , + [INDEX_DIFFVOLTAGE_1M2 ] =-33 , + [INDEX_DIFFVOLTAGE_3M4 ] =-2 , + [INDEX_ACCELX ] =344 , + [INDEX_TIMESTAMP ] =50 , };/**
Quoted 16 lines · Daniel Baluta
Quoted 13 lines · Alison Schofield
Cleanups related to the usage of
dummy_scan_elementsin the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum forIIO_CHAN_SOFT_TIMESTAMP(rm hard coded value)
- comment edited to match changes & follow preferred kernel styleSigned-off-by Alison Schofield <[email protected]>--- drivers/staging/iio/iio_simple_dummy.c | 22 ++++++++++++---------- drivers/staging/iio/iio_simple_dummy.h | 20 +++++++++++--------- drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 28 insertions(+), 23 deletions(-)
Quoted 9 lines
drivers/staging/iio/iio_simple_dummy.c line 1
Quoted 7 lines
drivers/staging/iio/iio_simple_dummy.c +1
-1@@ -1,4 +1,4 @@ -/** +/* This change should be in the 3rd patch.
Thanks for the eagle eyes! I see this (and the other comment I edit'd also.) It leads to another question.
In these dummy files, there are 27 comment blocks that start with /** instead of /* . I touched 2 of them as a passerby, but now that I'm looking.... should I change them all or is /** that an acceptable variation.
alison
< snip >
Quoted 38 lines · Alison Schofield
Quoted 9 lines · Daniel Baluta
Quoted 6 lines · Alison Schofield
Cleanups related to the usage of
dummy_scan_elementsin the iio dummy driver:
- change enum names to upper case INDEX_*
- use the enum forIIO_CHAN_SOFT_TIMESTAMP(rm hard coded value)
- comment edited to match changes & follow preferred kernel styleQuoted 3 lines
Quoted 3 lines
Signed-off-by Alison Schofield <[email protected]>--- drivers/staging/iio/iio_simple_dummy.c | 22++++++++++++----------
Quoted 1 line
Quoted 1 line
drivers/staging/iio/iio_simple_dummy.h | 20+++++++++++---------
Quoted 4 lines
Review
Quoted 4 lines
drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 28 insertions(+), 23 deletions(-)(quoted diff) +0
-0
b/drivers/staging/iio/iio_simple_dummy.cQuoted 8 lines
drivers/staging/iio/iio_simple_dummy.c line 1
Quoted 6 lines
index 381f90f..5e19068 100644
drivers/staging/iio/iio_simple_dummy.c +1
-1@@ -1,4 +1,4 @@ -/** +/* This change should be in the 3rd patch.
Thanks for the eagle eyes! I see this (and the other comment I edit'd also.) It leads to another question.
In these dummy files, there are 27 comment blocks that start with /** instead of /* . I touched 2 of them as a passerby, but now that I'm looking.... should I change them all or is /** that an acceptable
variation.
Quoted 4 lines
alison
< snip >
Good thing you raised this as one instance in the patch was an incorrect change away from **
Basically it should have two stars if kernel-doc (formal kernel documentation) and one star if a straightforward inline
comment. See Documentation/kernel-doc-nano-howto.txt
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
cover iio: dummy: scan index enum update and clean up
In reply to Alison SchofieldThis patchset obsoletes the prior single patch:
[PATCH] staging: iio: dummy: clean up the define and usage of dummy_scan_elements
It is split into 3 patches that
1) udpate the existing enum list
2) add timestamp to the enum list
3) cleans one block comment checkpatch err
Changes (other than splitting) since it was a single patch:
- prefaced index names with DUMMY_ to be more descriptive
- fit that block comment on one line by following model of preceeding comment
- did not touch /** comments as they are used for extracting docs
Alison Schofield (3):
staging: iio: dummy: use uppercase descriptors for enum names
staging: iio: dummy: add the timestamp buffer to the scan index enum
staging: iio: dummy: replace block comment with single line comment
drivers/staging/iio/iio_simple_dummy.c | 17 ++++++++--------- drivers/staging/iio/iio_simple_dummy.h | 18 ++++++++++-------- drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++++---- 3 files changed, 23 insertions(+), 21 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/3 staging: iio: dummy: use uppercase descriptors for enum names
Replace lower case names in the enum dummy_scan_elements with uppercase names and a descriptive prefix: DUMMY_INDEX_
--- drivers/staging/iio/iio_simple_dummy.c | 8 ++++---- drivers/staging/iio/iio_simple_dummy.h | 16 ++++++++-------- drivers/staging/iio/iio_simple_dummy_buffer.c | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/staging/iio/iio_simple_dummy.c +4 -4
@@ -137,7 +137,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {*/ .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), /* The ordering of elements in the buffer via an enum */ - .scan_index = voltage0, + .scan_index = DUMMY_INDEX_VOLTAGE_0, .scan_type = { /* Description of storage in buffer */ .sign = 'u', /* unsigned */ .realbits = 13, /* 13 bits */
@@ -176,7 +176,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {* sampling_frequency * The frequency in Hz at which the channels are sampled */ - .scan_index = diffvoltage1m2, + .scan_index = DUMMY_INDEX_DIFFVOLTAGE_1M2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 12, /* 12 bits */
@@ -194,7 +194,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = diffvoltage3m4, + .scan_index = DUMMY_INDEX_DIFFVOLTAGE_3M4, .scan_type = { .sign = 's', .realbits = 11,
@@ -221,7 +221,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {BIT (IIO_CHAN_INFO_CALIBSCALE ) | BIT(IIO_CHAN_INFO_CALIBBIAS), .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .scan_index = accelx, + .scan_index = DUMMY_INDEX_ACCELX, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */ .realbits = 16, /* 16 bits */
drivers/staging/iio/iio_simple_dummy.h +8 -8
@@ -98,18 +98,18 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)/** * enum iio_simple_dummy_scan_elements - scan index enum -* @voltage0: the single ended voltage channel -* @diffvoltage1m2: first differential channel -* @diffvoltage3m4: second differenial channel -* @accelx: acceleration channel +* @DUMMY_INDEX_VOLTAGE_0: the single ended voltage channel +* @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel +* @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel +* @DUMMY_INDEX_ACCELX: acceleration channel * * Enum provides convenient numbering for the scan index. */ enum iio_simple_dummy_scan_elements { - voltage0, - diffvoltage1m2, - diffvoltage3m4, - accelx, +DUMMY_INDEX_VOLTAGE_0 , +DUMMY_INDEX_DIFFVOLTAGE_1M2 , +DUMMY_INDEX_DIFFVOLTAGE_3M4 , +DUMMY_INDEX_ACCELX , };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
drivers/staging/iio/iio_simple_dummy_buffer.c +4 -4
@@ -27,10 +27,10 @@/* Some fake data */ static const s16 fakedata[] = { - [voltage0] =7 , - [diffvoltage1m2] =-33 , - [diffvoltage3m4] =-2 , - [accelx] =344 , + [DUMMY_INDEX_VOLTAGE_0 ] =7 , + [DUMMY_INDEX_DIFFVOLTAGE_1M2 ] =-33 , + [DUMMY_INDEX_DIFFVOLTAGE_3M4 ] =-2 , + [DUMMY_INDEX_ACCELX ] =344 , };/**
Signature · 1 line
2.1.4
PATCH 2/3 staging: iio: dummy: add the timestamp buffer to the scan index enum
In reply to Alison SchofieldReplace the hard coded buffer index for IIO_CHAN SOFT_TIMESTAMP with an entry in the scan index enum.
--- drivers/staging/iio/iio_simple_dummy.c | 6 +++--- drivers/staging/iio/iio_simple_dummy.h | 2 ++ drivers/staging/iio/iio_simple_dummy_buffer.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)
drivers/staging/iio/iio_simple_dummy.c +3 -3
@@ -230,10 +230,10 @@ static const struct iio_chan_spec iio_dummy_channels[] = { }, },/* -* Convenience macro for timestamps. 4 is the index in -* the buffer. +* Convenience macro for timestamps. +* DUMMY_INDEX_TIMESTAMP is the index in the buffer. */ -IIO_CHAN_SOFT_TIMESTAMP (4 ), +IIO_CHAN_SOFT_TIMESTAMP (DUMMY_INDEX_TIMESTAMP ),/* DAC channel out_voltage0_raw */ { .type = IIO_VOLTAGE,
drivers/staging/iio/iio_simple_dummy.h +2 -0
@@ -102,6 +102,7 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)* @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel * @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel * @DUMMY_INDEX_ACCELX: acceleration channel +* @DUMMY_INDEX_TIMESTAMP: timestamp channel * * Enum provides convenient numbering for the scan index. */
@@ -110,6 +111,7 @@ enum iio_simple_dummy_scan_elements {DUMMY_INDEX_DIFFVOLTAGE_1M2 ,DUMMY_INDEX_DIFFVOLTAGE_3M4 ,DUMMY_INDEX_ACCELX , + DUMMY_INDEX_TIMESTAMP, };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
drivers/staging/iio/iio_simple_dummy_buffer.c +1 -0
@@ -31,6 +31,7 @@ static const s16 fakedata[] = { [DUMMY_INDEX_DIFFVOLTAGE_1M2] = -33, [DUMMY_INDEX_DIFFVOLTAGE_3M4] = -2, [DUMMY_INDEX_ACCELX] = 344, + [DUMMY_INDEX_TIMESTAMP] = 50, };/**
Signature · 1 line
2.1.4
Greg KH
maintainerRe: [Outreachy kernel] [PATCH 2/3] staging: iio: dummy: add the timestamp buffer to the scan index enum
Quoted 53 lines · Alison Schofield
Replace the hard coded buffer index for
IIO_CHANSOFT_TIMESTAMPwith an entry in the scan index enum.Signed-off-by Alison Schofield <[email protected]>--- drivers/staging/iio/iio_simple_dummy.c | 6 +++--- drivers/staging/iio/iio_simple_dummy.h | 2 ++ drivers/staging/iio/iio_simple_dummy_buffer.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-)drivers/staging/iio/iio_simple_dummy.c +3
-3@@ -230,10 +230,10 @@ static const struct iio_chan_spec iio_dummy_channels[] = { }, },/* -* Convenience macro for timestamps. 4 is the index in -* the buffer. +* Convenience macro for timestamps. +* DUMMY_INDEX_TIMESTAMP is the index in the buffer. */ -IIO_CHAN_SOFT_TIMESTAMP (4 ), +IIO_CHAN_SOFT_TIMESTAMP (DUMMY_INDEX_TIMESTAMP ),/* DAC channel out_voltage0_raw */ { .type = IIO_VOLTAGE,drivers/staging/iio/iio_simple_dummy.h +2
-0@@ -102,6 +102,7 @@ iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)* @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel * @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel * @DUMMY_INDEX_ACCELX: acceleration channel +* @DUMMY_INDEX_TIMESTAMP: timestamp channel * * Enum provides convenient numbering for the scan index. */ @@ -110,6 +111,7 @@ enum iio_simple_dummy_scan_elements {DUMMY_INDEX_DIFFVOLTAGE_1M2 ,DUMMY_INDEX_DIFFVOLTAGE_3M4 ,DUMMY_INDEX_ACCELX , + DUMMY_INDEX_TIMESTAMP, };#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER drivers/staging/iio/iio_simple_dummy_buffer.c +0
-0
drivers/staging/iio/iio_simple_dummy_buffer.c static const s16 fakedata[] = { · line 34
Quoted 4 lines
drivers/staging/iio/iio_simple_dummy_buffer.c +1
-0@@ -31,6 +31,7 @@ static const s16 fakedata[] = { [DUMMY_INDEX_DIFFVOLTAGE_1M2] = -33, [DUMMY_INDEX_DIFFVOLTAGE_3M4] = -2, [DUMMY_INDEX_ACCELX] = 344, + [DUMMY_INDEX_TIMESTAMP] = 50,
You just increased the size of this structure, why?
PATCH 3/3 staging: iio: dummy: replace block comment with single line comment
In reply to Alison SchofieldReplace one block comment with a single line comment. Follow style of previous comment and omit word channel, since it's clear the topic is channels.
Addresses checkpatch.pl:
WARNING: Block comments use * on subsequent lines
--- drivers/staging/iio/iio_simple_dummy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/iio/iio_simple_dummy.c +1 -2
@@ -364,8 +364,7 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret =IIO_VAL_INT_PLUS_MICRO ;break ;case 1 : -/* all differential adc channels -> -* 0.000001344 */ +/* all differential adc -> 0.000001344 */ *val =0 ; *val2 =1344 ; ret =IIO_VAL_INT_PLUS_NANO ;
Signature · 1 line
2.1.4