staging: greybus: fix warnings about endianness detected by sparse
Subsystems (4)
PATCH 1/3 staging: greybus: fix warnings about endianness detected by sparse
This patch fix the following warnings from sparse,
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_module.c:222:25: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_module.c:222:25: expected restricted __le16 [usertype] data_cport drivers/staging/greybus/audio_module.c:222:25: got unsigned short [usertype] intf_cport_id drivers/staging/greybus/audio_topology.c:460:40: warning: restricted __le32 degrades to integer drivers/staging/greybus/audio_topology.c:691:41: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_topology.c:691:41: expected unsigned int access drivers/staging/greybus/audio_topology.c:691:41: got restricted __le32 [usertype] access drivers/staging/greybus/audio_topology.c:746:44: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_topology.c:746:44: expected unsigned int drivers/staging/greybus/audio_topology.c:746:44: got restricted __le32 drivers/staging/greybus/audio_topology.c:748:52: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_topology.c:748:52: expected unsigned int drivers/staging/greybus/audio_topology.c:748:52: got restricted __le32 drivers/staging/greybus/audio_topology.c:802:42: warning: restricted __le32 degrades to integer drivers/staging/greybus/audio_topology.c:805:50: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_topology.c:805:50: expected restricted __le32 drivers/staging/greybus/audio_topology.c:805:50: got unsigned int drivers/staging/greybus/audio_topology.c:814:50: warning: restricted __le32 degrades to integer drivers/staging/greybus/audio_topology.c:817:58: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_topology.c:817:58: expected restricted __le32 drivers/staging/greybus/audio_topology.c:817:58: got unsigned int drivers/staging/greybus/audio_topology.c:889:25: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_topology.c:889:25: expected unsigned int access drivers/staging/greybus/audio_topology.c:889:25: got restricted __le32 [usertype] access
--- drivers/staging/greybus/audio_module.c | 6 +++--- drivers/staging/greybus/audio_topology.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/staging/greybus/audio_module.c +3 -3
@@ -219,7 +219,7 @@ static int gb_audio_add_data_connection(struct gbaudio_module_info *gbmodule,greybus_set_drvdata (bundle, gbmodule); dai->id =0 ; - dai->data_cport = connection->intf_cport_id; + dai->data_cport =cpu_to_le16 (connection->intf_cport_id); dai->connection = connection;list_add (&dai->list, &gbmodule->data_list);
@@ -329,7 +329,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,if (ret) {dev_err (dev,"%d:Error while enabling %d:data connection\n" , - ret, dai->data_cport); + ret,le16_to_cpu (dai->data_cport)); goto disable_data_connection; } }
@@ -451,7 +451,7 @@ static int gb_audio_resume(struct device *dev)if (ret) {dev_err (dev,"%d:Error while enabling %d:data connection\n" , - ret, dai->data_cport); + ret,le16_to_cpu (dai->data_cport));return ret; } }
drivers/staging/greybus/audio_topology.c +9 -9
@@ -466,7 +466,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, goto exit;/* update ucontrol */ -if (gbvalue.value.integer_value[0 ] != val) { +if (gbvalue.value.integer_value[0 ] !=cpu_to_le32 (val)) {for (wi =0 ; wi < wlist->num_widgets; wi++) { widget = wlist->widgets[wi]; snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
@@ -689,7 +689,7 @@ static int gbaudio_tplg_create_kcontrol(struct gbaudio_module_info *gb,return -ENOMEM ; ctldata->ctl_id = ctl->id; ctldata->data_cport =le16_to_cpu (ctl->data_cport); - ctldata->access = ctl->access; + ctldata->access =le32_to_cpu (ctl->access); ctldata->vcount = ctl->count_values; ctldata->info = &ctl->info; *kctl = (struct snd_kcontrol_new)
@@ -744,10 +744,10 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,return ret; } - ucontrol->value.enumerated.item[0 ] = gbvalue.value.enumerated_item[0 ]; + ucontrol->value.enumerated.item[0 ] =le32_to_cpu (gbvalue.value.enumerated_item[0 ]);if (e->shift_l != e->shift_r) ucontrol->value.enumerated.item[1 ] = - gbvalue.value.enumerated_item[1 ]; +le32_to_cpu (gbvalue.value.enumerated_item[1 ]);return 0 ; }
@@ -801,10 +801,10 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, mask = e->mask << e->shift_l;if (gbvalue.value.enumerated_item[0 ] != - ucontrol->value.enumerated.item[0 ]) { +cpu_to_le32 (ucontrol->value.enumerated.item[0 ])) { change =1 ; gbvalue.value.enumerated_item[0 ] = - ucontrol->value.enumerated.item[0 ]; +cpu_to_le32 (ucontrol->value.enumerated.item[0 ]); }if (e->shift_l != e->shift_r) {
@@ -813,10 +813,10 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, val |= ucontrol->value.enumerated.item[1 ] << e->shift_r; mask |= e->mask << e->shift_r;if (gbvalue.value.enumerated_item[1 ] != - ucontrol->value.enumerated.item[1 ]) { +cpu_to_le32 (ucontrol->value.enumerated.item[1 ])) { change =1 ; gbvalue.value.enumerated_item[1 ] = - ucontrol->value.enumerated.item[1 ]; +cpu_to_le32 (ucontrol->value.enumerated.item[1 ]); } }
@@ -887,7 +887,7 @@ static int gbaudio_tplg_create_mixer_ctl(struct gbaudio_module_info *gb,return -ENOMEM ; ctldata->ctl_id = ctl->id; ctldata->data_cport =le16_to_cpu (ctl->data_cport); - ctldata->access = ctl->access; + ctldata->access =le32_to_cpu (ctl->access); ctldata->vcount = ctl->count_values; ctldata->info = &ctl->info; *kctl = (struct snd_kcontrol_new)
Signature · 1 line
2.28.0
PATCH 2/3 staging: greybus: codecs: use SNDRV_PCM_FMTBIT_S16_LE for format bitmask
snd_soc_pcm_stream.formats should use the bitmask SNDRV_PCM_FMTBIT_* instead of the sequential integers SNDRV_PCM_FORMAT_* as explained by commit e712bfca1ac1f63f622f87c2f33b57608f2a4d19
("ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask").
Found by sparse,
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_codec.c:691:36: warning: incorrect type in initializer (different base types) drivers/staging/greybus/audio_codec.c:691:36: expected unsigned long long [usertype] formats drivers/staging/greybus/audio_codec.c:691:36: got restricted snd_pcm_format_t [usertype] drivers/staging/greybus/audio_codec.c:701:36: warning: incorrect type in initializer (different base types) drivers/staging/greybus/audio_codec.c:701:36: expected unsigned long long [usertype] formats drivers/staging/greybus/audio_codec.c:701:36: got restricted snd_pcm_format_t [usertype]
--- drivers/staging/greybus/audio_codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/audio_codec.c +2 -2
@@ -688,7 +688,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = { .playback = { .stream_name = "I2S 0 Playback", .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FORMAT_S16_LE, + .formats = SNDRV_PCM_FMTBIT_S16_LE, .rate_max = 48000, .rate_min = 48000, .channels_min = 1,
@@ -698,7 +698,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = { .capture = { .stream_name = "I2S 0 Capture", .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FORMAT_S16_LE, + .formats = SNDRV_PCM_FMTBIT_S16_LE, .rate_max = 48000, .rate_min = 48000, .channels_min = 1,
Signature · 1 line
2.28.0
Re: [greybus-dev] [PATCH 2/3] staging: greybus: codecs: use SNDRV_PCM_FMTBIT_S16_LE for format bitmask
Quoted 6 lines · Coiby Xu
snd_soc_pcm_stream.formats should use the bitmask SNDRV_PCM_FMTBIT_* instead of the sequential integers SNDRV_PCM_FORMAT_* as explained by commit
e712bfca1ac1f63f622f87c2f33b57608f2a4d19
("ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask").Found by sparse,
Looks good.
Quoted 37 lines
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_codec.c:691:36: warning: incorrect type in initializer (different base types) drivers/staging/greybus/audio_codec.c:691:36: expected unsigned long long [usertype] formats drivers/staging/greybus/audio_codec.c:691:36: got restricted snd_pcm_format_t [usertype] drivers/staging/greybus/audio_codec.c:701:36: warning: incorrect type in initializer (different base types) drivers/staging/greybus/audio_codec.c:701:36: expected unsigned long long [usertype] formats drivers/staging/greybus/audio_codec.c:701:36: got restricted snd_pcm_format_t [usertype]Signed-off-by Coiby Xu <[email protected]>--- drivers/staging/greybus/audio_codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/greybus/audio_codec.c +2
-2@@ -688,7 +688,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = { .playback = { .stream_name = "I2S 0 Playback", .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FORMAT_S16_LE, + .formats = SNDRV_PCM_FMTBIT_S16_LE, .rate_max = 48000, .rate_min = 48000, .channels_min = 1,@@ -698,7 +698,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = { .capture = { .stream_name = "I2S 0 Capture", .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FORMAT_S16_LE, + .formats = SNDRV_PCM_FMTBIT_S16_LE, .rate_max = 48000, .rate_min = 48000, .channels_min = 1,
PATCH 3/3 staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
In reply to Coiby XuUse __8 to replace int and remove the unnecessary __bitwise type attribute.
Found by sparse,
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted snd_ctl_elem_type_t drivers/staging/greybus/audio_topology.c:679:14: warning: restricted snd_ctl_elem_iface_t degrades to integer drivers/staging/greybus/audio_topology.c:906:14: warning: restricted snd_ctl_elem_iface_t degrades to integer
--- drivers/staging/greybus/audio_topology.c | 2 +- include/uapi/sound/asound.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/greybus/audio_topology.c +1 -1
@@ -182,7 +182,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,/* update uinfo */ uinfo->access = data->access; uinfo->count = data->vcount; - uinfo->type = (snd_ctl_elem_type_t )info->type; + uinfo->type = info->type;switch (info->type) {case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN :
include/uapi/sound/asound.h +2 -2
@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128 ];/* card components / fine identification, delimited with one space (AC97 etc..) */ }; -typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)/* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)/* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)/* integer type */
@@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t;#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6)/* 64-bit integer type */ #define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64 -typedef int __bitwise snd_ctl_elem_iface_t ; +typedef __u8 snd_ctl_elem_iface_t ;#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0)/* global control */ #define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1)/* hardware dependent device */ #define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2)/* virtual mixer device */
Signature · 1 line
2.28.0
RE: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
From: Coiby Xu
Quoted 4 lines
Sent: 24 September 2020 11:21
Use __8 to replace int and remove the unnecessary__bitwisetype attribute.Found by sparse,
...
Quoted 9 lines
include/uapi/sound/asound.h +0
-0@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128 ];/* card components / fine identification, delimited with one space (AC97 etc..) */
};
include/uapi/sound/asound.h struct snd_ctl_card_info { · line 956
Quoted 5 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)/* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)/* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)/* integer type */
WTF is all that about anyway??
What is wrong with:
#define SNDRV_CTL_ELEM_TYPE_NONE 0u /* invalid */
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
Quoted 15 lines · David Laight
From: Coiby Xu
Quoted 4 lines
Sent: 24 September 2020 11:21
Use __8 to replace int and remove the unnecessary__bitwisetype attribute.Found by sparse,
...
Quoted 9 lines
include/uapi/sound/asound.h +0
-0@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128 ];/* card components / fine identification, delimited with one space (AC97 etc..) */
};
Quoted 9 lines
include/uapi/sound/asound.h struct snd_ctl_card_info { · line 956
Quoted 5 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)/* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)/* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)/* integer type */ WTF is all that about anyway??
What is wrong with:
#defineSNDRV_CTL_ELEM_TYPE_NONE0u /* invalid */
I'm sorry I don't quite understand you. Are you suggesting SNDRV_CTL_ELEM_TYPE_NONE isn't needed in the first place?
Quoted 7 lines
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
--
Best regards,
Coiby
Re: [greybus-dev] [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
Quoted 26 lines · Coiby Xu
Quoted 15 lines · David Laight
From: Coiby Xu
Quoted 4 lines
Sent: 24 September 2020 11:21
Use __8 to replace int and remove the unnecessary__bitwisetype attribute.Found by sparse,
...
Quoted 9 lines
include/uapi/sound/asound.h +0
-0@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128]; /* card components / fine identification, delimited with one space (AC97 etc..) */
};Quoted 9 lines
Quoted 5 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((
__forcesnd_ctl_elem_type_t) 0) /* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__forcesnd_ctl_elem_type_t) 1) /* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__forcesnd_ctl_elem_type_t) 2) /* integer type */WTF is all that about anyway??
What is wrong with:
#define SNDRV_CTL_ELEM_TYPE_NONE 0u /* invalid */
Quoted 2 lines
I'm sorry I don't quite understand you. Are you suggesting
SNDRV_CTL_ELEM_TYPE_NONEisn't needed in the first place?
I think David is asking why it's defined the way it is, and I'd guess it's to have the compiler issue an error if you attempt to assign one of these values to a variable or field of the wrong type.
No, you should not attempt to change this.
-Alex
Quoted 14 lines
Quoted 6 lines
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)Signature · 6 lines
Best regards, Coiby _______________________________________________ greybus-dev mailing list [email protected] https://lists.linaro.org/mailman/listinfo/greybus-dev
Re: [greybus-dev] [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
Quoted 36 lines · Alex Elder
Quoted 31 lines · Coiby Xu
Quoted 17 lines · David Laight
From: Coiby Xu
Quoted 5 lines
Sent: 24 September 2020 11:21
Use __8 to replace int and remove the unnecessary__bitwisetype attribute.Found by sparse,
...
Quoted 10 lines
include/uapi/sound/asound.h +0
-0@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128]; /* card components / fine identification, delimited with one
space (AC97 etc..) */
};Quoted 12 lines
Quoted 8 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((
__forcesnd_ctl_elem_type_t) 0) /* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__forcesnd_ctl_elem_type_t) 1) /* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__forcesnd_ctl_elem_type_t) 2) /* integer type */WTF is all that about anyway??
What is wrong with:
#define SNDRV_CTL_ELEM_TYPE_NONE 0u /* invalid */Quoted 3 lines
I'm sorry I don't quite understand you. Are you suggesting
SNDRV_CTL_ELEM_TYPE_NONE
isn't needed in the first place?
Quoted 6 lines
I think David is asking why it's defined the way it is, and I'd guess it's to have the compiler issue an error if you attempt to assign one of these values to a variable or field of the wrong type.
No, you should not attempt to change this.
Thank you for the explanation!
Quoted 18 lines
-Alex
Quoted 15 lines
Quoted 7 lines
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)--
Best regards,
Coiby
_______________________________________________
greybus-dev mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/greybus-dev
--
Best regards,
Coiby
RE: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
In reply to Coiby XuFrom: Coiby Xu
Quoted 28 lines
Sent: 25 September 2020 15:11
Quoted 15 lines · David Laight
From: Coiby Xu
Quoted 4 lines
Sent: 24 September 2020 11:21
Use __8 to replace int and remove the unnecessary__bitwisetype attribute.Found by sparse,
...
Quoted 9 lines
include/uapi/sound/asound.h +0
-0@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128 ];/* card components / fine identification, delimited with one space (AC97 etc..) */
};Quoted 9 lines
include/uapi/sound/asound.h struct snd_ctl_card_info { · line 956
Quoted 5 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)/* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)/* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)/* integer type */ WTF is all that about anyway??
What is wrong with:
#defineSNDRV_CTL_ELEM_TYPE_NONE0u /* invalid */
Quoted 2 lines
I'm sorry I don't quite understand you. Are you suggesting
SNDRV_CTL_ELEM_TYPE_NONEisn't needed in the first place?
No, just remove all the casts from the constants.
Are the types even used anywhere else?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Greg Kroah-Hartman
maintainerRe: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
In reply to Coiby XuQuoted 42 lines · Coiby Xu
Use __8 to replace int and remove the unnecessary
__bitwisetype attribute.Found by sparse,
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted snd_ctl_elem_type_t drivers/staging/greybus/audio_topology.c:679:14: warning: restricted snd_ctl_elem_iface_t degrades to integer drivers/staging/greybus/audio_topology.c:906:14: warning: restricted snd_ctl_elem_iface_t degrades to integerSigned-off-by Coiby Xu <[email protected]>--- drivers/staging/greybus/audio_topology.c | 2 +- include/uapi/sound/asound.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/staging/greybus/audio_topology.c +1
-1@@ -182,7 +182,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,/* update uinfo */ uinfo->access = data->access; uinfo->count = data->vcount; - uinfo->type = (snd_ctl_elem_type_t )info->type; + uinfo->type = info->type;switch (info->type) {case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN :include/uapi/sound/asound.h +1
-1@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128 ];/* card components / fine identification, delimited with one space (AC97 etc..) */ }; -typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)/* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)/* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)/* integer type */
include/uapi/sound/asound.h typedef int __bitwise snd_ctl_elem_type_t; · line 966
Quoted 8 lines
include/uapi/sound/asound.h +1
-1@@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t;#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6)/* 64-bit integer type */ #define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64 -typedef int __bitwise snd_ctl_elem_iface_t ; +typedef __u8 snd_ctl_elem_iface_t ;#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0)/* global control */ #define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1)/* hardware dependent device */ #define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2)/* virtual mixer device */
I can't take a uapi sound header file patch along with a driver change, these need to be independant.
And this is a userspace api, you just changed the size of an externally facing variable, are you _SURE_ that is ok to do?
thanks,
greg k-h
Re: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
Quoted 46 lines · Greg Kroah-Hartman
Quoted 45 lines · Coiby Xu
Use __8 to replace int and remove the unnecessary
__bitwisetype attribute.Found by sparse,
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted snd_ctl_elem_type_t drivers/staging/greybus/audio_topology.c:679:14: warning: restricted snd_ctl_elem_iface_t degrades to integer drivers/staging/greybus/audio_topology.c:906:14: warning: restricted snd_ctl_elem_iface_t degrades to integerSigned-off-by Coiby Xu <[email protected]>--- drivers/staging/greybus/audio_topology.c | 2 +- include/uapi/sound/asound.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/staging/greybus/audio_topology.c +1
-1@@ -182,7 +182,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,/* update uinfo */ uinfo->access = data->access; uinfo->count = data->vcount; - uinfo->type = (snd_ctl_elem_type_t )info->type; + uinfo->type = info->type;switch (info->type) {case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN :include/uapi/sound/asound.h +1
-1@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128 ];/* card components / fine identification, delimited with one space (AC97 etc..) */ }; -typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)/* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)/* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)/* integer type */ @@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t;#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6)/* 64-bit integer type */ #define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64
Quoted 8 lines
include/uapi/sound/asound.h typedef int __bitwise snd_ctl_elem_type_t; · line 966
Quoted 5 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_iface_t ; +typedef __u8 snd_ctl_elem_iface_t ;#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0)/* global control */ #define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1)/* hardware dependent device */ #define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2)/* virtual mixer device */ I can't take a uapi sound header file patch along with a driver change, these need to be independant.
Thank you and Alex for reminding me this is a change of public header!
Quoted 3 lines
And this is a userspace api, you just changed the size of an externally facing variable, are you _SURE_ that is ok to do?
The reasons I make this change are, 1) using int to represent 7 enumeration values seems to be overkill; 2) using one type could avoid worries about byte order.
I examine one userspace example (libalsa-intf/alsa_mixer.c [1]). This change won't cause compiling breakage. But I don't the experience to imagine any other bad consequence.
Another way to avoid userspace API change is to let
"struct gb_audio_ctl_elem_info" use snd_ctl_elem_iface_t type which may be more elegant than using "__force" as suggested by Alex,
$ git diff
include/linux/greybus/greybus_protocols.h +2 -1
@@ -8,6 +8,7 @@#define __GREYBUS_PROTOCOLS_H#include <linux/types.h> +#include <sound/asound.h> /* Fixed IDs for control/svc protocols */
@@ -1997,7 +1998,7 @@ struct gb_audio_enumerated { } __packed;struct gb_audio_ctl_elem_info {/* See snd_ctl_elem_info in Linux source */ -__u8 type;/* GB_AUDIO_CTL_ELEM_TYPE_* */ +snd_ctl_elem_type_t type;/* GB_AUDIO_CTL_ELEM_TYPE_* */ __le16 dimen[4 ];union {struct gb_audio_integer integer
My only concern is if greybus authors have any special reason to not include sound/asound.h in the first place and re-define things like SNDRV_CTL_ELEM_TYPE_*,
/* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
#define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01
#define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02
/* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
#define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00
...
/* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
#define GB_AUDIO_ACCESS_READ BIT(0)
...
[1] https://gitlab.com/Codeaurora/platform_hardware_qcom_audio/-/blob/aee6032826ec7c8b6edda404422fda0ef40ec2db/libalsa-intf/alsa_mixer.c
alsa_mixer.c
Quoted 4 lines
thanks,
greg k-h
--
Best regards,
Coiby
Re: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
Quoted 5 lines · Coiby Xu
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines · Coiby Xu
Use __8 to replace int and remove the unnecessary
__bitwisetype attribute.Found by sparse,
. . .
Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
include/uapi/sound/asound.h +0
-0@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128]; /* card components / fine identification, delimited with one space (AC97 etc..) */ };
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((
__forcesnd_ctl_elem_type_t) 0) /* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__forcesnd_ctl_elem_type_t) 1) /* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__forcesnd_ctl_elem_type_t) 2) /* integer type */include/uapi/sound/asound.h +0
-0@@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t; #define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6) /* 64-bit integer type */ #define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64Quoted 8 lines
include/uapi/sound/asound.h typedef int __bitwise snd_ctl_elem_type_t; · line 966
Quoted 5 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_iface_t ; +typedef __u8 snd_ctl_elem_iface_t ; #define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0) /* global control */ #define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1) /* hardware dependent device */ #define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2) /* virtual mixer device */I can't take a uapi sound header file patch along with a driver change, these need to be independant.
Quoted 8 lines
Thank you and Alex for reminding me this is a change of public header!
Quoted 3 lines
And this is a userspace api, you just changed the size of an externally facing variable, are you _SURE_ that is ok to do?
The reasons I make this change are, 1) using int to represent 7 enumeration values seems to be overkill; 2) using one type could avoid worries about byte order.
(1) might be a valid suggestion, but the file you suggest changing is part of the Linux user space API, which you basically can't change.
I'm fairly certain the user space API is defined to have CPU-local byte order (unless specified explicitly otherwise) so that is not a concern.
Quoted 3 lines
I examine one userspace example (
libalsa-intf/alsa_mixer.c[1]). This change won't cause compiling breakage. But I don't the experience to imagine any other bad consequence.
As a rule, once the user space API has been established, it stays with us forever. You can add to it, but modifying (or removing) an existing interface is essentially forbidden.
Quoted 3 lines
Another way to avoid userspace API change is to let
"structgb_audio_ctl_elem_info" usesnd_ctl_elem_iface_ttype which may be more elegant than using "__force" as suggested by Alex,
The Greybus definitions were explicitly defined to be operating system independent. For that reason there are (admittedly cumbersome) definitions of certain types and values that essentially mimic those defined by Linux exactly That way Linux (or another system using Greybus) can change its internal values without changing the Greybus API definition. (This addresses the concern you mention below.)
What you are suggesting is not consistent with that principle.
-Alex
Quoted 51 lines
$ git diffinclude/linux/greybus/greybus_protocols.h +1
-0@@ -8,6 +8,7 @@ #define __GREYBUS_PROTOCOLS_H #include <linux/types.h> +#include <sound/asound.h> /* Fixed IDs for control/svc protocols */@@ -1997,7 +1998,7 @@ struct gb_audio_enumerated { } __packed; struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linuxsource */
- __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */ + snd_ctl_elem_type_t type; /* GB_AUDIO_CTL_ELEM_TYPE_* */
__le16 dimen[4];
union {
struct gb_audio_integer integerMy only concern is if greybus authors have any special reason to not include
sound/asound.hin the first place and re-define things like SNDRV_CTL_ELEM_TYPE_*,/* See SNDRV_CTL_ELEM_TYPE_* in Linux source */ #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN
0x01#define GB_AUDIO_CTL_ELEM_TYPE_INTEGER0x02/* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
#define GB_AUDIO_CTL_ELEM_IFACE_CARD0x00
.../* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
#define GB_AUDIO_ACCESS_READ BIT(0)
...alsa_mixer.c
Quoted 4 lines
thanks,
greg k-h
Signature · 2 lines
Best regards, Coiby
Re: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
Quoted 53 lines · Alex Elder
Quoted 6 lines · Coiby Xu
Quoted 5 lines · Greg Kroah-Hartman
Quoted 4 lines · Coiby Xu
Use __8 to replace int and remove the unnecessary
__bitwisetype attribute.Found by sparse,
. . .
Quoted 34 lines
Quoted 22 lines
Quoted 22 lines
include/uapi/sound/asound.h +0
-0@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128]; /* card components / fine identification, delimited with one space (AC97 etc..) */ };
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((
__forcesnd_ctl_elem_type_t) 0) /* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__forcesnd_ctl_elem_type_t) 1) /* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__forcesnd_ctl_elem_type_t) 2) /* integer type */include/uapi/sound/asound.h +0
-0@@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t; #define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force
snd_ctl_elem_type_t) 6) /* 64-bit integer type */
#define SNDRV_CTL_ELEM_TYPE_LASTSNDRV_CTL_ELEM_TYPE_INTEGER64Quoted 11 lines
Quoted 8 lines
include/uapi/sound/asound.h +1
-1-typedef int __bitwise snd_ctl_elem_iface_t ; +typedef __u8 snd_ctl_elem_iface_t ;#define SNDRV_CTL_ELEM_IFACE_CARD ((
__forcesnd_ctl_elem_iface_t) 0) /* global control */ #define SNDRV_CTL_ELEM_IFACE_HWDEP ((__forcesnd_ctl_elem_iface_t) 1) /* hardware dependent device */ #define SNDRV_CTL_ELEM_IFACE_MIXER ((__forcesnd_ctl_elem_iface_t) 2) /* virtual mixer device */I can't take a uapi sound header file patch along with a driver change, these need to be independant.
Quoted 8 lines
Thank you and Alex for reminding me this is a change of public header!
Quoted 3 lines
And this is a userspace api, you just changed the size of an externally facing variable, are you _SURE_ that is ok to do?
The reasons I make this change are, 1) using int to represent 7 enumeration values seems to be overkill; 2) using one type could avoid worries about byte order.
Quoted 7 lines
(1) might be a valid suggestion, but the file you suggest changing is part of the Linux user space API, which you basically can't change.
I'm fairly certain the user space API is defined to have CPU-local byte order (unless specified explicitly otherwise) so that is not a concern.
Thank you for sharing me about the byte order of user space API which prompts me to examine where "info->type" comes from,
uinfo->type = (snd_ctl_elem_type_t)info->type;
Eventually it comes from the parsed topology data which is obtained via gb_audio_gb_get_topology(gbmodule->mgmt_connection, &topology). But since (struct gb_audio_ctl_elem_info*)->type has __u8 type, there is no endianness concern. Then based on the principles of userspace API shouldn't be modified and greybus is operating system independent, your previous suggestion to use __force which means "I know what I'm doing" is actually a good idea,
uinfo->type = (__force snd_ctl_elem_type_t)info->type;
Quoted 21 lines
Quoted 3 lines
I examine one userspace example (
libalsa-intf/alsa_mixer.c[1]). This change won't cause compiling breakage. But I don't the experience to imagine any other bad consequence.As a rule, once the user space API has been established, it stays with us forever. You can add to it, but modifying (or removing) an existing interface is essentially forbidden.
Quoted 3 lines
Another way to avoid userspace API change is to let
"structgb_audio_ctl_elem_info" usesnd_ctl_elem_iface_ttype which may be more elegant than using "__force" as suggested by Alex,The Greybus definitions were explicitly defined to be operating system independent. For that reason there are (admittedly cumbersome) definitions of certain types and values that essentially mimic those defined by Linux exactly That way Linux (or another system using Greybus) can change its internal values without changing the Greybus API definition. (This addresses the concern you mention below.)
Quoted 61 lines
What you are suggesting is not consistent with that principle.
-Alex
Quoted 54 lines
$ git diffinclude/linux/greybus/greybus_protocols.h +1
-0@@ -8,6 +8,7 @@ #define __GREYBUS_PROTOCOLS_H #include <linux/types.h> +#include <sound/asound.h> /* Fixed IDs for control/svc protocols */@@ -1997,7 +1998,7 @@ struct gb_audio_enumerated { } __packed;struct
gb_audio_ctl_elem_info{ /* Seesnd_ctl_elem_infoin Linux source */
- __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */ + snd_ctl_elem_type_t type; /* GB_AUDIO_CTL_ELEM_TYPE_* */
__le16 dimen[4];
union {
struct gb_audio_integer integerMy only concern is if greybus authors have any special reason to not include
sound/asound.hin the first place and re-define things like SNDRV_CTL_ELEM_TYPE_*,/* See SNDRV_CTL_ELEM_TYPE_* in Linux source */ #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN
0x01#define GB_AUDIO_CTL_ELEM_TYPE_INTEGER0x02/* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
#define GB_AUDIO_CTL_ELEM_IFACE_CARD0x00
.../* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
#define GB_AUDIO_ACCESS_READ BIT(0)
...alsa_mixer.c
Quoted 4 lines
thanks,
greg k-h
--
Best regards,
Coiby
--
Best regards,
Coiby
Re: [greybus-dev] [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t
In reply to Coiby XuQuoted 3 lines · Coiby Xu
Use __8 to replace int and remove the unnecessary
__bitwisetype attribute.Found by sparse,
Greg's right, don't change the public header.
You could try this in the Greybus code to eliminate the warning, but I haven't tried it (and for all I know it's not a good idea):
uinfo->type = (__force snd_ctl_elem_type_t)info->type; -Alex
Quoted 47 lines
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted snd_ctl_elem_type_t drivers/staging/greybus/audio_topology.c:679:14: warning: restricted snd_ctl_elem_iface_t degrades to integer drivers/staging/greybus/audio_topology.c:906:14: warning: restricted snd_ctl_elem_iface_t degrades to integerSigned-off-by Coiby Xu <[email protected]>--- drivers/staging/greybus/audio_topology.c | 2 +- include/uapi/sound/asound.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/staging/greybus/audio_topology.c +1
-1@@ -182,7 +182,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,/* update uinfo */ uinfo->access = data->access; uinfo->count = data->vcount; - uinfo->type = (snd_ctl_elem_type_t )info->type; + uinfo->type = info->type;switch (info->type) {case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN :include/uapi/sound/asound.h +2
-2@@ -950,7 +950,7 @@ struct snd_ctl_card_info {unsigned char components[128 ];/* card components / fine identification, delimited with one space (AC97 etc..) */ }; -typedef int __bitwise snd_ctl_elem_type_t ; +typedef __u8 snd_ctl_elem_type_t ;#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0)/* invalid */ #define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1)/* boolean type */ #define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2)/* integer type */ @@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t;#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6)/* 64-bit integer type */ #define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64 -typedef int __bitwise snd_ctl_elem_iface_t ; +typedef __u8 snd_ctl_elem_iface_t ;#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0)/* global control */ #define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1)/* hardware dependent device */ #define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2)/* virtual mixer device */
Quoted 1 line · Coiby Xu
This patch fix the following warnings from sparse,
You need to address Greg's comment.
But in general this looks good. I have one comment below, which you can address in v2. If you (or others) disagree with it, I'm fine with your code as-is. Either way, you can add this:
Quoted 6 lines
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_module.c:222:25: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_module.c:222:25: expected restricted __le16 [usertype] data_cport drivers/staging/greybus/audio_module.c:222:25: got unsigned short [usertype] intf_cport_id drivers/staging/greybus/audio_topology.c:460:40: warning: restricted __le32 degrades to integer drivers/staging/greybus/audio_topology.c:691:41: warning: incorrect type in assignment (different base types)
. . .
drivers/staging/greybus/audio_topology.c static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, · line 469
Quoted 10 lines
drivers/staging/greybus/audio_topology.c +1
-1@@ -466,7 +466,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, goto exit;/* update ucontrol */ -if (gbvalue.value.integer_value[0 ] != val) { +if (gbvalue.value.integer_value[0 ] !=cpu_to_le32 (val)) {
It's equivalent, but I have a small preference to convert the value from gbvalue into CPU byte order rather than what you have here.
Quoted 61 lines
drivers/staging/greybus/audio_topology.c +8
-8for (wi =0 ; wi < wlist->num_widgets; wi++) { widget = wlist->widgets[wi]; snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,@@ -689,7 +689,7 @@ static int gbaudio_tplg_create_kcontrol(struct gbaudio_module_info *gb,return -ENOMEM ; ctldata->ctl_id = ctl->id; ctldata->data_cport =le16_to_cpu (ctl->data_cport); - ctldata->access = ctl->access; + ctldata->access =le32_to_cpu (ctl->access); ctldata->vcount = ctl->count_values; ctldata->info = &ctl->info; *kctl = (struct snd_kcontrol_new)@@ -744,10 +744,10 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,return ret; } - ucontrol->value.enumerated.item[0 ] = gbvalue.value.enumerated_item[0 ]; + ucontrol->value.enumerated.item[0 ] =le32_to_cpu (gbvalue.value.enumerated_item[0 ]);if (e->shift_l != e->shift_r) ucontrol->value.enumerated.item[1 ] = - gbvalue.value.enumerated_item[1 ]; +le32_to_cpu (gbvalue.value.enumerated_item[1 ]);return 0 ; }@@ -801,10 +801,10 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, mask = e->mask << e->shift_l;if (gbvalue.value.enumerated_item[0 ] != - ucontrol->value.enumerated.item[0 ]) { +cpu_to_le32 (ucontrol->value.enumerated.item[0 ])) { change =1 ; gbvalue.value.enumerated_item[0 ] = - ucontrol->value.enumerated.item[0 ]; +cpu_to_le32 (ucontrol->value.enumerated.item[0 ]); }if (e->shift_l != e->shift_r) {@@ -813,10 +813,10 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, val |= ucontrol->value.enumerated.item[1 ] << e->shift_r; mask |= e->mask << e->shift_r;if (gbvalue.value.enumerated_item[1 ] != - ucontrol->value.enumerated.item[1 ]) { +cpu_to_le32 (ucontrol->value.enumerated.item[1 ])) { change =1 ; gbvalue.value.enumerated_item[1 ] = - ucontrol->value.enumerated.item[1 ]; +cpu_to_le32 (ucontrol->value.enumerated.item[1 ]); } }@@ -887,7 +887,7 @@ static int gbaudio_tplg_create_mixer_ctl(struct gbaudio_module_info *gb,return -ENOMEM ; ctldata->ctl_id = ctl->id; ctldata->data_cport =le16_to_cpu (ctl->data_cport); - ctldata->access = ctl->access; + ctldata->access =le32_to_cpu (ctl->access); ctldata->vcount = ctl->count_values; ctldata->info = &ctl->info; *kctl = (struct snd_kcontrol_new)
Quoted 10 lines · Alex Elder
Quoted 1 line · Coiby Xu
This patch fix the following warnings from sparse,
You need to address Greg's comment.
But in general this looks good. I have one comment below, which you can address in v2. If you (or others) disagree with it, I'm fine with your code as-is. Either way, you can add this:
Reviewed-by Alex Elder <[email protected]>
Thank you fore reviewing this patch!
Quoted 17 lines
Quoted 7 lines
$ make C=2 drivers/staging/greybus/ drivers/staging/greybus/audio_module.c:222:25: warning: incorrect type in assignment (different base types) drivers/staging/greybus/audio_module.c:222:25: expected restricted __le16 [usertype] data_cport drivers/staging/greybus/audio_module.c:222:25: got unsigned short [usertype] intf_cport_id drivers/staging/greybus/audio_topology.c:460:40: warning: restricted __le32 degrades to integer drivers/staging/greybus/audio_topology.c:691:41: warning: incorrect type in assignment (different base types). . .
Quoted 7 lines
drivers/staging/greybus/audio_topology.c +0
-0@@ -466,7 +466,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, goto exit;
Quoted 7 lines
drivers/staging/greybus/audio_topology.c static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, · line 469
Quoted 3 lines
drivers/staging/greybus/audio_topology.c +1
-1/* update ucontrol */ -if (gbvalue.value.integer_value[0 ] != val) { +if (gbvalue.value.integer_value[0 ] !=cpu_to_le32 (val)) {It's equivalent, but I have a small preference to convert the value from gbvalue into CPU byte order rather than what you have here.
Thank you for the suggestion! I'll use CPU byte order when submitting next version.
Quoted 52 lines
Quoted 52 lines
drivers/staging/greybus/audio_topology.c +7
-7for (wi =0 ; wi < wlist->num_widgets; wi++) { widget = wlist->widgets[wi]; snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,@@ -689,7 +689,7 @@ static int gbaudio_tplg_create_kcontrol(struct gbaudio_module_info *gb,return -ENOMEM ; ctldata->ctl_id = ctl->id; ctldata->data_cport =le16_to_cpu (ctl->data_cport); - ctldata->access = ctl->access; + ctldata->access =le32_to_cpu (ctl->access); ctldata->vcount = ctl->count_values; ctldata->info = &ctl->info; *kctl = (struct snd_kcontrol_new)@@ -744,10 +744,10 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,return ret; } - ucontrol->value.enumerated.item[0 ] = gbvalue.value.enumerated_item[0 ]; + ucontrol->value.enumerated.item[0 ] =le32_to_cpu (gbvalue.value.enumerated_item[0 ]);if (e->shift_l != e->shift_r) ucontrol->value.enumerated.item[1 ] = - gbvalue.value.enumerated_item[1 ]; +le32_to_cpu (gbvalue.value.enumerated_item[1 ]);return 0 ; }@@ -801,10 +801,10 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, mask = e->mask << e->shift_l;if (gbvalue.value.enumerated_item[0 ] != - ucontrol->value.enumerated.item[0 ]) { +cpu_to_le32 (ucontrol->value.enumerated.item[0 ])) { change =1 ; gbvalue.value.enumerated_item[0 ] = - ucontrol->value.enumerated.item[0 ]; +cpu_to_le32 (ucontrol->value.enumerated.item[0 ]); }if (e->shift_l != e->shift_r) {@@ -813,10 +813,10 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, val |= ucontrol->value.enumerated.item[1 ] << e->shift_r; mask |= e->mask << e->shift_r;if (gbvalue.value.enumerated_item[1 ] != - ucontrol->value.enumerated.item[1 ]) { +cpu_to_le32 (ucontrol->value.enumerated.item[1 ])) { change =1 ; gbvalue.value.enumerated_item[1 ] = - ucontrol->value.enumerated.item[1 ]; +cpu_to_le32 (ucontrol->value.enumerated.item[1 ]); } }
Quoted 11 lines
drivers/staging/greybus/audio_topology.c static int gbaudio_tplg_create_mixer_ctl(struct gbaudio_module_info *gb, · line 893
Quoted 10 lines
drivers/staging/greybus/audio_topology.c +1
-1@@ -887,7 +887,7 @@ static int gbaudio_tplg_create_mixer_ctl(struct gbaudio_module_info *gb,return -ENOMEM ; ctldata->ctl_id = ctl->id; ctldata->data_cport =le16_to_cpu (ctl->data_cport); - ctldata->access = ctl->access; + ctldata->access =le32_to_cpu (ctl->access); ctldata->vcount = ctl->count_values; ctldata->info = &ctl->info; *kctl = (struct snd_kcontrol_new)
--
Best regards,
Coiby