[alsa-devel] [PATCH 1/7] ALSA: firewire-tascam: add skeleton for TASCAM FireWire series

Takashi Iwai tiwai at suse.de
Sat Oct 3 18:07:42 CEST 2015


On Sat, 03 Oct 2015 11:57:34 +0200,
Takashi Sakamoto wrote:
> 
> On 2015年10月03日 18:14, Clemens Ladisch wrote:
> > Takashi Sakamoto wrote:
> >>>>> 23		data = be32_to_cpu(fw_dev->config_rom[28]);
> >>
> >> About using 'be32_to_cpu()', the 'config_rom' member actually has 'const
> >> u32 *', while in the member caracters in the textual leaf are aligned in
> >> big-endian.
> > 
> > Strictly speaking, strings do not have an endianness.
> > 
> > Most data in the actual configuration ROM is organized as big-endian 32-
> > bit values, so the FireWire core converts _all_ words from big endian to
> > CPU endian.  The words that are not actually 32-bit values but strings
> > have to be converted back; the correct function for this is cpu_to_be32().
> 
> Yes. And I forgot a pair of cpu_to_be32/be32_to_cpu is symmetric each other!
> (I'm really a stupid guy, sigh...)
> 
> This patch solves the sparce warnings.
> 
> $ git diff
> diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
> index ee2f498..6e1087e 100644
> --- a/sound/firewire/tascam/tascam.c
> +++ b/sound/firewire/tascam/tascam.c
> @@ -50,19 +50,19 @@ static int check_name(struct snd_tscm *tscm)
>         struct fw_device *fw_dev = fw_parent_device(tscm->unit);
>         char vendor[8];
>         char model[8];
> -       __u32 data;
> +       __be32 data;
> 
>         /* Retrieve model name. */
> -       data = be32_to_cpu(fw_dev->config_rom[28]);
> +       data = cpu_to_be32(fw_dev->config_rom[28]);
>         memcpy(model, &data, 4);
> -       data = be32_to_cpu(fw_dev->config_rom[29]);
> +       data = cpu_to_be32(fw_dev->config_rom[29]);
>         memcpy(model + 4, &data, 4);
>         model[7] = '\0';
> 
>         /* Retrieve vendor name. */
> -       data = be32_to_cpu(fw_dev->config_rom[23]);
> +       data = cpu_to_be32(fw_dev->config_rom[23]);
>         memcpy(vendor, &data, 4);
> -       data = be32_to_cpu(fw_dev->config_rom[24]);
> +       data = cpu_to_be32(fw_dev->config_rom[24]);
>         memcpy(vendor + 4, &data, 4);
>         vendor[7] = '\0';
> 
> 
> > Iwai-san,
> 
> Should I re-post this patchset? Or you kindly merge them with your
> modification?

I already merged the latest patchset, so incremental patches are
preferred.


thanks,

Takashi


More information about the Alsa-devel mailing list