Skip to content

Commit

Permalink
ALSA: wss: Remove (almost) always NULL parameters
Browse files Browse the repository at this point in the history
Most callers of snd_wss_pcm(), snd_wss_timer() and snd_cs4236_pcm() pass
NULL as the last parameter, some callers pass a pointer but never use it
after the function has been called and only a few callers pass a pointer and
actually use it. The later is only the case for snd_wss_pcm() for
snd_cs4236_pcm() and it is possible to get the same PCM object by accessing
the pcm field of the snd_wss struct that was passed as the first parameter.

This function removes the last parameters from the functions mentioned above
and updates the callers which used it to use chip->pcm instead. This allows
us to slightly simplify the functions since they don't have to check and set
the last parameter anymore which makes the code slightly shorter and
cleaner.

Signed-off-by: Lars-Peter Clausen <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
larsclausen authored and tiwai committed Jan 2, 2015
1 parent 92533f1 commit fa60c06
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 67 deletions.
6 changes: 3 additions & 3 deletions include/sound/wss.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ int snd_wss_create(struct snd_card *card,
unsigned short hardware,
unsigned short hwshare,
struct snd_wss **rchip);
int snd_wss_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm);
int snd_wss_timer(struct snd_wss *chip, int device, struct snd_timer **rtimer);
int snd_wss_pcm(struct snd_wss *chip, int device);
int snd_wss_timer(struct snd_wss *chip, int device);
int snd_wss_mixer(struct snd_wss *chip);

const struct snd_pcm_ops *snd_wss_get_pcm_ops(int direction);
Expand All @@ -167,7 +167,7 @@ int snd_cs4236_create(struct snd_card *card,
unsigned short hardware,
unsigned short hwshare,
struct snd_wss **rchip);
int snd_cs4236_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm);
int snd_cs4236_pcm(struct snd_wss *chip, int device);
int snd_cs4236_mixer(struct snd_wss *chip);

/*
Expand Down
7 changes: 3 additions & 4 deletions sound/isa/ad1848/ad1848.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n)
{
struct snd_card *card;
struct snd_wss *chip;
struct snd_pcm *pcm;
int error;

error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
Expand All @@ -103,7 +102,7 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n)

card->private_data = chip;

error = snd_wss_pcm(chip, 0, &pcm);
error = snd_wss_pcm(chip, 0);
if (error < 0)
goto out;

Expand All @@ -112,10 +111,10 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n)
goto out;

strcpy(card->driver, "AD1848");
strcpy(card->shortname, pcm->name);
strcpy(card->shortname, chip->pcm->name);

sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
pcm->name, chip->port, irq[n], dma1[n]);
chip->pcm->name, chip->port, irq[n], dma1[n]);
if (thinkpad[n])
strcat(card->longname, " [Thinkpad]");

Expand Down
4 changes: 2 additions & 2 deletions sound/isa/azt2320.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int snd_card_azt2320_probe(int dev,
sprintf(card->longname, "%s, WSS at 0x%lx, irq %i, dma %i&%i",
card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]);

error = snd_wss_pcm(chip, 0, NULL);
error = snd_wss_pcm(chip, 0);
if (error < 0) {
snd_card_free(card);
return error;
Expand All @@ -225,7 +225,7 @@ static int snd_card_azt2320_probe(int dev,
snd_card_free(card);
return error;
}
error = snd_wss_timer(chip, 0, NULL);
error = snd_wss_timer(chip, 0);
if (error < 0) {
snd_card_free(card);
return error;
Expand Down
4 changes: 2 additions & 2 deletions sound/isa/cmi8328.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ static int snd_cmi8328_probe(struct device *pdev, unsigned int ndev)
if (err < 0)
goto error;

err = snd_wss_pcm(cmi->wss, 0, NULL);
err = snd_wss_pcm(cmi->wss, 0);
if (err < 0)
goto error;

Expand All @@ -318,7 +318,7 @@ static int snd_cmi8328_probe(struct device *pdev, unsigned int ndev)
if (err < 0)
goto error;

if (snd_wss_timer(cmi->wss, 0, NULL) < 0)
if (snd_wss_timer(cmi->wss, 0) < 0)
snd_printk(KERN_WARNING "error initializing WSS timer\n");

if (mpuport[ndev] == SNDRV_AUTO_PORT) {
Expand Down
9 changes: 4 additions & 5 deletions sound/isa/cs423x/cs4231.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n)
{
struct snd_card *card;
struct snd_wss *chip;
struct snd_pcm *pcm;
int error;

error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
Expand All @@ -106,23 +105,23 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n)

card->private_data = chip;

error = snd_wss_pcm(chip, 0, &pcm);
error = snd_wss_pcm(chip, 0);
if (error < 0)
goto out;

strcpy(card->driver, "CS4231");
strcpy(card->shortname, pcm->name);
strcpy(card->shortname, chip->pcm->name);

sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
pcm->name, chip->port, irq[n], dma1[n]);
chip->pcm->name, chip->port, irq[n], dma1[n]);
if (dma2[n] >= 0)
sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]);

error = snd_wss_mixer(chip);
if (error < 0)
goto out;

error = snd_wss_timer(chip, 0, NULL);
error = snd_wss_timer(chip, 0);
if (error < 0)
goto out;

Expand Down
13 changes: 6 additions & 7 deletions sound/isa/cs423x/cs4236.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ static int snd_cs423x_card_new(struct device *pdev, int dev,
static int snd_cs423x_probe(struct snd_card *card, int dev)
{
struct snd_card_cs4236 *acard;
struct snd_pcm *pcm;
struct snd_wss *chip;
struct snd_opl3 *opl3;
int err;
Expand All @@ -404,33 +403,33 @@ static int snd_cs423x_probe(struct snd_card *card, int dev)
acard->chip = chip;
if (chip->hardware & WSS_HW_CS4236B_MASK) {

err = snd_cs4236_pcm(chip, 0, &pcm);
err = snd_cs4236_pcm(chip, 0);
if (err < 0)
return err;

err = snd_cs4236_mixer(chip);
if (err < 0)
return err;
} else {
err = snd_wss_pcm(chip, 0, &pcm);
err = snd_wss_pcm(chip, 0);
if (err < 0)
return err;

err = snd_wss_mixer(chip);
if (err < 0)
return err;
}
strcpy(card->driver, pcm->name);
strcpy(card->shortname, pcm->name);
strcpy(card->driver, chip->pcm->name);
strcpy(card->shortname, chip->pcm->name);
sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",
pcm->name,
chip->pcm->name,
chip->port,
irq[dev],
dma1[dev]);
if (dma2[dev] >= 0)
sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);

err = snd_wss_timer(chip, 0, NULL);
err = snd_wss_timer(chip, 0);
if (err < 0)
return err;

Expand Down
9 changes: 3 additions & 6 deletions sound/isa/cs423x/cs4236_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,14 @@ int snd_cs4236_create(struct snd_card *card,
return 0;
}

int snd_cs4236_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm)
int snd_cs4236_pcm(struct snd_wss *chip, int device)
{
struct snd_pcm *pcm;
int err;

err = snd_wss_pcm(chip, device, &pcm);
err = snd_wss_pcm(chip, device);
if (err < 0)
return err;
pcm->info_flags &= ~SNDRV_PCM_INFO_JOINT_DUPLEX;
if (rpcm)
*rpcm = pcm;
chip->pcm->info_flags &= ~SNDRV_PCM_INFO_JOINT_DUPLEX;
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions sound/isa/galaxy/galaxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,15 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n)
if (err < 0)
goto error;

err = snd_wss_pcm(chip, 0, NULL);
err = snd_wss_pcm(chip, 0);
if (err < 0)
goto error;

err = snd_wss_mixer(chip);
if (err < 0)
goto error;

err = snd_wss_timer(chip, 0, NULL);
err = snd_wss_timer(chip, 0);
if (err < 0)
goto error;

Expand Down
4 changes: 2 additions & 2 deletions sound/isa/gus/gusmax.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev)
if (err < 0)
goto _err;

err = snd_wss_pcm(wss, 0, NULL);
err = snd_wss_pcm(wss, 0);
if (err < 0)
goto _err;

err = snd_wss_mixer(wss);
if (err < 0)
goto _err;

err = snd_wss_timer(wss, 2, NULL);
err = snd_wss_timer(wss, 2);
if (err < 0)
goto _err;

Expand Down
10 changes: 5 additions & 5 deletions sound/isa/gus/interwave.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
#ifdef SNDRV_STB
struct snd_i2c_bus *i2c_bus;
#endif
struct snd_pcm *pcm;
char *str;
int err;

Expand Down Expand Up @@ -695,14 +694,15 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
if (err < 0)
return err;

err = snd_wss_pcm(wss, 0, &pcm);
err = snd_wss_pcm(wss, 0);
if (err < 0)
return err;

sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A');
strcat(pcm->name, " (codec)");
sprintf(wss->pcm->name + strlen(wss->pcm->name), " rev %c",
gus->revision + 'A');
strcat(wss->pcm->name, " (codec)");

err = snd_wss_timer(wss, 2, NULL);
err = snd_wss_timer(wss, 2);
if (err < 0)
return err;

Expand Down
4 changes: 2 additions & 2 deletions sound/isa/opl3sa2.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev)
return err;
}
chip->wss = wss;
err = snd_wss_pcm(wss, 0, NULL);
err = snd_wss_pcm(wss, 0);
if (err < 0)
return err;
err = snd_wss_mixer(wss);
Expand All @@ -693,7 +693,7 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev)
err = snd_opl3sa2_mixer(card);
if (err < 0)
return err;
err = snd_wss_timer(wss, 0, NULL);
err = snd_wss_timer(wss, 0);
if (err < 0)
return err;
if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) {
Expand Down
12 changes: 5 additions & 7 deletions sound/isa/opti9xx/miro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,6 @@ static int snd_miro_probe(struct snd_card *card)
int error;
struct snd_miro *miro = card->private_data;
struct snd_wss *codec;
struct snd_timer *timer;
struct snd_pcm *pcm;
struct snd_rawmidi *rmidi;

if (!miro->res_mc_base) {
Expand Down Expand Up @@ -1310,19 +1308,19 @@ static int snd_miro_probe(struct snd_card *card)
if (error < 0)
return error;

error = snd_wss_pcm(codec, 0, &pcm);
error = snd_wss_pcm(codec, 0);
if (error < 0)
return error;

error = snd_wss_mixer(codec);
if (error < 0)
return error;

error = snd_wss_timer(codec, 0, &timer);
error = snd_wss_timer(codec, 0);
if (error < 0)
return error;

miro->pcm = pcm;
miro->pcm = codec->pcm;

error = snd_miro_mixer(card, miro);
if (error < 0)
Expand Down Expand Up @@ -1356,8 +1354,8 @@ static int snd_miro_probe(struct snd_card *card)

strcpy(card->driver, "miro");
sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
card->shortname, miro->name, pcm->name, miro->wss_base + 4,
miro->irq, miro->dma1, miro->dma2);
card->shortname, miro->name, codec->pcm->name,
miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2);

if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT)
rmidi = NULL;
Expand Down
13 changes: 5 additions & 8 deletions sound/isa/opti9xx/opti92x-ad1848.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,6 @@ static int snd_opti9xx_probe(struct snd_card *card)
int xdma2;
struct snd_opti9xx *chip = card->private_data;
struct snd_wss *codec;
#ifdef CS4231
struct snd_timer *timer;
#endif
struct snd_pcm *pcm;
struct snd_rawmidi *rmidi;
struct snd_hwdep *synth;

Expand Down Expand Up @@ -855,7 +851,7 @@ static int snd_opti9xx_probe(struct snd_card *card)
if (error < 0)
return error;
chip->codec = codec;
error = snd_wss_pcm(codec, 0, &pcm);
error = snd_wss_pcm(codec, 0);
if (error < 0)
return error;
error = snd_wss_mixer(codec);
Expand All @@ -867,7 +863,7 @@ static int snd_opti9xx_probe(struct snd_card *card)
return error;
#endif
#ifdef CS4231
error = snd_wss_timer(codec, 0, &timer);
error = snd_wss_timer(codec, 0);
if (error < 0)
return error;
#endif
Expand All @@ -884,11 +880,12 @@ static int snd_opti9xx_probe(struct snd_card *card)
sprintf(card->shortname, "OPTi %s", card->driver);
#if defined(CS4231) || defined(OPTi93X)
sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d",
card->shortname, pcm->name,
card->shortname, codec->pcm->name,
chip->wss_base + 4, irq, dma1, xdma2);
#else
sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",
card->shortname, pcm->name, chip->wss_base + 4, irq, dma1);
card->shortname, codec->pcm->name, chip->wss_base + 4, irq,
dma1);
#endif /* CS4231 || OPTi93X */

if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT)
Expand Down
2 changes: 1 addition & 1 deletion sound/isa/sc6000.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
if (err < 0)
goto err_unmap2;

err = snd_wss_pcm(chip, 0, NULL);
err = snd_wss_pcm(chip, 0);
if (err < 0) {
snd_printk(KERN_ERR PFX
"error creating new WSS PCM device\n");
Expand Down
5 changes: 2 additions & 3 deletions sound/isa/sscape.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,6 @@ static int create_ad1845(struct snd_card *card, unsigned port,
codec_type, WSS_HWSHARE_DMA1, &chip);
if (!err) {
unsigned long flags;
struct snd_pcm *pcm;

if (sscape->type != SSCAPE_VIVO) {
/*
Expand All @@ -893,7 +892,7 @@ static int create_ad1845(struct snd_card *card, unsigned port,

}

err = snd_wss_pcm(chip, 0, &pcm);
err = snd_wss_pcm(chip, 0);
if (err < 0) {
snd_printk(KERN_ERR "sscape: No PCM device "
"for AD1845 chip\n");
Expand All @@ -907,7 +906,7 @@ static int create_ad1845(struct snd_card *card, unsigned port,
goto _error;
}
if (chip->hardware != WSS_HW_AD1848) {
err = snd_wss_timer(chip, 0, NULL);
err = snd_wss_timer(chip, 0);
if (err < 0) {
snd_printk(KERN_ERR "sscape: No timer device "
"for AD1845 chip\n");
Expand Down
Loading

0 comments on commit fa60c06

Please sign in to comment.