Commit 1e73eea7 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] smiapp: Pass struct sensor to register writing commands instead of i2c_client

Pass struct sensor to register access commands. This allows taking quirks
into account in register access.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@maxwell.research.nokia.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2547428d
This diff is collapsed.
...@@ -28,9 +28,7 @@ ...@@ -28,9 +28,7 @@
static int smiapp_write_8(struct smiapp_sensor *sensor, u16 reg, u8 val) static int smiapp_write_8(struct smiapp_sensor *sensor, u16 reg, u8 val)
{ {
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); return smiapp_write(sensor, (SMIA_REG_8BIT << 16) | reg, val);
return smiapp_write(client, (SMIA_REG_8BIT << 16) | reg, val);
} }
static int smiapp_write_8s(struct smiapp_sensor *sensor, static int smiapp_write_8s(struct smiapp_sensor *sensor,
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include "smiapp.h"
#include "smiapp-regs.h" #include "smiapp-regs.h"
static uint32_t float_to_u32_mul_1000000(struct i2c_client *client, static uint32_t float_to_u32_mul_1000000(struct i2c_client *client,
...@@ -77,8 +78,9 @@ static uint32_t float_to_u32_mul_1000000(struct i2c_client *client, ...@@ -77,8 +78,9 @@ static uint32_t float_to_u32_mul_1000000(struct i2c_client *client,
* Read a 8/16/32-bit i2c register. The value is returned in 'val'. * Read a 8/16/32-bit i2c register. The value is returned in 'val'.
* Returns zero if successful, or non-zero otherwise. * Returns zero if successful, or non-zero otherwise.
*/ */
int smiapp_read(struct i2c_client *client, u32 reg, u32 *val) int smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val)
{ {
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
struct i2c_msg msg; struct i2c_msg msg;
unsigned char data[4]; unsigned char data[4];
unsigned int len = (u8)(reg >> 16); unsigned int len = (u8)(reg >> 16);
...@@ -145,8 +147,9 @@ int smiapp_read(struct i2c_client *client, u32 reg, u32 *val) ...@@ -145,8 +147,9 @@ int smiapp_read(struct i2c_client *client, u32 reg, u32 *val)
* Write to a 8/16-bit register. * Write to a 8/16-bit register.
* Returns zero if successful, or non-zero otherwise. * Returns zero if successful, or non-zero otherwise.
*/ */
int smiapp_write(struct i2c_client *client, u32 reg, u32 val) int smiapp_write(struct smiapp_sensor *sensor, u32 reg, u32 val)
{ {
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
struct i2c_msg msg; struct i2c_msg msg;
unsigned char data[6]; unsigned char data[6];
unsigned int retries; unsigned int retries;
......
...@@ -40,7 +40,9 @@ struct smia_reg { ...@@ -40,7 +40,9 @@ struct smia_reg {
u32 val; /* 8/16/32-bit value */ u32 val; /* 8/16/32-bit value */
}; };
int smiapp_read(struct i2c_client *client, u32 reg, u32 *val); struct smiapp_sensor;
int smiapp_write(struct i2c_client *client, u32 reg, u32 val);
int smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val);
int smiapp_write(struct smiapp_sensor *sensor, u32 reg, u32 val);
#endif #endif
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