From 0f5b360afc8abbb5927b6a9562eef46f19f0305a Mon Sep 17 00:00:00 2001 From: Cai Wenzhong Date: Wed, 24 Jan 2024 09:41:02 +0800 Subject: [PATCH] media: i2c: maxim: remote: record the status of the serializer Signed-off-by: Cai Wenzhong Change-Id: Iee78aff7e99950313e5134bd9b0dd73422f0bec1 --- drivers/media/i2c/maxim/remote/max9295.c | 9 ++++++++- drivers/media/i2c/maxim/remote/max96715.c | 9 ++++++++- drivers/media/i2c/maxim/remote/max96717.c | 7 +++++++ drivers/media/i2c/maxim/remote/maxim_remote.h | 12 ++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/maxim/remote/max9295.c b/drivers/media/i2c/maxim/remote/max9295.c index 9501dfc88d5d..ea3d20bc47dc 100644 --- a/drivers/media/i2c/maxim/remote/max9295.c +++ b/drivers/media/i2c/maxim/remote/max9295.c @@ -18,7 +18,7 @@ #define DRIVER_VERSION KERNEL_VERSION(3, 0x01, 0x00) -#define MAX9295_NAME "max9295" +#define MAX9295_NAME "maxim-max9295" #define MAX9295_I2C_ADDR_DEF 0x40 @@ -456,6 +456,8 @@ static int max9295_module_init(maxim_remote_ser_t *max9295) return ret; } + max9295->ser_state = MAXIM_REMOTE_SER_INIT; + return 0; } @@ -468,6 +470,8 @@ static int max9295_module_deinit(maxim_remote_ser_t *max9295) #endif ret |= max9295_soft_power_down(max9295); + max9295->ser_state = MAXIM_REMOTE_SER_DEINIT; + return ret; } @@ -515,6 +519,7 @@ static int max9295_probe(struct i2c_client *client, max9295->client = client; max9295->ser_i2c_addr_map = client->addr; max9295->ser_ops = &max9295_ser_ops; + max9295->ser_state = MAXIM_REMOTE_SER_DEINIT; i2c_set_clientdata(client, max9295); @@ -537,6 +542,8 @@ static void max9295_remove(struct i2c_client *client) mutex_destroy(&max9295->mutex); + max9295->ser_state = MAXIM_REMOTE_SER_DEINIT; + #if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE return 0; #endif diff --git a/drivers/media/i2c/maxim/remote/max96715.c b/drivers/media/i2c/maxim/remote/max96715.c index fc6a6cf0ddbf..1d568468b9b5 100644 --- a/drivers/media/i2c/maxim/remote/max96715.c +++ b/drivers/media/i2c/maxim/remote/max96715.c @@ -18,7 +18,7 @@ #define DRIVER_VERSION KERNEL_VERSION(3, 0x01, 0x00) -#define MAX96715_NAME "max96715" +#define MAX96715_NAME "maxim-max96715" #define MAX96715_I2C_ADDR_DEF 0x40 @@ -457,6 +457,8 @@ static int max96715_module_init(maxim_remote_ser_t *max96715) return ret; #endif + max96715->ser_state = MAXIM_REMOTE_SER_INIT; + return 0; } @@ -469,6 +471,8 @@ static int max96715_module_deinit(maxim_remote_ser_t *max96715) #endif ret |= max96715_soft_power_down(max96715); + max96715->ser_state = MAXIM_REMOTE_SER_DEINIT; + return ret; } @@ -516,6 +520,7 @@ static int max96715_probe(struct i2c_client *client, max96715->client = client; max96715->ser_i2c_addr_map = client->addr; max96715->ser_ops = &max96715_ser_ops; + max96715->ser_state = MAXIM_REMOTE_SER_DEINIT; i2c_set_clientdata(client, max96715); @@ -538,6 +543,8 @@ static void max96715_remove(struct i2c_client *client) mutex_destroy(&max96715->mutex); + max96715->ser_state = MAXIM_REMOTE_SER_DEINIT; + #if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE return 0; #endif diff --git a/drivers/media/i2c/maxim/remote/max96717.c b/drivers/media/i2c/maxim/remote/max96717.c index c2a19887ea37..209f8b4c0d06 100644 --- a/drivers/media/i2c/maxim/remote/max96717.c +++ b/drivers/media/i2c/maxim/remote/max96717.c @@ -409,6 +409,8 @@ static int max96717_module_init(maxim_remote_ser_t *max96717) return ret; } + max96717->ser_state = MAXIM_REMOTE_SER_INIT; + return 0; } @@ -418,6 +420,8 @@ static int max96717_module_deinit(maxim_remote_ser_t *max96717) ret |= max96717_i2c_addr_def(max96717); + max96717->ser_state = MAXIM_REMOTE_SER_DEINIT; + return ret; } @@ -465,6 +469,7 @@ static int max96717_probe(struct i2c_client *client, max96717->client = client; max96717->ser_i2c_addr_map = client->addr; max96717->ser_ops = &max96717_ser_ops; + max96717->ser_state = MAXIM_REMOTE_SER_DEINIT; i2c_set_clientdata(client, max96717); @@ -487,6 +492,8 @@ static void max96717_remove(struct i2c_client *client) mutex_destroy(&max96717->mutex); + max96717->ser_state = MAXIM_REMOTE_SER_DEINIT; + #if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE return 0; #endif diff --git a/drivers/media/i2c/maxim/remote/maxim_remote.h b/drivers/media/i2c/maxim/remote/maxim_remote.h index 8a79df354ed1..692871d81e0e 100644 --- a/drivers/media/i2c/maxim/remote/maxim_remote.h +++ b/drivers/media/i2c/maxim/remote/maxim_remote.h @@ -25,6 +25,10 @@ enum rkmodule_pad_type { #endif #endif /* LINUX_VERSION_CODE */ +/* Serializer State */ +#define MAXIM_REMOTE_SER_DEINIT 0 +#define MAXIM_REMOTE_SER_INIT 1 + /* I2C Device ID */ enum { MAXIM_REMOTE_I2C_SER_DEF, /* Serializer I2C address: Default */ @@ -76,6 +80,7 @@ typedef struct maxim_remote_ser { u8 cam_i2c_addr_def; u8 cam_i2c_addr_map; + u32 ser_state; struct maxim_remote_init_seq ser_init_seq; const struct maxim_remote_ser_ops *ser_ops; } maxim_remote_ser_t; @@ -325,4 +330,11 @@ static inline struct maxim_remote_ser *maxim_remote_cam_bind_ser(struct device * } } +static inline bool maxim_remote_ser_is_inited(maxim_remote_ser_t *remote_ser) +{ + if (remote_ser && (remote_ser->ser_state == MAXIM_REMOTE_SER_INIT)) + return true; + + return false; +} #endif /* __MAXIM_REMOTE_H__ */