http://blog.csdn.net/shadow_dance/article/details/8617594
creat sys 文件系统
#ifdef VIRTUAL_KEYS
static ssize_t virtual_keys_show(struct kobject *kobj,struct kobj_attribute *attr, char *buf)
{
return sprintf(buf,
__stringify(EV_KEY) ":" __stringify(KEY_VOLUMEUP) ":1030:370:30:30"
":" __stringify(EV_KEY) ":" __stringify(KEY_VOLUMEDOWN) ":1030:470:30:30"
":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":1030:18:30:30"
":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":1030:136:30:30"
":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":1030:236:30:30"
"\n");
}
static struct kobj_attribute virtual_keys_attr = {
.attr = {
.name = "virtualkeys.xxxx",
.mode = S_IRUGO,
},
.show = &virtual_keys_show,
};
static struct attribute *properties_attrs[] = {
&virtual_keys_attr.attr,
NULL
};
static struct attribute_group properties_attr_group = {
.attrs = properties_attrs,
};
static void virtual_keys_init(void)
{
int ret;
struct kobject *properties_kobj;
properties_kobj = kobject_create_and_add("board_properties", NULL);
if (properties_kobj)
ret = sysfs_create_group(properties_kobj,
&properties_attr_group);
if (!properties_kobj || ret)
pr_err("failed to create board_properties\n");
}
#endif
#ifdef TP_PROXIMITY_SENSOR
err = sysfs_create_group(&client->dev.kobj, &ft5306_attr_group);
static ssize_t ft5306_show_enable_ps_sensor(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct ft5x0x_ts_data *data = i2c_get_clientdata(client);
return sprintf(buf, "%d\n", data->enable_ps_sensor);
}
static ssize_t ft5306_store_enable_ps_sensor(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct ft5x0x_ts_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long flags;
int err;
char data_cmd[2]={0, 0};
printk("%s: enable ps senosr ( %ld)\n", __func__, val);
if ((val != 0) && (val != 1)) {
printk("%s:store unvalid value=%ld\n", __func__, val);
return count;
}
if(val == 1) {
}
else {
}
return count;
}
static DEVICE_ATTR(enable_ps_sensor, S_IWUGO | S_IRUGO,
ft5306_show_enable_ps_sensor, ft5306_store_enable_ps_sensor);
static struct attribute *ft5306_attributes[] = {
&dev_attr_enable_ps_sensor.attr,
NULL
};
static const struct attribute_group ft5306_attr_group = {
.attrs = ft5306_attributes,
};
#endif