android驅動下生成設備節點的方法

echo 1 > /sys/devices/platform/s3c2440-i2c.2/i2c-2/2-0055/bqfs_update


static ssize_t set_bqfs_update(struct device *dev,
                        struct device_attribute *attr, const char *buf,
                        size_t count)
{
    struct bq27410_device_info *di = dev_get_drvdata(dev);
    unsigned int    val;

    if (!(sscanf(buf, "%u\n", &val)))
 return -EINVAL;
   
    //upgrade BFG file
    bq27410_DEBUG("set_bqfs_update %d\n", val);
    bq27410_upgrade(di);

    return count;
}

 

static DEVICE_ATTR(bqfs_update, S_IRUGO | S_IWUSR, NULL, set_bqfs_update);

static struct attribute *bq27410_sysfs_entries[] = {
        &dev_attr_bqfs_update.attr,
        NULL
};

static struct attribute_group bq27410_attr_group = {
        .name   = NULL,
        .attrs  = bq27410_sysfs_entries,
};

 

struct i2c_client *client
 retval = sysfs_create_group(&client->dev.kobj, &bq27410_attr_group);
    if (retval) {
        bq27410_DEBUG("sysfs_create_group failed\n");
        goto batt_failed_5;
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章