lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZcD5HjnxSJkQ6QYT@finisterre.sirena.org.uk>
Date: Mon, 5 Feb 2024 15:05:02 +0000
From: Mark Brown <broonie@...nel.org>
To: Shenghao Ding <shenghao-ding@...com>
Cc: conor+dt@...nel.org, krzysztof.kozlowski@...aro.org,
	devicetree@...r.kernel.org, robh+dt@...nel.org,
	andriy.shevchenko@...ux.intel.com, linux-sound@...r.kernel.org,
	liam.r.girdwood@...el.com, lgirdwood@...il.com,
	linux-kernel@...r.kernel.org, kevin-lu@...com, baojun.xu@...com,
	v-po@...com, navada@...com, perex@...ex.cz, j-mcpherson@...com,
	pierre-louis.bossart@...ux.intel.com, 13916275206@....com,
	mohit.chawla@...com, soyer@....hu, jkhuang3@...com, tiwai@...e.de,
	pdjuandi@...com, manisha.agrawal@...com, s-hari@...com,
	aviel@...com, hnagalla@...com, praneeth@...com
Subject: Re: [PATCH v3 1/4] ASoc: PCM6240: Create PCM6240 Family driver code

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.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ