diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2020-02-03 14:38:42 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-12-02 17:27:53 +0300 |
commit | 82731a194fc155eb734941bb1f777caea4077ffa (patch) | |
tree | 385a432be67c104cd516d634d47a9afa32bea055 /drivers/media/i2c/smiapp/smiapp-regs.c | |
parent | 6493c4b777c2bca7fcfaabca2388d82f186f9be3 (diff) | |
download | linux-82731a194fc155eb734941bb1f777caea4077ffa.tar.xz |
media: smiapp: Use CCS register flags
Use the CCS register flags instead of the old smia flags. The
new flags include the register width information that was separate from
the register flags previously.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/i2c/smiapp/smiapp-regs.c')
-rw-r--r-- | drivers/media/i2c/smiapp/smiapp-regs.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c b/drivers/media/i2c/smiapp/smiapp-regs.c index 1b58b7c6c839..904054d303ba 100644 --- a/drivers/media/i2c/smiapp/smiapp-regs.c +++ b/drivers/media/i2c/smiapp/smiapp-regs.c @@ -133,6 +133,16 @@ static int ____smiapp_read_8only(struct smiapp_sensor *sensor, u16 reg, return 0; } +unsigned int ccs_reg_width(u32 reg) +{ + if (reg & CCS_FL_16BIT) + return sizeof(uint16_t); + if (reg & CCS_FL_32BIT) + return sizeof(uint32_t); + + return sizeof(uint8_t); +} + /* * Read a 8/16/32-bit i2c register. The value is returned in 'val'. * Returns zero if successful, or non-zero otherwise. @@ -141,13 +151,9 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val, bool only8) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); - u8 len = SMIAPP_REG_WIDTH(reg); + unsigned int len = ccs_reg_width(reg); int rval; - if (len != SMIAPP_REG_8BIT && len != SMIAPP_REG_16BIT - && len != SMIAPP_REG_32BIT) - return -EINVAL; - if (!only8) rval = ____smiapp_read(sensor, SMIAPP_REG_ADDR(reg), len, val); else @@ -156,7 +162,7 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val, if (rval < 0) return rval; - if (reg & SMIAPP_REG_FLAG_FLOAT) + if (reg & CCS_FL_FLOAT_IREAL) *val = float_to_u32_mul_1000000(client, *val); return 0; @@ -204,7 +210,7 @@ int smiapp_write_no_quirk(struct smiapp_sensor *sensor, u32 reg, u32 val) struct i2c_msg msg; unsigned char data[6]; unsigned int retries; - u8 len = SMIAPP_REG_WIDTH(reg); + unsigned int len = ccs_reg_width(reg); int r; if (len > sizeof(data) - 2) |