Commit e73ad388 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: poewrmac: Fix assignment in if condition

PPC powermac driver code contains a few assignments in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-65-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent dd1fc3c5
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -105,7 +105,10 @@ static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type,
	}

	chip = input_get_drvdata(dev);
	if (! chip || (beep = chip->beep) == NULL)
	if (!chip)
		return -1;
	beep = chip->beep;
	if (!beep)
		return -1;

	if (! hz) {
+16 −8
Original line number Diff line number Diff line
@@ -84,7 +84,8 @@ static int daca_get_deemphasis(struct snd_kcontrol *kcontrol,
{
	struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
	struct pmac_daca *mix;
	if (! (mix = chip->mixer_data))
	mix = chip->mixer_data;
	if (!mix)
		return -ENODEV;
	ucontrol->value.integer.value[0] = mix->deemphasis ? 1 : 0;
	return 0;
@@ -97,7 +98,8 @@ static int daca_put_deemphasis(struct snd_kcontrol *kcontrol,
	struct pmac_daca *mix;
	int change;

	if (! (mix = chip->mixer_data))
	mix = chip->mixer_data;
	if (!mix)
		return -ENODEV;
	change = mix->deemphasis != ucontrol->value.integer.value[0];
	if (change) {
@@ -123,7 +125,8 @@ static int daca_get_volume(struct snd_kcontrol *kcontrol,
{
	struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
	struct pmac_daca *mix;
	if (! (mix = chip->mixer_data))
	mix = chip->mixer_data;
	if (!mix)
		return -ENODEV;
	ucontrol->value.integer.value[0] = mix->left_vol;
	ucontrol->value.integer.value[1] = mix->right_vol;
@@ -138,7 +141,8 @@ static int daca_put_volume(struct snd_kcontrol *kcontrol,
	unsigned int vol[2];
	int change;

	if (! (mix = chip->mixer_data))
	mix = chip->mixer_data;
	if (!mix)
		return -ENODEV;
	vol[0] = ucontrol->value.integer.value[0];
	vol[1] = ucontrol->value.integer.value[1];
@@ -162,7 +166,8 @@ static int daca_get_amp(struct snd_kcontrol *kcontrol,
{
	struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
	struct pmac_daca *mix;
	if (! (mix = chip->mixer_data))
	mix = chip->mixer_data;
	if (!mix)
		return -ENODEV;
	ucontrol->value.integer.value[0] = mix->amp_on ? 1 : 0;
	return 0;
@@ -175,7 +180,8 @@ static int daca_put_amp(struct snd_kcontrol *kcontrol,
	struct pmac_daca *mix;
	int change;

	if (! (mix = chip->mixer_data))
	mix = chip->mixer_data;
	if (!mix)
		return -ENODEV;
	change = mix->amp_on != ucontrol->value.integer.value[0];
	if (change) {
@@ -248,7 +254,8 @@ int snd_pmac_daca_init(struct snd_pmac *chip)
	mix->i2c.addr = DACA_I2C_ADDR;
	mix->i2c.init_client = daca_init_client;
	mix->i2c.name = "DACA";
	if ((err = snd_pmac_keywest_init(&mix->i2c)) < 0)
	err = snd_pmac_keywest_init(&mix->i2c);
	if (err < 0)
		return err;

	/*
@@ -257,7 +264,8 @@ int snd_pmac_daca_init(struct snd_pmac *chip)
	strcpy(chip->card->mixername, "PowerMac DACA");

	for (i = 0; i < ARRAY_SIZE(daca_mixers); i++) {
		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&daca_mixers[i], chip))) < 0)
		err = snd_ctl_add(chip->card, snd_ctl_new1(&daca_mixers[i], chip));
		if (err < 0)
			return err;
	}

+4 −2
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ int snd_pmac_tumbler_post_init(void)
	if (!keywest_ctx || !keywest_ctx->client)
		return -ENXIO;

	if ((err = keywest_ctx->init_client(keywest_ctx)) < 0) {
	err = keywest_ctx->init_client(keywest_ctx);
	if (err < 0) {
		snd_printk(KERN_ERR "tumbler: %i :cannot initialize the MCS\n", err);
		return err;
	}
@@ -136,7 +137,8 @@ int snd_pmac_keywest_init(struct pmac_keywest *i2c)

	keywest_ctx = i2c;

	if ((err = i2c_add_driver(&keywest_driver))) {
	err = i2c_add_driver(&keywest_driver);
	if (err) {
		snd_printk(KERN_ERR "cannot register keywest i2c driver\n");
		i2c_put_adapter(adap);
		return err;
+4 −2
Original line number Diff line number Diff line
@@ -1160,7 +1160,8 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
	chip->playback.stream = SNDRV_PCM_STREAM_PLAYBACK;
	chip->capture.stream = SNDRV_PCM_STREAM_CAPTURE;

	if ((err = snd_pmac_detect(chip)) < 0)
	err = snd_pmac_detect(chip);
	if (err < 0)
		goto __error;

	if (snd_pmac_dbdma_alloc(chip, &chip->playback.cmd, PMAC_MAX_FRAGS + 1) < 0 ||
@@ -1299,7 +1300,8 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
	/* Reset dbdma channels */
	snd_pmac_dbdma_reset(chip);

	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
	if (err < 0)
		goto __error;

	*chip_return = chip;
+14 −7
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ static int snd_pmac_probe(struct platform_device *devptr)
	if (err < 0)
		return err;

	if ((err = snd_pmac_new(card, &chip)) < 0)
	err = snd_pmac_new(card, &chip);
	if (err < 0)
		goto __error;
	card->private_data = chip;

@@ -58,7 +59,8 @@ static int snd_pmac_probe(struct platform_device *devptr)
		strcpy(card->shortname, "PowerMac Burgundy");
		sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
			card->shortname, chip->device_id, chip->subframe);
		if ((err = snd_pmac_burgundy_init(chip)) < 0)
		err = snd_pmac_burgundy_init(chip);
		if (err < 0)
			goto __error;
		break;
	case PMAC_DACA:
@@ -66,7 +68,8 @@ static int snd_pmac_probe(struct platform_device *devptr)
		strcpy(card->shortname, "PowerMac DACA");
		sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
			card->shortname, chip->device_id, chip->subframe);
		if ((err = snd_pmac_daca_init(chip)) < 0)
		err = snd_pmac_daca_init(chip);
		if (err < 0)
			goto __error;
		break;
	case PMAC_TUMBLER:
@@ -92,7 +95,8 @@ static int snd_pmac_probe(struct platform_device *devptr)
			name_ext = "";
		sprintf(card->longname, "%s%s Rev %d",
			card->shortname, name_ext, chip->revision);
		if ((err = snd_pmac_awacs_init(chip)) < 0)
		err = snd_pmac_awacs_init(chip);
		if (err < 0)
			goto __error;
		break;
	default:
@@ -101,14 +105,16 @@ static int snd_pmac_probe(struct platform_device *devptr)
		goto __error;
	}

	if ((err = snd_pmac_pcm_new(chip)) < 0)
	err = snd_pmac_pcm_new(chip);
	if (err < 0)
		goto __error;

	chip->initialized = 1;
	if (enable_beep)
		snd_pmac_attach_beep(chip);

	if ((err = snd_card_register(card)) < 0)
	err = snd_card_register(card);
	if (err < 0)
		goto __error;

	platform_set_drvdata(devptr, card);
@@ -162,7 +168,8 @@ static int __init alsa_card_pmac_init(void)
{
	int err;

	if ((err = platform_driver_register(&snd_pmac_driver)) < 0)
	err = platform_driver_register(&snd_pmac_driver);
	if (err < 0)
		return err;
	device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0);
	return 0;
Loading