Skip to content

Commit

Permalink
iio: adis: stylistic changes
Browse files Browse the repository at this point in the history
[ Upstream commit c39010e ]

Minor stylistic changes to address checkptach complains when called with
'--strict'.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220122130905.99-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Stable-dep-of: 99c05e4 ("iio: adis: add '__adis_enable_irq()' implementation")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
nunojsa authored and gregkh committed Dec 31, 2022
1 parent de3e358 commit 3c2e130
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 50 deletions.
47 changes: 25 additions & 22 deletions drivers/iio/imu/adis.c
Expand Up @@ -30,8 +30,8 @@
* @value: The value to write to device (up to 4 bytes)
* @size: The size of the @value (in bytes)
*/
int __adis_write_reg(struct adis *adis, unsigned int reg,
unsigned int value, unsigned int size)
int __adis_write_reg(struct adis *adis, unsigned int reg, unsigned int value,
unsigned int size)
{
unsigned int page = reg / ADIS_PAGE_SIZE;
int ret, i;
Expand Down Expand Up @@ -114,7 +114,7 @@ int __adis_write_reg(struct adis *adis, unsigned int reg,
ret = spi_sync(adis->spi, &msg);
if (ret) {
dev_err(&adis->spi->dev, "Failed to write register 0x%02X: %d\n",
reg, ret);
reg, ret);
} else {
adis->current_page = page;
}
Expand All @@ -130,8 +130,8 @@ EXPORT_SYMBOL_GPL(__adis_write_reg);
* @val: The value read back from the device
* @size: The size of the @val buffer
*/
int __adis_read_reg(struct adis *adis, unsigned int reg,
unsigned int *val, unsigned int size)
int __adis_read_reg(struct adis *adis, unsigned int reg, unsigned int *val,
unsigned int size)
{
unsigned int page = reg / ADIS_PAGE_SIZE;
struct spi_message msg;
Expand Down Expand Up @@ -201,12 +201,12 @@ int __adis_read_reg(struct adis *adis, unsigned int reg,
ret = spi_sync(adis->spi, &msg);
if (ret) {
dev_err(&adis->spi->dev, "Failed to read register 0x%02X: %d\n",
reg, ret);
reg, ret);
return ret;
} else {
adis->current_page = page;
}

adis->current_page = page;

switch (size) {
case 4:
*val = get_unaligned_be32(adis->rx);
Expand Down Expand Up @@ -247,23 +247,23 @@ EXPORT_SYMBOL_GPL(__adis_update_bits_base);

#ifdef CONFIG_DEBUG_FS

int adis_debugfs_reg_access(struct iio_dev *indio_dev,
unsigned int reg, unsigned int writeval, unsigned int *readval)
int adis_debugfs_reg_access(struct iio_dev *indio_dev, unsigned int reg,
unsigned int writeval, unsigned int *readval)
{
struct adis *adis = iio_device_get_drvdata(indio_dev);

if (readval) {
uint16_t val16;
u16 val16;
int ret;

ret = adis_read_reg_16(adis, reg, &val16);
if (ret == 0)
*readval = val16;

return ret;
} else {
return adis_write_reg_16(adis, reg, writeval);
}

return adis_write_reg_16(adis, reg, writeval);
}
EXPORT_SYMBOL(adis_debugfs_reg_access);

Expand All @@ -279,14 +279,16 @@ EXPORT_SYMBOL(adis_debugfs_reg_access);
int adis_enable_irq(struct adis *adis, bool enable)
{
int ret = 0;
uint16_t msc;
u16 msc;

mutex_lock(&adis->state_lock);

if (adis->data->enable_irq) {
ret = adis->data->enable_irq(adis, enable);
goto out_unlock;
} else if (adis->data->unmasked_drdy) {
}

if (adis->data->unmasked_drdy) {
if (enable)
enable_irq(adis->spi->irq);
else
Expand Down Expand Up @@ -322,7 +324,7 @@ EXPORT_SYMBOL(adis_enable_irq);
*/
int __adis_check_status(struct adis *adis)
{
uint16_t status;
u16 status;
int ret;
int i;

Expand Down Expand Up @@ -358,7 +360,7 @@ int __adis_reset(struct adis *adis)
const struct adis_timeout *timeouts = adis->data->timeouts;

ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg,
ADIS_GLOB_CMD_SW_RESET);
ADIS_GLOB_CMD_SW_RESET);
if (ret) {
dev_err(&adis->spi->dev, "Failed to reset device: %d\n", ret);
return ret;
Expand Down Expand Up @@ -414,7 +416,7 @@ int __adis_initial_startup(struct adis *adis)
{
const struct adis_timeout *timeouts = adis->data->timeouts;
struct gpio_desc *gpio;
uint16_t prod_id;
u16 prod_id;
int ret;

/* check if the device has rst pin low */
Expand All @@ -423,7 +425,7 @@ int __adis_initial_startup(struct adis *adis)
return PTR_ERR(gpio);

if (gpio) {
msleep(10);
usleep_range(10, 12);
/* bring device out of reset */
gpiod_set_value_cansleep(gpio, 0);
msleep(timeouts->reset_ms);
Expand Down Expand Up @@ -477,7 +479,8 @@ EXPORT_SYMBOL_GPL(__adis_initial_startup);
* a error bit in the channels raw value set error_mask to 0.
*/
int adis_single_conversion(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, unsigned int error_mask, int *val)
const struct iio_chan_spec *chan,
unsigned int error_mask, int *val)
{
struct adis *adis = iio_device_get_drvdata(indio_dev);
unsigned int uval;
Expand All @@ -486,7 +489,7 @@ int adis_single_conversion(struct iio_dev *indio_dev,
mutex_lock(&adis->state_lock);

ret = __adis_read_reg(adis, chan->address, &uval,
chan->scan_type.storagebits / 8);
chan->scan_type.storagebits / 8);
if (ret)
goto err_unlock;

Expand Down Expand Up @@ -521,7 +524,7 @@ EXPORT_SYMBOL_GPL(adis_single_conversion);
* called.
*/
int adis_init(struct adis *adis, struct iio_dev *indio_dev,
struct spi_device *spi, const struct adis_data *data)
struct spi_device *spi, const struct adis_data *data)
{
if (!data || !data->timeouts) {
dev_err(&spi->dev, "No config data or timeouts not defined!\n");
Expand Down
6 changes: 3 additions & 3 deletions drivers/iio/imu/adis_buffer.c
Expand Up @@ -20,7 +20,7 @@
#include <linux/iio/imu/adis.h>

static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,
const unsigned long *scan_mask)
const unsigned long *scan_mask)
{
struct adis *adis = iio_device_get_drvdata(indio_dev);
unsigned int burst_length, burst_max_length;
Expand Down Expand Up @@ -67,7 +67,7 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,
}

int adis_update_scan_mode(struct iio_dev *indio_dev,
const unsigned long *scan_mask)
const unsigned long *scan_mask)
{
struct adis *adis = iio_device_get_drvdata(indio_dev);
const struct iio_chan_spec *chan;
Expand Down Expand Up @@ -158,7 +158,7 @@ static irqreturn_t adis_trigger_handler(int irq, void *p)
}

iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
pf->timestamp);
pf->timestamp);

irq_done:
iio_trigger_notify_done(indio_dev->trig);
Expand Down
3 changes: 1 addition & 2 deletions drivers/iio/imu/adis_trigger.c
Expand Up @@ -15,8 +15,7 @@
#include <linux/iio/trigger.h>
#include <linux/iio/imu/adis.h>

static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig, bool state)
{
struct adis *adis = iio_trigger_get_drvdata(trig);

Expand Down
48 changes: 25 additions & 23 deletions include/linux/iio/imu/adis.h
Expand Up @@ -32,6 +32,7 @@ struct adis_timeout {
u16 sw_reset_ms;
u16 self_test_ms;
};

/**
* struct adis_data - ADIS chip variant specific data
* @read_delay: SPI delay for read operations in us
Expand All @@ -45,7 +46,7 @@ struct adis_timeout {
* @self_test_mask: Bitmask of supported self-test operations
* @self_test_reg: Register address to request self test command
* @self_test_no_autoclear: True if device's self-test needs clear of ctrl reg
* @status_error_msgs: Array of error messgaes
* @status_error_msgs: Array of error messages
* @status_error_mask: Bitmask of errors supported by the device
* @timeouts: Chip specific delays
* @enable_irq: Hook for ADIS devices that have a special IRQ enable/disable
Expand Down Expand Up @@ -130,12 +131,12 @@ struct adis {
unsigned long irq_flag;
void *buffer;

uint8_t tx[10] ____cacheline_aligned;
uint8_t rx[4];
u8 tx[10] ____cacheline_aligned;
u8 rx[4];
};

int adis_init(struct adis *adis, struct iio_dev *indio_dev,
struct spi_device *spi, const struct adis_data *data);
struct spi_device *spi, const struct adis_data *data);
int __adis_reset(struct adis *adis);

/**
Expand All @@ -156,9 +157,9 @@ static inline int adis_reset(struct adis *adis)
}

int __adis_write_reg(struct adis *adis, unsigned int reg,
unsigned int val, unsigned int size);
unsigned int val, unsigned int size);
int __adis_read_reg(struct adis *adis, unsigned int reg,
unsigned int *val, unsigned int size);
unsigned int *val, unsigned int size);

/**
* __adis_write_reg_8() - Write single byte to a register (unlocked)
Expand All @@ -167,7 +168,7 @@ int __adis_read_reg(struct adis *adis, unsigned int reg,
* @value: The value to write
*/
static inline int __adis_write_reg_8(struct adis *adis, unsigned int reg,
uint8_t val)
u8 val)
{
return __adis_write_reg(adis, reg, val, 1);
}
Expand All @@ -179,7 +180,7 @@ static inline int __adis_write_reg_8(struct adis *adis, unsigned int reg,
* @value: Value to be written
*/
static inline int __adis_write_reg_16(struct adis *adis, unsigned int reg,
uint16_t val)
u16 val)
{
return __adis_write_reg(adis, reg, val, 2);
}
Expand All @@ -191,7 +192,7 @@ static inline int __adis_write_reg_16(struct adis *adis, unsigned int reg,
* @value: Value to be written
*/
static inline int __adis_write_reg_32(struct adis *adis, unsigned int reg,
uint32_t val)
u32 val)
{
return __adis_write_reg(adis, reg, val, 4);
}
Expand All @@ -203,7 +204,7 @@ static inline int __adis_write_reg_32(struct adis *adis, unsigned int reg,
* @val: The value read back from the device
*/
static inline int __adis_read_reg_16(struct adis *adis, unsigned int reg,
uint16_t *val)
u16 *val)
{
unsigned int tmp;
int ret;
Expand All @@ -222,7 +223,7 @@ static inline int __adis_read_reg_16(struct adis *adis, unsigned int reg,
* @val: The value read back from the device
*/
static inline int __adis_read_reg_32(struct adis *adis, unsigned int reg,
uint32_t *val)
u32 *val)
{
unsigned int tmp;
int ret;
Expand All @@ -242,7 +243,7 @@ static inline int __adis_read_reg_32(struct adis *adis, unsigned int reg,
* @size: The size of the @value (in bytes)
*/
static inline int adis_write_reg(struct adis *adis, unsigned int reg,
unsigned int val, unsigned int size)
unsigned int val, unsigned int size)
{
int ret;

Expand All @@ -261,7 +262,7 @@ static inline int adis_write_reg(struct adis *adis, unsigned int reg,
* @size: The size of the @val buffer
*/
static int adis_read_reg(struct adis *adis, unsigned int reg,
unsigned int *val, unsigned int size)
unsigned int *val, unsigned int size)
{
int ret;

Expand All @@ -279,7 +280,7 @@ static int adis_read_reg(struct adis *adis, unsigned int reg,
* @value: The value to write
*/
static inline int adis_write_reg_8(struct adis *adis, unsigned int reg,
uint8_t val)
u8 val)
{
return adis_write_reg(adis, reg, val, 1);
}
Expand All @@ -291,7 +292,7 @@ static inline int adis_write_reg_8(struct adis *adis, unsigned int reg,
* @value: Value to be written
*/
static inline int adis_write_reg_16(struct adis *adis, unsigned int reg,
uint16_t val)
u16 val)
{
return adis_write_reg(adis, reg, val, 2);
}
Expand All @@ -303,7 +304,7 @@ static inline int adis_write_reg_16(struct adis *adis, unsigned int reg,
* @value: Value to be written
*/
static inline int adis_write_reg_32(struct adis *adis, unsigned int reg,
uint32_t val)
u32 val)
{
return adis_write_reg(adis, reg, val, 4);
}
Expand All @@ -315,7 +316,7 @@ static inline int adis_write_reg_32(struct adis *adis, unsigned int reg,
* @val: The value read back from the device
*/
static inline int adis_read_reg_16(struct adis *adis, unsigned int reg,
uint16_t *val)
u16 *val)
{
unsigned int tmp;
int ret;
Expand All @@ -334,7 +335,7 @@ static inline int adis_read_reg_16(struct adis *adis, unsigned int reg,
* @val: The value read back from the device
*/
static inline int adis_read_reg_32(struct adis *adis, unsigned int reg,
uint32_t *val)
u32 *val)
{
unsigned int tmp;
int ret;
Expand Down Expand Up @@ -443,8 +444,8 @@ static inline void adis_dev_unlock(struct adis *adis)
}

int adis_single_conversion(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, unsigned int error_mask,
int *val);
const struct iio_chan_spec *chan,
unsigned int error_mask, int *val);

#define ADIS_VOLTAGE_CHAN(addr, si, chan, name, info_all, bits) { \
.type = IIO_VOLTAGE, \
Expand Down Expand Up @@ -493,7 +494,7 @@ int adis_single_conversion(struct iio_dev *indio_dev,
.modified = 1, \
.channel2 = IIO_MOD_ ## mod, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
info_sep, \
(info_sep), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
.info_mask_shared_by_all = info_all, \
.address = (addr), \
Expand Down Expand Up @@ -527,7 +528,7 @@ devm_adis_setup_buffer_and_trigger(struct adis *adis, struct iio_dev *indio_dev,
int devm_adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev);

int adis_update_scan_mode(struct iio_dev *indio_dev,
const unsigned long *scan_mask);
const unsigned long *scan_mask);

#else /* CONFIG_IIO_BUFFER */

Expand All @@ -551,7 +552,8 @@ static inline int devm_adis_probe_trigger(struct adis *adis,
#ifdef CONFIG_DEBUG_FS

int adis_debugfs_reg_access(struct iio_dev *indio_dev,
unsigned int reg, unsigned int writeval, unsigned int *readval);
unsigned int reg, unsigned int writeval,
unsigned int *readval);

#else

Expand Down

0 comments on commit 3c2e130

Please sign in to comment.