From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 565F7C4363D for ; Thu, 24 Sep 2020 12:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0091120708 for ; Thu, 24 Sep 2020 12:51:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JHElf2PW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbgIXMvH (ORCPT ); Thu, 24 Sep 2020 08:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727872AbgIXMu7 (ORCPT ); Thu, 24 Sep 2020 08:50:59 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50FFDC0613CE for ; Thu, 24 Sep 2020 05:50:59 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id m17so3188109ioo.1 for ; Thu, 24 Sep 2020 05:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=yci97FVNoqLlRiH8ruEJ8twEw2eGRL1tijxr6XUkGBI=; b=JHElf2PWOjGwZ2uGqH7qobKJsX+ZvpW9hBbaturH0ymHl3jqQXKYGjzEjtMjRa3HE8 z4LTPsAm2BVQe4Fpb+b+3kkRvex1/8a8QSb4hXcdZdo61FeCdyA4ZJYldevS5XEtWH4K yQdu2NmvSA1oNvP2CpbjmDw4PMCl1cNaotJ0vdWvwtOtGvPKWsJKM/PhWl6R8jPgRwHV cvAPl56Hx5QGJ1K+1lB2iARhS0XCZM02Lm0g2y+QDu2flTcBWp/KH/IplJMl393jqB4D MI2JCMBT25qIeN5e93GN9vttRCrrkb0yR8TWyCshVOJ99lk4owc9yo+sUasPbPVEuFM5 wQNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yci97FVNoqLlRiH8ruEJ8twEw2eGRL1tijxr6XUkGBI=; b=CPifVx7hZpAOuXE0jWaF754lfiqDBqnR81gwrwxc8jw6kW3EdU0zUW8b2PKhCkoUHD szD8I8XZq49/0z01OhgbiCa+U9fwNdcQUEgxVP4Nqo9Zphxb1fKhlr5zs9dnx4sA7Yte D+8ggoWx0q4DIOMHtY/dantCBTctgfYhazJ3hbsrZI0JnesF0pZ0eH5D2G3BVLFH7+L/ tV513uoeXmu/BC5RbXwHMhK6qpEVYVxwlZW98AOSo5kL7USgzTcZqUv7bTlf+VJSqBRS pmotblHDAnzaoK8a8QTqNE2zryB80nO3TT0KGvduzZXr+Vg1c5FwJ7/txzkOc7UuZFtj RYVw== X-Gm-Message-State: AOAM533P6ghxL7ihAA5I23kHRHaHMxR7auhCaOt6PQQENXDPoqcBEZ8i ElaFtcIMz1df64eYOG3zSCrR9w== X-Google-Smtp-Source: ABdhPJzaged4vDsro/WE+/3g9Zsw+yRfl5m3gs3sYiODiGd7MU1eY5SZdtkuu865SPBj3w6YjL19yQ== X-Received: by 2002:a6b:7c07:: with SMTP id m7mr3226609iok.32.1600951858531; Thu, 24 Sep 2020 05:50:58 -0700 (PDT) Received: from [172.22.22.26] (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.googlemail.com with ESMTPSA id l131sm1355977ioa.31.2020.09.24.05.50.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2020 05:50:58 -0700 (PDT) Subject: Re: [greybus-dev] [PATCH 1/3] [PATCH] staging: greybus: fix warnings about endianness detected by sparse To: Coiby Xu , devel@driverdev.osuosl.org Cc: Alex Elder , open list , Johan Hovold , "moderated list:GREYBUS SUBSYSTEM" , Dan Carpenter References: <20200924102039.43895-1-coiby.xu@gmail.com> From: Alex Elder Message-ID: <3fda9226-6f6f-6c5f-aa02-c9047a3d2dce@linaro.org> Date: Thu, 24 Sep 2020 07:50:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200924102039.43895-1-coiby.xu@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/24/20 5:20 AM, Coiby Xu wrote: > 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 > $ 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) . . . > diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c > index 83b38ae8908c..56bf1a4f95ad 100644 > --- a/drivers/staging/greybus/audio_topology.c > +++ b/drivers/staging/greybus/audio_topology.c > @@ -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. > 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) >