staging: greybus: audio: Fix sparse warning.
authorRajat Asthana <thisisrast7@gmail.com>
Wed, 19 May 2021 13:41:19 +0000 (19:11 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 May 2021 09:39:26 +0000 (11:39 +0200)
Sparse complains that:
   warning: restricted send_ctl_elem_iface_t degrades to integer.

I have looked at this code, and the code is fine as-is. Normally we
would frown on using the __force directive to silence Sparse warnings
but in this case it's fine. Case statements can't be made into __bitwise
types. We also can't change the type of "ctl->iface" either because that
is part of the user space API.

So just add a (__force int) to make the warning go away.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rajat Asthana <thisisrast7@gmail.com>
Link: https://lore.kernel.org/r/20210519134119.848055-1-thisisrast7@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/audio_topology.c

index 1fc7727ab7be188bdb1fb0b07cb9bbb36d4e61bc..1e613d42d8237669683f3d88c15d8cb0a40256f7 100644 (file)
@@ -676,7 +676,7 @@ static int gbaudio_tplg_create_kcontrol(struct gbaudio_module_info *gb,
        struct gbaudio_ctl_pvt *ctldata;
 
        switch (ctl->iface) {
-       case SNDRV_CTL_ELEM_IFACE_MIXER:
+       case (__force int)SNDRV_CTL_ELEM_IFACE_MIXER:
                switch (ctl->info.type) {
                case GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED:
                        ret = gbaudio_tplg_create_enum_kctl(gb, kctl, ctl);
@@ -903,7 +903,7 @@ static int gbaudio_tplg_create_wcontrol(struct gbaudio_module_info *gb,
        int ret;
 
        switch (ctl->iface) {
-       case SNDRV_CTL_ELEM_IFACE_MIXER:
+       case (__force int)SNDRV_CTL_ELEM_IFACE_MIXER:
                switch (ctl->info.type) {
                case GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED:
                        ret = gbaudio_tplg_create_enum_ctl(gb, kctl, ctl);