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: <20191006101336.2fdf927f@archlinux>
Date:   Sun, 6 Oct 2019 10:13:36 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Alexandru Ardelean <alexandru.ardelean@...log.com>
Cc:     <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 03/10] iio: imu: adis[16480]: group RW into a single
 lock in adis_enable_irq()

On Thu, 26 Sep 2019 14:18:05 +0300
Alexandru Ardelean <alexandru.ardelean@...log.com> wrote:

> The adis_enable_irq() does a read & a write. This change keeps a lock for
> the duration of both operations vs for each op.
> 
> The change is also needed in adis16480, since that has it's own
> implementation for adis_enable_irq().
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
Applied.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis.c      | 17 +++++++++++------
>  drivers/iio/imu/adis16480.c |  4 ++--
>  2 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c
> index 4f3be011c898..dc30f70d36f3 100644
> --- a/drivers/iio/imu/adis.c
> +++ b/drivers/iio/imu/adis.c
> @@ -250,12 +250,16 @@ int adis_enable_irq(struct adis *adis, bool enable)
>  	int ret = 0;
>  	uint16_t msc;
>  
> -	if (adis->data->enable_irq)
> -		return adis->data->enable_irq(adis, enable);
> +	mutex_lock(&adis->state_lock);
> +
> +	if (adis->data->enable_irq) {
> +		ret = adis->data->enable_irq(adis, enable);
> +		goto out_unlock;
> +	}
>  
> -	ret = adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc);
> +	ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc);
>  	if (ret)
> -		goto error_ret;
> +		goto out_unlock;
>  
>  	msc |= ADIS_MSC_CTRL_DATA_RDY_POL_HIGH;
>  	msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2;
> @@ -264,9 +268,10 @@ int adis_enable_irq(struct adis *adis, bool enable)
>  	else
>  		msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN;
>  
> -	ret = adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
> +	ret = __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
>  
> -error_ret:
> +out_unlock:
> +	mutex_unlock(&adis->state_lock);
>  	return ret;
>  }
>  EXPORT_SYMBOL(adis_enable_irq);
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index b99d73887c9f..dc13d8a33612 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -936,14 +936,14 @@ static int adis16480_enable_irq(struct adis *adis, bool enable)
>  	uint16_t val;
>  	int ret;
>  
> -	ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
> +	ret = __adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
>  	if (ret < 0)
>  		return ret;
>  
>  	val &= ~ADIS16480_DRDY_EN_MSK;
>  	val |= ADIS16480_DRDY_EN(enable);
>  
> -	return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val);
> +	return __adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val);
>  }
>  
>  static int adis16480_initial_setup(struct iio_dev *indio_dev)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ