mirror of https://gitee.com/openkylin/linux.git
iio: imu: adis: add unlocked __adis_initial_startup()
This change splits the __adis_initial_startup() away from adis_initial_startup(). The unlocked version can be used in certain calls during probe, where races won't happen since the ADIS driver may not be registered yet with IIO. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
e914cfdf12
commit
3f17ada8f3
|
@ -365,7 +365,7 @@ static int adis_self_test(struct adis *adis)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adis_inital_startup() - Performs device self-test
|
* __adis_initial_startup() - Device initial setup
|
||||||
* @adis: The adis device
|
* @adis: The adis device
|
||||||
*
|
*
|
||||||
* Returns 0 if the device is operational, a negative error code otherwise.
|
* Returns 0 if the device is operational, a negative error code otherwise.
|
||||||
|
@ -373,28 +373,22 @@ static int adis_self_test(struct adis *adis)
|
||||||
* This function should be called early on in the device initialization sequence
|
* This function should be called early on in the device initialization sequence
|
||||||
* to ensure that the device is in a sane and known state and that it is usable.
|
* to ensure that the device is in a sane and known state and that it is usable.
|
||||||
*/
|
*/
|
||||||
int adis_initial_startup(struct adis *adis)
|
int __adis_initial_startup(struct adis *adis)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&adis->state_lock);
|
|
||||||
|
|
||||||
ret = adis_self_test(adis);
|
ret = adis_self_test(adis);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&adis->spi->dev, "Self-test failed, trying reset.\n");
|
dev_err(&adis->spi->dev, "Self-test failed, trying reset.\n");
|
||||||
__adis_reset(adis);
|
__adis_reset(adis);
|
||||||
ret = adis_self_test(adis);
|
ret = adis_self_test(adis);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err(&adis->spi->dev, "Second self-test failed, giving up.\n");
|
dev_err(&adis->spi->dev, "Second self-test failed, giving up.\n");
|
||||||
goto out_unlock;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out_unlock:
|
|
||||||
mutex_unlock(&adis->state_lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(adis_initial_startup);
|
EXPORT_SYMBOL_GPL(__adis_initial_startup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adis_single_conversion() - Performs a single sample conversion
|
* adis_single_conversion() - Performs a single sample conversion
|
||||||
|
|
|
@ -297,6 +297,7 @@ static inline int adis_read_reg_32(struct adis *adis, unsigned int reg,
|
||||||
|
|
||||||
int adis_enable_irq(struct adis *adis, bool enable);
|
int adis_enable_irq(struct adis *adis, bool enable);
|
||||||
int __adis_check_status(struct adis *adis);
|
int __adis_check_status(struct adis *adis);
|
||||||
|
int __adis_initial_startup(struct adis *adis);
|
||||||
|
|
||||||
static inline int adis_check_status(struct adis *adis)
|
static inline int adis_check_status(struct adis *adis)
|
||||||
{
|
{
|
||||||
|
@ -309,7 +310,17 @@ static inline int adis_check_status(struct adis *adis)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int adis_initial_startup(struct adis *adis);
|
/* locked version of __adis_initial_startup() */
|
||||||
|
static inline int adis_initial_startup(struct adis *adis)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
mutex_lock(&adis->state_lock);
|
||||||
|
ret = __adis_initial_startup(adis);
|
||||||
|
mutex_unlock(&adis->state_lock);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int adis_single_conversion(struct iio_dev *indio_dev,
|
int adis_single_conversion(struct iio_dev *indio_dev,
|
||||||
const struct iio_chan_spec *chan, unsigned int error_mask,
|
const struct iio_chan_spec *chan, unsigned int error_mask,
|
||||||
|
|
Loading…
Reference in New Issue