Re: [PATCH v3 1/4] ASoc: PCM6240: Create PCM6240 Family driver code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sat, Feb 03, 2024 at 11:04:59AM +0800, Shenghao Ding wrote:

> +static int pcmdev_dev_update_bits(struct pcmdevice_priv *pcm_dev,
> +	unsigned int dev_no, unsigned int reg, unsigned int mask,
> +	unsigned int value)
> +{
> +	struct regmap *map = pcm_dev->regmap;
> +	int ret;
> +
> +	if (dev_no >= pcm_dev->ndev) {
> +		dev_err(pcm_dev->dev, "%s, no such channel(%d)\n", __func__,
> +			dev_no);
> +		return -EINVAL;
> +	}
> +
> +	ret = pcmdev_change_dev(pcm_dev, dev_no);
> +	if (ret < 0) {
> +		dev_err(pcm_dev->dev, "%s, E=%d\n", __func__, ret);
> +		return ret;
> +	}
> +
> +	ret = regmap_update_bits(map, reg, mask, value);
> +	if (ret < 0)
> +		dev_err(pcm_dev->dev, "update_bits ERROR, E=%d\n",
> +			ret);
> +
> +	return ret;
> +}

retmap_update_bits() will return 0 on a successful write...

> +static int pcmdev_put_volsw(struct snd_kcontrol *kcontrol,
> +	struct snd_ctl_elem_value *ucontrol, int vol_ctrl_type)
> +{

> +	err = pcmdev_dev_update_bits(pcm_dev, dev_no, reg, val_mask, val);
> +	if (err)
> +		dev_err(pcm_dev->dev, "%s:update_bits, ERROR, E=%d\n",
> +			__func__, err);
> +
> +	mutex_unlock(&pcm_dev->codec_lock);
> +	return err;

...so this and other controls will return 0 when the value changes,
brekaing event generation.  Please use the mixer-test kselftest to check
for this and other issues.

> +static int pcmdevice_codec_probe(struct snd_soc_component *codec)
> +{

> +	/* device-name[defined in pcmdevice_i2c_id]-i2c-bus_id[0,1,...,N]-
> +	 * sum[1,2,...,4]dev-reg.bin stores the firmware including register
> +	 * setting and params for different filters inside chips, it must be
> +	 * copied into firmware folder. The same types of pcmdevices sitting
> +	 * on the same i2c bus will be aggregated as one single codec,
> +	 * all of them share the same bin file.
> +	 */
> +	scnprintf(pcm_dev->regbin_name, PCMDEVICE_REGBIN_FILENAME_LEN,
> +		"%s-i2c-%d-%udev-reg.bin", pcm_dev->dev_name, adap->nr,
> +		pcm_dev->ndev);
> +
> +	ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
> +		pcm_dev->regbin_name, pcm_dev->dev, GFP_KERNEL, pcm_dev,
> +		pcmdev_regbin_ready);
> +	if (ret) {
> +		dev_err(pcm_dev->dev, "load %s error = %d\n",
> +			pcm_dev->regbin_name, ret);
> +		goto out;
> +	}

This does still seem like it'd be better placed in the main probe()
function with the component registration happening once firmware is
ready so...

> +static int pcmdevice_startup(struct snd_pcm_substream *substream,
> +	struct snd_soc_dai *dai)
> +{
> +	struct snd_soc_component *codec = dai->component;
> +	struct pcmdevice_priv *pcm_priv = snd_soc_component_get_drvdata(codec);
> +
> +	if (pcm_priv->fw_state != PCMDEVICE_FW_LOAD_OK) {
> +		dev_err(pcm_priv->dev, "DSP bin file not loaded\n");
> +		return -EBUSY;
> +	}
> +
> +	return 0;
> +}

...issues like this can be avoided.  The device is fundamentally reliant
on the firmware being there AFAICT.

> +
> +		} else
> +			dev_err(pcm_dev->dev, "%s: GPIO %d request error\n",
> +				__func__, pcm_dev->irq_info.gpio);
> +	} else
> +		dev_err(pcm_dev->dev, "Looking up irq-gpio failed %d\n",
> +			pcm_dev->irq_info.gpio);

If one side of the if/else has a braces both should.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux