Commit 2989a457 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: ccs: Refactor register reading a little

Rework quirk and 8-bit only access functions with a single function that
takes arguments. This is later extensible to support yet more flags.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent e40f1bcb
...@@ -168,18 +168,12 @@ static int __ccs_read_addr(struct ccs_sensor *sensor, u32 reg, u32 *val, ...@@ -168,18 +168,12 @@ static int __ccs_read_addr(struct ccs_sensor *sensor, u32 reg, u32 *val,
return 0; return 0;
} }
int ccs_read_addr_no_quirk(struct ccs_sensor *sensor, u32 reg, u32 *val) static int ccs_read_addr_raw(struct ccs_sensor *sensor, u32 reg, u32 *val,
{ bool force8, bool quirk)
return __ccs_read_addr(
sensor, reg, val,
ccs_needs_quirk(sensor, CCS_QUIRK_FLAG_8BIT_READ_ONLY));
}
static int ccs_read_addr_quirk(struct ccs_sensor *sensor, u32 reg, u32 *val,
bool force8)
{ {
int rval; int rval;
if (quirk) {
*val = 0; *val = 0;
rval = ccs_call_quirk(sensor, reg_access, false, &reg, val); rval = ccs_call_quirk(sensor, reg_access, false, &reg, val);
if (rval == -ENOIOCTLCMD) if (rval == -ENOIOCTLCMD)
...@@ -189,18 +183,21 @@ static int ccs_read_addr_quirk(struct ccs_sensor *sensor, u32 reg, u32 *val, ...@@ -189,18 +183,21 @@ static int ccs_read_addr_quirk(struct ccs_sensor *sensor, u32 reg, u32 *val,
if (force8) if (force8)
return __ccs_read_addr(sensor, reg, val, true); return __ccs_read_addr(sensor, reg, val, true);
}
return ccs_read_addr_no_quirk(sensor, reg, val); return __ccs_read_addr(sensor, reg, val,
ccs_needs_quirk(sensor,
CCS_QUIRK_FLAG_8BIT_READ_ONLY));
} }
int ccs_read_addr(struct ccs_sensor *sensor, u32 reg, u32 *val) int ccs_read_addr(struct ccs_sensor *sensor, u32 reg, u32 *val)
{ {
return ccs_read_addr_quirk(sensor, reg, val, false); return ccs_read_addr_raw(sensor, reg, val, false, true);
} }
int ccs_read_addr_8only(struct ccs_sensor *sensor, u32 reg, u32 *val) int ccs_read_addr_8only(struct ccs_sensor *sensor, u32 reg, u32 *val)
{ {
return ccs_read_addr_quirk(sensor, reg, val, true); return ccs_read_addr_raw(sensor, reg, val, true, true);
} }
int ccs_write_addr_no_quirk(struct ccs_sensor *sensor, u32 reg, u32 val) int ccs_write_addr_no_quirk(struct ccs_sensor *sensor, u32 reg, u32 val)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment