From patchwork Wed Jul 25 21:24:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 10544843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7421DA517 for ; Wed, 25 Jul 2018 21:25:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F082AB67 for ; Wed, 25 Jul 2018 21:25:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5721C2AB96; Wed, 25 Jul 2018 21:25:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4A852AB67 for ; Wed, 25 Jul 2018 21:25:52 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0A20A267833; Wed, 25 Jul 2018 23:24:45 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id AA5D92677A1; Wed, 25 Jul 2018 23:24:25 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id CDCFA2677AA for ; Wed, 25 Jul 2018 23:24:17 +0200 (CEST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8ADA6B37E for ; Wed, 25 Jul 2018 21:24:16 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Wed, 25 Jul 2018 23:24:14 +0200 Message-Id: <20180725212414.19795-15-tiwai@suse.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180725212414.19795-1-tiwai@suse.de> References: <20180725212414.19795-1-tiwai@suse.de> Subject: [alsa-devel] [PATCH 14/14] ALSA: sb: Proper endian notations X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The data types defined in SB CSP driver code are all in little-endian, hence the proper type like __le32 should be used. Spotted by sparse, a warning like: sound/isa/sb/sb16_csp.c:330:14: warning: cast to restricted __le32 Signed-off-by: Takashi Iwai --- sound/isa/sb/sb16_csp.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 2210e7c72787..b9d67a7065cd 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -60,18 +60,18 @@ MODULE_FIRMWARE("sb16/ima_adpcm_capture.csp"); * RIFF data format */ struct riff_header { - __u32 name; - __u32 len; + __le32 name; + __le32 len; }; struct desc_header { struct riff_header info; - __u16 func_nr; - __u16 VOC_type; - __u16 flags_play_rec; - __u16 flags_16bit_8bit; - __u16 flags_stereo_mono; - __u16 flags_rates; + __le16 func_nr; + __le16 VOC_type; + __le16 flags_play_rec; + __le16 flags_16bit_8bit; + __le16 flags_stereo_mono; + __le16 flags_rates; }; /* @@ -314,7 +314,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, unsigned short func_nr = 0; struct riff_header file_h, item_h, code_h; - __u32 item_type; + __le32 item_type; struct desc_header funcdesc_h; unsigned long flags; @@ -326,7 +326,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, if (copy_from_user(&file_h, data_ptr, sizeof(file_h))) return -EFAULT; - if ((file_h.name != RIFF_HEADER) || + if ((le32_to_cpu(file_h.name) != RIFF_HEADER) || (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) { snd_printd("%s: Invalid RIFF header\n", __func__); return -EINVAL; @@ -336,7 +336,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, if (copy_from_user(&item_type, data_ptr, sizeof(item_type))) return -EFAULT; - if (item_type != CSP__HEADER) { + if (le32_to_cpu(item_type) != CSP__HEADER) { snd_printd("%s: Invalid RIFF file type\n", __func__); return -EINVAL; } @@ -346,12 +346,12 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, if (copy_from_user(&item_h, data_ptr, sizeof(item_h))) return -EFAULT; data_ptr += sizeof(item_h); - if (item_h.name != LIST_HEADER) + if (le32_to_cpu(item_h.name) != LIST_HEADER) continue; if (copy_from_user(&item_type, data_ptr, sizeof(item_type))) return -EFAULT; - switch (item_type) { + switch (le32_to_cpu(item_type)) { case FUNC_HEADER: if (copy_from_user(&funcdesc_h, data_ptr + sizeof(item_type), sizeof(funcdesc_h))) return -EFAULT; @@ -378,7 +378,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, return -EFAULT; /* init microcode blocks */ - if (code_h.name != INIT_HEADER) + if (le32_to_cpu(code_h.name) != INIT_HEADER) break; data_ptr += sizeof(code_h); err = snd_sb_csp_load_user(p, data_ptr, le32_to_cpu(code_h.len), @@ -391,7 +391,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, if (copy_from_user(&code_h, data_ptr, sizeof(code_h))) return -EFAULT; - if (code_h.name != MAIN_HEADER) { + if (le32_to_cpu(code_h.name) != MAIN_HEADER) { snd_printd("%s: Missing 'main' microcode\n", __func__); return -EINVAL; }