diff mbox

ASoC: soc-core: Fix sparse warning in be32_to_cpup() call

Message ID 1442476977-4284-1-git-send-email-jsarha@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jyri Sarha Sept. 17, 2015, 8:02 a.m. UTC
Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 sound/soc/soc-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown Sept. 17, 2015, 9:22 a.m. UTC | #1
On Thu, Sep 17, 2015 at 11:02:57AM +0300, Jyri Sarha wrote:

>  	val /= sizeof(u32);
>  	for (i = 0; i < val; i++)
> -		if (be32_to_cpup(&of_slot_mask[i]))
> +		if (be32_to_cpup((__be32 *)&of_slot_mask[i]))
>  			*mask |= (1 << i);
>  

There was no changelog and this is setting off alarm bells since the
cast just smashes warnings - are you sure we're not missing some other
annotations and that a cast is the best thing here?
Jyri Sarha Sept. 17, 2015, 9:33 a.m. UTC | #2
On 09/17/15 12:22, Mark Brown wrote:
> On Thu, Sep 17, 2015 at 11:02:57AM +0300, Jyri Sarha wrote:
>
>>   	val /= sizeof(u32);
>>   	for (i = 0; i < val; i++)
>> -		if (be32_to_cpup(&of_slot_mask[i]))
>> +		if (be32_to_cpup((__be32 *)&of_slot_mask[i]))
>>   			*mask |= (1 << i);
>>
>
> There was no changelog and this is setting off alarm bells since the
> cast just smashes warnings - are you sure we're not missing some other
> annotations and that a cast is the best thing here?
>

You are right, I was a bit hasty. It is better to declare of_slot_mask 
to const __be32 * in the first place, instead of just const u32 * and 
then casting it to something else.

I'll send a new patch shortly.

BR,
Jyri
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1929f0e..614b831 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3301,7 +3301,7 @@  static int snd_soc_of_get_slot_mask(struct device_node *np,
 		return 0;
 	val /= sizeof(u32);
 	for (i = 0; i < val; i++)
-		if (be32_to_cpup(&of_slot_mask[i]))
+		if (be32_to_cpup((__be32 *)&of_slot_mask[i]))
 			*mask |= (1 << i);
 
 	return val;