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;
    }

你可能感兴趣的:(android)