Commit 3adb82eb authored by Sergiu Cuciurean's avatar Sergiu Cuciurean Committed by Jonathan Cameron
Browse files

iio: dac: vf610_dac: Replace indio_dev->mlock with own device lock



As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock on the device's state structure.

Signed-off-by: default avatarSergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 0b2884ef
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ struct vf610_dac {
	struct device *dev;
	struct device *dev;
	enum vf610_conversion_mode_sel conv_mode;
	enum vf610_conversion_mode_sel conv_mode;
	void __iomem *regs;
	void __iomem *regs;
	struct mutex lock;
};
};


static void vf610_dac_init(struct vf610_dac *info)
static void vf610_dac_init(struct vf610_dac *info)
@@ -64,7 +65,7 @@ static int vf610_set_conversion_mode(struct iio_dev *indio_dev,
	struct vf610_dac *info = iio_priv(indio_dev);
	struct vf610_dac *info = iio_priv(indio_dev);
	int val;
	int val;


	mutex_lock(&indio_dev->mlock);
	mutex_lock(&info->lock);
	info->conv_mode = mode;
	info->conv_mode = mode;
	val = readl(info->regs + VF610_DACx_STATCTRL);
	val = readl(info->regs + VF610_DACx_STATCTRL);
	if (mode)
	if (mode)
@@ -72,7 +73,7 @@ static int vf610_set_conversion_mode(struct iio_dev *indio_dev,
	else
	else
		val &= ~VF610_DAC_LPEN;
		val &= ~VF610_DAC_LPEN;
	writel(val, info->regs + VF610_DACx_STATCTRL);
	writel(val, info->regs + VF610_DACx_STATCTRL);
	mutex_unlock(&indio_dev->mlock);
	mutex_unlock(&info->lock);


	return 0;
	return 0;
}
}
@@ -147,9 +148,9 @@ static int vf610_write_raw(struct iio_dev *indio_dev,


	switch (mask) {
	switch (mask) {
	case IIO_CHAN_INFO_RAW:
	case IIO_CHAN_INFO_RAW:
		mutex_lock(&indio_dev->mlock);
		mutex_lock(&info->lock);
		writel(VF610_DAC_DAT0(val), info->regs);
		writel(VF610_DAC_DAT0(val), info->regs);
		mutex_unlock(&indio_dev->mlock);
		mutex_unlock(&info->lock);
		return 0;
		return 0;


	default:
	default:
@@ -205,6 +206,8 @@ static int vf610_dac_probe(struct platform_device *pdev)
	indio_dev->channels = vf610_dac_iio_channels;
	indio_dev->channels = vf610_dac_iio_channels;
	indio_dev->num_channels = ARRAY_SIZE(vf610_dac_iio_channels);
	indio_dev->num_channels = ARRAY_SIZE(vf610_dac_iio_channels);


	mutex_init(&info->lock);

	ret = clk_prepare_enable(info->clk);
	ret = clk_prepare_enable(info->clk);
	if (ret) {
	if (ret) {
		dev_err(&pdev->dev,
		dev_err(&pdev->dev,