[alsa-devel] [PATCH 0/5] ALSA: firewire: suppress sparse warnings due to endianness handling
Hi,
This patchset fixes some issues related to sparse warnings about endianness handling for ALSA firewire stack.
For writing this patchset, I use 'C=1 CF=-D__CHECK_ENDIAN__' options to 'make' command. If they're not enough, please inform to me.
Takashi Sakamoto (5): ALSA: dice: correct variable types for __be32 data ALSA: dice: assign converted data to the same type of variable ALSA: fireworks: use u32 type for be32_to_cpup() macro ALSA: bebob: use correct type for __be32 data ALSA: firewire-digi00x/firewire-tascam: remove wrong conversion for Config ROM
sound/firewire/bebob/bebob_maudio.c | 2 +- sound/firewire/dice/dice-stream.c | 12 ++++++------ sound/firewire/dice/dice.c | 3 ++- sound/firewire/digi00x/digi00x.c | 3 +-- sound/firewire/fireworks/fireworks_command.c | 2 +- sound/firewire/tascam/tascam.c | 3 +-- 6 files changed, 12 insertions(+), 13 deletions(-)
Some local variables in some functions are typed as unsigned int, while __be32 value is assigned to them. This causes sparse warnings.
dice-stream.c:50:17: warning: incorrect type in assignment (different base types) dice-stream.c:50:17: expected unsigned int [unsigned] channel dice-stream.c:50:17: got restricted __be32 [usertype] <noident> dice-stream.c:74:17: warning: incorrect type in assignment (different base types) dice-stream.c:74:17: expected unsigned int [unsigned] channel dice-stream.c:74:17: got restricted __be32 [usertype] <noident>
This commit fixes this bug.
Fixes: 288a8d0cb04f('ALSA: dice: Change the way to start stream') Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/dice/dice-stream.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c index 2108f7f..a6a39f7 100644 --- a/sound/firewire/dice/dice-stream.c +++ b/sound/firewire/dice/dice-stream.c @@ -44,16 +44,16 @@ int snd_dice_stream_get_rate_mode(struct snd_dice *dice, unsigned int rate, static void release_resources(struct snd_dice *dice, struct fw_iso_resources *resources) { - unsigned int channel; + __be32 channel;
/* Reset channel number */ channel = cpu_to_be32((u32)-1); if (resources == &dice->tx_resources) snd_dice_transaction_write_tx(dice, TX_ISOCHRONOUS, - &channel, 4); + &channel, sizeof(channel)); else snd_dice_transaction_write_rx(dice, RX_ISOCHRONOUS, - &channel, 4); + &channel, sizeof(channel));
fw_iso_resources_free(resources); } @@ -62,7 +62,7 @@ static int keep_resources(struct snd_dice *dice, struct fw_iso_resources *resources, unsigned int max_payload_bytes) { - unsigned int channel; + __be32 channel; int err;
err = fw_iso_resources_allocate(resources, max_payload_bytes, @@ -74,10 +74,10 @@ static int keep_resources(struct snd_dice *dice, channel = cpu_to_be32(resources->channel); if (resources == &dice->tx_resources) err = snd_dice_transaction_write_tx(dice, TX_ISOCHRONOUS, - &channel, 4); + &channel, sizeof(channel)); else err = snd_dice_transaction_write_rx(dice, RX_ISOCHRONOUS, - &channel, 4); + &channel, sizeof(channel)); if (err < 0) release_resources(dice, resources); end:
In former commit, u32 data was assigned to __be32 variable instead of an int variable. This is not enough solution because it still causes sparse warnings.
dice.c:80:23: warning: incorrect type in assignment (different base types) dice.c:80:23: expected restricted __be32 [usertype] value dice.c:80:23: got unsigned int dice.c:81:21: warning: restricted __be32 degrades to integer dice.c:81:46: warning: restricted __be32 degrades to integer
This commit fixes this bug.
Fixes: 7c2d4c0cf5ba('ALSA: dice: Split transaction functionality into a file') Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/dice/dice.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c index 70a111d..5d99436 100644 --- a/sound/firewire/dice/dice.c +++ b/sound/firewire/dice/dice.c @@ -29,7 +29,8 @@ static int dice_interface_check(struct fw_unit *unit) struct fw_csr_iterator it; int key, val, vendor = -1, model = -1, err; unsigned int category, i; - __be32 *pointers, value; + __be32 *pointers; + u32 value; __be32 version;
pointers = kmalloc_array(ARRAY_SIZE(min_values), sizeof(__be32),
In former commit, snd_efw_command_get_phys_meters() was added to handle metering data. The given buffer is used to save transaction result and to convert between endianness. But this causes sparse warnings.
fireworks_command.c:269:25: warning: incorrect type in argument 1 (different base types) fireworks_command.c:269:25: expected unsigned int [usertype] *p fireworks_command.c:269:25: got restricted __be32 [usertype] *
This commit fixes this bug.
Fixes: bde8a8f23bbe('ALSA: fireworks: Add transaction and some commands') Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/fireworks/fireworks_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/firewire/fireworks/fireworks_command.c b/sound/firewire/fireworks/fireworks_command.c index 166f805..94bab04 100644 --- a/sound/firewire/fireworks/fireworks_command.c +++ b/sound/firewire/fireworks/fireworks_command.c @@ -257,7 +257,7 @@ int snd_efw_command_get_phys_meters(struct snd_efw *efw, struct snd_efw_phys_meters *meters, unsigned int len) { - __be32 *buf = (__be32 *)meters; + u32 *buf = (u32 *)meters; unsigned int i; int err;
In former commit, metering is supported for BeBoB based models customized by M-Audio. The data in transaction is aligned to big-endianness, while in the driver code u16 typed variable is assigned to the data. This causes sparse warnings.
bebob_maudio.c:651:31: warning: cast to restricted __be16 bebob_maudio.c:651:31: warning: cast to restricted __be16 bebob_maudio.c:651:31: warning: cast to restricted __be16 bebob_maudio.c:651:31: warning: cast to restricted __be16
This commit fixes this bug by using __be16 variable for the data.
Fixes: 3149ac489ff8('ALSA: bebob: Add support for M-Audio special Firewire series') Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/bebob/bebob_maudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c index 7b86a6b..07e5abd 100644 --- a/sound/firewire/bebob/bebob_maudio.c +++ b/sound/firewire/bebob/bebob_maudio.c @@ -628,7 +628,7 @@ static const char *const special_meter_labels[] = { static int special_meter_get(struct snd_bebob *bebob, u32 *target, unsigned int size) { - u16 *buf; + __be16 *buf; unsigned int i, c, channels; int err;
The contents of Config ROM in firewire device structure are already aligned to CPU-endianness. Thus, no need to convert it again.
This commit removes needless conversions
Fixes: 9edf723fd858('ALSA: firewire-digi00x: add skeleton for Digi 002/003 family') Fixes: c0949b278515('ALSA: firewire-tascam: add skeleton for TASCAM FireWire series') Reported-by: Stefan Richter stefanr@s5r6.in-berlin.de Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/digi00x/digi00x.c | 3 +-- sound/firewire/tascam/tascam.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/firewire/digi00x/digi00x.c b/sound/firewire/digi00x/digi00x.c index bbe3be7..1f33b7a 100644 --- a/sound/firewire/digi00x/digi00x.c +++ b/sound/firewire/digi00x/digi00x.c @@ -34,8 +34,7 @@ static int name_card(struct snd_dg00x *dg00x) strcpy(dg00x->card->mixername, model); snprintf(dg00x->card->longname, sizeof(dg00x->card->longname), "Digidesign %s, GUID %08x%08x at %s, S%d", model, - cpu_to_be32(fw_dev->config_rom[3]), - cpu_to_be32(fw_dev->config_rom[4]), + fw_dev->config_rom[3], fw_dev->config_rom[4], dev_name(&dg00x->unit->device), 100 << fw_dev->max_speed);
return 0; diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c index c6747a4..c2f42cd 100644 --- a/sound/firewire/tascam/tascam.c +++ b/sound/firewire/tascam/tascam.c @@ -73,8 +73,7 @@ static int identify_model(struct snd_tscm *tscm) strcpy(tscm->card->mixername, model); snprintf(tscm->card->longname, sizeof(tscm->card->longname), "TASCAM %s, GUID %08x%08x at %s, S%d", model, - cpu_to_be32(fw_dev->config_rom[3]), - cpu_to_be32(fw_dev->config_rom[4]), + fw_dev->config_rom[3], fw_dev->config_rom[4], dev_name(&tscm->unit->device), 100 << fw_dev->max_speed);
return 0;
On Sun, 18 Oct 2015 15:39:48 +0200, Takashi Sakamoto wrote:
Hi,
This patchset fixes some issues related to sparse warnings about endianness handling for ALSA firewire stack.
For writing this patchset, I use 'C=1 CF=-D__CHECK_ENDIAN__' options to 'make' command. If they're not enough, please inform to me.
Takashi Sakamoto (5): ALSA: dice: correct variable types for __be32 data ALSA: dice: assign converted data to the same type of variable ALSA: fireworks: use u32 type for be32_to_cpup() macro ALSA: bebob: use correct type for __be32 data ALSA: firewire-digi00x/firewire-tascam: remove wrong conversion for Config ROM
Applied all five patches now. Thanks.
Takashi
sound/firewire/bebob/bebob_maudio.c | 2 +- sound/firewire/dice/dice-stream.c | 12 ++++++------ sound/firewire/dice/dice.c | 3 ++- sound/firewire/digi00x/digi00x.c | 3 +-- sound/firewire/fireworks/fireworks_command.c | 2 +- sound/firewire/tascam/tascam.c | 3 +-- 6 files changed, 12 insertions(+), 13 deletions(-)
-- 2.1.4
participants (2)
-
Takashi Iwai
-
Takashi Sakamoto