mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
gsensor code result in system reboot,gsensor code by lw update
This commit is contained in:
@@ -40,73 +40,6 @@
|
||||
#define DBG(x...)
|
||||
#endif
|
||||
|
||||
struct i2c_client *kxtik_client=NULL;
|
||||
static struct class *sensor_class = NULL;
|
||||
|
||||
static ssize_t sensor_setoratitention(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int i=0;
|
||||
char gsensororatation[20];
|
||||
|
||||
struct sensor_private_data *sensor =
|
||||
(struct sensor_private_data *) i2c_get_clientdata(kxtik_client);
|
||||
struct sensor_platform_data *pdata = sensor->pdata;
|
||||
|
||||
|
||||
char *p = strstr(buf,"gsensor");
|
||||
int start = strcspn(p,"{");
|
||||
int end = strcspn(p,"}");
|
||||
|
||||
strncpy(gsensororatation,p+start,end-start+1);
|
||||
char *tmp=gsensororatation;
|
||||
|
||||
|
||||
while(strncmp(tmp,"}",1)!=0)
|
||||
{
|
||||
if((strncmp(tmp,",",1)==0)||(strncmp(tmp,"{",1)==0))
|
||||
{
|
||||
|
||||
tmp++;
|
||||
continue;
|
||||
}
|
||||
else if(strncmp(tmp,"-",1)==0)
|
||||
{
|
||||
pdata->orientation[i++]=-1;
|
||||
DBG("i=%d,data=%d\n",i,pdata->orientation[i]);
|
||||
tmp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdata->orientation[i++]=tmp[0]-48;
|
||||
DBG("----i=%d,data=%d\n",i,pdata->orientation[i]);
|
||||
}
|
||||
tmp++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
for(i=0;i<9;i++)
|
||||
DBG("i=%d gsensor_info=%d\n",i,pdata->orientation[i]);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static CLASS_ATTR(oratiention, 0777, NULL,sensor_setoratitention);
|
||||
|
||||
static int sensor_sys_init(void)
|
||||
{
|
||||
int ret ;
|
||||
sensor_class = class_create(THIS_MODULE, "gsensor");
|
||||
ret = class_create_file(sensor_class, &class_attr_oratiention);
|
||||
if (ret)
|
||||
{
|
||||
printk("Fail to creat class oratiention.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/****************operate according to sensor chip:start************/
|
||||
|
||||
static int sensor_active(struct i2c_client *client, int enable, int rate)
|
||||
@@ -152,7 +85,6 @@ static int sensor_init(struct i2c_client *client)
|
||||
return result;
|
||||
}
|
||||
|
||||
kxtik_client=client;
|
||||
sensor->status_cur = SENSOR_OFF;
|
||||
|
||||
result = sensor_write_reg(client, KXTIK_DATA_CTRL_REG, KXTIK_ODR400F);
|
||||
@@ -180,8 +112,6 @@ static int sensor_init(struct i2c_client *client)
|
||||
return result;
|
||||
}
|
||||
|
||||
sensor_sys_init();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,73 +91,6 @@ struct sensor_reg_data {
|
||||
char data;
|
||||
};
|
||||
|
||||
struct i2c_client *lis3dgh_client=NULL;
|
||||
static struct class *sensor_class = NULL;
|
||||
|
||||
static ssize_t sensor_setoratitention(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int i=0;
|
||||
char gsensororatation[20];
|
||||
|
||||
struct sensor_private_data *sensor =
|
||||
(struct sensor_private_data *) i2c_get_clientdata(lis3dgh_client);
|
||||
struct sensor_platform_data *pdata = sensor->pdata;
|
||||
|
||||
|
||||
char *p = strstr(buf,"gsensor");
|
||||
int start = strcspn(p,"{");
|
||||
int end = strcspn(p,"}");
|
||||
|
||||
strncpy(gsensororatation,p+start,end-start+1);
|
||||
char *tmp=gsensororatation;
|
||||
|
||||
|
||||
while(strncmp(tmp,"}",1)!=0)
|
||||
{
|
||||
if((strncmp(tmp,",",1)==0)||(strncmp(tmp,"{",1)==0))
|
||||
{
|
||||
|
||||
tmp++;
|
||||
continue;
|
||||
}
|
||||
else if(strncmp(tmp,"-",1)==0)
|
||||
{
|
||||
pdata->orientation[i++]=-1;
|
||||
DBG("i=%d,data=%d\n",i,pdata->orientation[i]);
|
||||
tmp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdata->orientation[i++]=tmp[0]-48;
|
||||
DBG("----i=%d,data=%d\n",i,pdata->orientation[i]);
|
||||
}
|
||||
tmp++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
for(i=0;i<9;i++)
|
||||
DBG("i=%d gsensor_info=%d\n",i,pdata->orientation[i]);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static CLASS_ATTR(oratiention, 0777, NULL,sensor_setoratitention);
|
||||
|
||||
static int sensor_sys_init(void)
|
||||
{
|
||||
int ret ;
|
||||
sensor_class = class_create(THIS_MODULE, "gsensor");
|
||||
ret = class_create_file(sensor_class, &class_attr_oratiention);
|
||||
if (ret)
|
||||
{
|
||||
printk("Fail to creat class oratiention.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/****************operate according to sensor chip:start************/
|
||||
|
||||
static int sensor_active(struct i2c_client *client, int enable, int rate)
|
||||
@@ -216,7 +149,6 @@ static int sensor_init(struct i2c_client *client)
|
||||
printk("%s:line=%d,error\n",__func__,__LINE__);
|
||||
return result;
|
||||
}
|
||||
lis3dgh_client = client;
|
||||
|
||||
sensor->status_cur = SENSOR_OFF;
|
||||
|
||||
@@ -250,7 +182,6 @@ static int sensor_init(struct i2c_client *client)
|
||||
|
||||
}
|
||||
|
||||
sensor_sys_init();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,73 +48,6 @@
|
||||
#define MMA8452_ENABLE 1
|
||||
|
||||
|
||||
struct i2c_client *mma8452_client=NULL;
|
||||
static struct class *sensor_class = NULL;
|
||||
|
||||
static ssize_t sensor_setoratitention(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int i=0;
|
||||
char gsensororatation[20];
|
||||
|
||||
struct sensor_private_data *sensor =
|
||||
(struct sensor_private_data *) i2c_get_clientdata(mma8452_client);
|
||||
struct sensor_platform_data *pdata = sensor->pdata;
|
||||
|
||||
|
||||
char *p = strstr(buf,"gsensor");
|
||||
int start = strcspn(p,"{");
|
||||
int end = strcspn(p,"}");
|
||||
|
||||
strncpy(gsensororatation,p+start,end-start+1);
|
||||
char *tmp=gsensororatation;
|
||||
|
||||
|
||||
while(strncmp(tmp,"}",1)!=0)
|
||||
{
|
||||
if((strncmp(tmp,",",1)==0)||(strncmp(tmp,"{",1)==0))
|
||||
{
|
||||
|
||||
tmp++;
|
||||
continue;
|
||||
}
|
||||
else if(strncmp(tmp,"-",1)==0)
|
||||
{
|
||||
pdata->orientation[i++]=-1;
|
||||
DBG("i=%d,data=%d\n",i,pdata->orientation[i]);
|
||||
tmp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdata->orientation[i++]=tmp[0]-48;
|
||||
DBG("----i=%d,data=%d\n",i,pdata->orientation[i]);
|
||||
}
|
||||
tmp++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
for(i=0;i<9;i++)
|
||||
DBG("i=%d gsensor_info=%d\n",i,pdata->orientation[i]);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static CLASS_ATTR(oratiention, 0777, NULL,sensor_setoratitention);
|
||||
|
||||
static int sensor_sys_init(void)
|
||||
{
|
||||
int ret ;
|
||||
sensor_class = class_create(THIS_MODULE, "gsensor");
|
||||
ret = class_create_file(sensor_class, &class_attr_oratiention);
|
||||
if (ret)
|
||||
{
|
||||
printk("Fail to creat class oratiention.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/****************operate according to sensor chip:start************/
|
||||
|
||||
static int sensor_active(struct i2c_client *client, int enable, int rate)
|
||||
@@ -161,7 +94,6 @@ static int sensor_init(struct i2c_client *client)
|
||||
return ret;
|
||||
}
|
||||
|
||||
mma8452_client=client;
|
||||
sensor->status_cur = SENSOR_OFF;
|
||||
|
||||
/* disable FIFO FMODE = 0*/
|
||||
@@ -193,8 +125,8 @@ static int sensor_init(struct i2c_client *client)
|
||||
|
||||
DBG("mma8452 MMA8452_REG_SYSMOD:%x\n",sensor_read_reg(client,MMA8452_REG_SYSMOD));
|
||||
|
||||
sensor_sys_init();
|
||||
|
||||
printk("------sensor_chip_init\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user