余青的博客

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


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值