mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 06:09:23 -04:00
sound: usb: Fix incorrect type assignments
Change the map_pcm_format() helper to return a snd_pcm_format_t instead of a plain int to fix the following sparse warnings: sound/usb/usb_audio_qmi_svc.c:1135:26: expected restricted snd_pcm_format_t [usertype] pcm_format subs->pcm_format = pcm_format; sound/usb/usb_audio_qmi_svc.c:1135:26: got int [assigned] pcm_format subs->pcm_format = pcm_format; sound/usb/usb_audio_qmi_svc.c:1135:26: warning: incorrect type in assignment (different base types) subs->pcm_format = pcm_format; sound/usb/usb_audio_qmi_svc.c:962:24: expected int return SNDRV_PCM_FORMAT_S8; sound/usb/usb_audio_qmi_svc.c:962:24: got restricted snd_pcm_format_t [usertype] return SNDRV_PCM_FORMAT_S8; sound/usb/usb_audio_qmi_svc.c:962:24: warning: incorrect type in return expression (different base types) return SNDRV_PCM_FORMAT_S8; ... and so on. For these warnings: sound/usb/usb_audio_qmi_svc.c:559:47: expected unsigned short [usertype] usb_audio_spec_revision resp->usb_audio_spec_revision = sound/usb/usb_audio_qmi_svc.c:559:47: got restricted __le16 [usertype] bcdADC resp->usb_audio_spec_revision = sound/usb/usb_audio_qmi_svc.c:559:47: warning: incorrect type in assignment (different base types) resp->usb_audio_spec_revision = Fix these by passing the bcdADC value through le16_to_cpu before assigning to the usb_audio_spec_revision member. Change-Id: I0be5848846be7e29566a7854c5190634bce4347d Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
parent
a96556c936
commit
e61d2a2116
1 changed files with 16 additions and 10 deletions
|
|
@ -542,6 +542,8 @@ static int prepare_qmi_response(struct snd_usb_substream *subs,
|
|||
}
|
||||
|
||||
if (protocol == UAC_VERSION_1) {
|
||||
struct uac1_ac_header_descriptor *uac1_hdr = hdr_ptr;
|
||||
|
||||
as = find_csint_desc(alts->extra, alts->extralen,
|
||||
UAC_AS_GENERAL);
|
||||
if (!as) {
|
||||
|
|
@ -556,16 +558,16 @@ static int prepare_qmi_response(struct snd_usb_substream *subs,
|
|||
resp->usb_audio_subslot_size = fmt_v1->bSubframeSize;
|
||||
resp->usb_audio_subslot_size_valid = 1;
|
||||
|
||||
resp->usb_audio_spec_revision =
|
||||
((struct uac1_ac_header_descriptor *)hdr_ptr)->bcdADC;
|
||||
resp->usb_audio_spec_revision = le16_to_cpu(uac1_hdr->bcdADC);
|
||||
resp->usb_audio_spec_revision_valid = 1;
|
||||
} else if (protocol == UAC_VERSION_2) {
|
||||
struct uac2_ac_header_descriptor *uac2_hdr = hdr_ptr;
|
||||
|
||||
fmt_v2 = (struct uac_format_type_i_ext_descriptor *)fmt;
|
||||
resp->usb_audio_subslot_size = fmt_v2->bSubslotSize;
|
||||
resp->usb_audio_subslot_size_valid = 1;
|
||||
|
||||
resp->usb_audio_spec_revision =
|
||||
((struct uac2_ac_header_descriptor *)hdr_ptr)->bcdADC;
|
||||
resp->usb_audio_spec_revision = le16_to_cpu(uac2_hdr->bcdADC);
|
||||
resp->usb_audio_spec_revision_valid = 1;
|
||||
} else if (protocol == UAC_VERSION_3) {
|
||||
if (assoc->bFunctionSubClass ==
|
||||
|
|
@ -955,7 +957,7 @@ static void uaudio_dev_release(struct kref *kref)
|
|||
}
|
||||
|
||||
/* maps audio format received over QMI to asound.h based pcm format */
|
||||
static int map_pcm_format(unsigned int fmt_received)
|
||||
static snd_pcm_format_t map_pcm_format(enum usb_qmi_audio_format fmt_received)
|
||||
{
|
||||
switch (fmt_received) {
|
||||
case USB_QMI_PCM_FORMAT_S8:
|
||||
|
|
@ -995,7 +997,13 @@ static int map_pcm_format(unsigned int fmt_received)
|
|||
case USB_QMI_PCM_FORMAT_U32_BE:
|
||||
return SNDRV_PCM_FORMAT_U32_BE;
|
||||
default:
|
||||
return -EINVAL;
|
||||
/*
|
||||
* We expect the caller to do input validation so we should
|
||||
* never hit this. But we do have to return a proper
|
||||
* snd_pcm_format_t value due to the __bitwise attribute; so
|
||||
* just return the equivalent of 0 in case of bad input.
|
||||
*/
|
||||
return SNDRV_PCM_FORMAT_S8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1061,7 +1069,6 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
|
|||
struct usb_host_endpoint *ep;
|
||||
ktime_t t_request_recvd = ktime_get();
|
||||
|
||||
int pcm_format;
|
||||
u8 pcm_card_num, pcm_dev_num, direction;
|
||||
int info_idx = -EINVAL, datainterval = -EINVAL, ret = 0;
|
||||
|
||||
|
|
@ -1095,8 +1102,7 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
|
|||
goto response;
|
||||
}
|
||||
|
||||
pcm_format = map_pcm_format(req_msg->audio_format);
|
||||
if (pcm_format == -EINVAL) {
|
||||
if (req_msg->audio_format > USB_QMI_PCM_FORMAT_U32_BE) {
|
||||
uaudio_err("unsupported pcm format received %d\n",
|
||||
req_msg->audio_format);
|
||||
ret = -EINVAL;
|
||||
|
|
@ -1132,7 +1138,7 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
|
|||
}
|
||||
}
|
||||
|
||||
subs->pcm_format = pcm_format;
|
||||
subs->pcm_format = map_pcm_format(req_msg->audio_format);
|
||||
subs->channels = req_msg->number_of_ch;
|
||||
subs->cur_rate = req_msg->bit_rate;
|
||||
if (req_msg->service_interval_valid) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue