summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2011-05-03 14:14:56 +0530
committerVarun Colbert <vcolbert@nvidia.com>2011-05-11 15:15:54 -0700
commitd1bf1333593f1d19740b2619377abf760b138cbe (patch)
treeeecb1bcf44540a0d75a24eeec8eed6644bef1692
parentdea4648595c273fb017ccafaabc7cbcfcc546bf7 (diff)
media: sh532u: Adding board related init/deinit
When device sh532u is open, it calls board related initialization and de- initialization function. In the board related functions, the client can initialize the required signal, power on/off the device etc. bug 802264 Change-Id: Ie69a6e70c5d104489d248bef538e89263208ee54 Reviewed-on: http://git-master/r/30169 Tested-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Danielle Sun <dsun@nvidia.com> Tested-by: Danielle Sun <dsun@nvidia.com> Reviewed-by: Prayas Mohanty <pmohanty@nvidia.com>
-rw-r--r--drivers/media/video/tegra/sh532u.c14
-rw-r--r--include/media/sh532u.h7
2 files changed, 21 insertions, 0 deletions
diff --git a/drivers/media/video/tegra/sh532u.c b/drivers/media/video/tegra/sh532u.c
index fbbf320a8099..7a707dff21e8 100644
--- a/drivers/media/video/tegra/sh532u.c
+++ b/drivers/media/video/tegra/sh532u.c
@@ -38,6 +38,7 @@
struct sh532u_info {
struct i2c_client *i2c_client;
struct sh532u_config config;
+ struct sh532u_platform_data sh532u_pdata;
};
static struct sh532u_info *info;
@@ -534,6 +535,9 @@ static int sh532u_open(struct inode *inode, struct file *file)
{
pr_info("sh532 open\n");
file->private_data = info;
+ if (info->sh532u_pdata.board_init)
+ info->sh532u_pdata.board_init(
+ info->sh532u_pdata.context_data);
init_driver();
return 0;
}
@@ -541,6 +545,9 @@ static int sh532u_open(struct inode *inode, struct file *file)
int sh532u_release(struct inode *inode, struct file *file)
{
pr_info("sh532 release\n");
+ if (info->sh532u_pdata.board_deinit)
+ info->sh532u_pdata.board_deinit(
+ info->sh532u_pdata.context_data);
file->private_data = NULL;
return 0;
}
@@ -564,6 +571,7 @@ static int sh532u_probe(
const struct i2c_device_id *id)
{
int err;
+ struct sh532u_platform_data *sh532u_pdata = client->dev.platform_data;
pr_info("sh532u: probing sensor.\n");
info = kzalloc(sizeof(struct sh532u_info), GFP_KERNEL);
@@ -584,6 +592,12 @@ static int sh532u_probe(
info->config.pos_low = POS_LOW;
info->config.pos_high = POS_HIGH;
i2c_set_clientdata(client, info);
+
+ if (sh532u_pdata) {
+ info->sh532u_pdata.context_data = sh532u_pdata->context_data;
+ info->sh532u_pdata.board_init = sh532u_pdata->board_init;
+ info->sh532u_pdata.board_deinit = sh532u_pdata->board_deinit;
+ }
return 0;
}
diff --git a/include/media/sh532u.h b/include/media/sh532u.h
index 9fba8e084e29..5c4ffd9d42f8 100644
--- a/include/media/sh532u.h
+++ b/include/media/sh532u.h
@@ -43,6 +43,11 @@ struct sh532u_config {
s16 limit_high;
};
+struct sh532u_platform_data {
+ void *context_data;
+ int (*board_init)(void *context_data);
+ int (*board_deinit)(void *context_data);
+};
/* Register Definition : Sany Driver IC */
/* EEPROM addresses */
#define addrHallOffset 0x10
@@ -302,7 +307,9 @@ P0 P1
#define END_ADDR 0x01BF
/*Macro define*/
+#if !defined(abs)
#define abs(a) (((a) > 0) ? (a) : -(a))
+#endif
#endif
/* __SH532U_H__ */