[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9628fe5d-62c0-b761-967b-357287e99a3e@wanadoo.fr>
Date: Thu, 6 Apr 2023 20:35:41 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: "Ding, Shenghao" <shenghao-ding@...com>,
Amadeusz Slawinski <amadeuszx.slawinski@...ux.intel.com>
Cc: "Lu, Kevin" <kevin-lu@...com>,
"alsa-devel@...a-project.org" <alsa-devel@...a-project.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Xu, Baojun" <x1077012@...com>, "Gupta, Peeyush" <peeyush@...com>,
"Navada Kanyana, Mukund" <navada@...com>,
Shenghao Ding <13916275206@....com>,
"broonie@...nel.org" <broonie@...nel.org>,
"lgirdwood@...il.com" <lgirdwood@...il.com>,
"perex@...ex.cz" <perex@...ex.cz>,
"pierre-louis.bossart@...ux.intel.com"
<pierre-louis.bossart@...ux.intel.com>
Subject: Re: RE: [EXTERNAL] Re: [PATCH v10] ASoC: tas2781: Add tas2781 driver
Le 05/04/2023 à 13:21, Ding, Shenghao a écrit :
> Hi Both
> I wrote a test code to verify the be32_to_cpu & be32_to_cpup,
> static int __init lkm_init(void)
> {
> char test_buf[]={0x12, 0x34, 0xab, 0xbc, 0x56, 0x78, 0xef};
> unsigned int *k, p, q;
> int i;
>
> printk("Hello, Shanghai!\n");
>
> for (i = 0; i < 4; i ++) {
> k = (unsigned int *)&test_buf[i];
> p = be32_to_cpup((__be32 *)k);
> q = be32_to_cpu(test_buf[i]);
> printk("%d: *k = 0x%08x p = 0x%08x q = 0x%08x %ld\n",
> i, *k, p, q, sizeof(unsigned int));
> }
> return 0;
> }
> The output is:
> [ 9109.722548] Hello, Shanghai!
> [ 9109.726287] 0: *k = 0xbcab3412 p = 0x1234abbc q = 0x12000000 4
> [ 9109.727665] 1: *k = 0x56bcab34 p = 0x34abbc56 q = 0x34000000 4
> [ 9109.728553] 2: *k = 0x7856bcab p = 0xabbc5678 q = 0xabffffff 4
> [ 9109.729308] 3: *k = 0xef7856bc p = 0xbc5678ef q = 0xbcffffff 4
> Apparently, be32_to_cpup's output is what I expected.
> Looking forward to your comments. Thanks.
Hi,
thanks for the clarification and code sample.
You are right.
I had in mind that something like: be32_to_cpu((__be32 *)data);
would make it. (thanks to the cast)
But because of the need of "&" and "[offset]", it would just make the
code unnecessarily complex.
I think that your approach is better.
CJ
Powered by blists - more mailing lists