Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114924
b: refs/heads/master
c: 07e0034
h: refs/heads/master
v: v3
  • Loading branch information
David Fries authored and Linus Torvalds committed Oct 16, 2008
1 parent c9588ca commit 0ddf155
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eba3b06da4bd8b79fe6c8ed922a319362c1a40c0
refs/heads/master: 07e003417b88deac4b887c98f499fc3b01bc8df0
35 changes: 10 additions & 25 deletions trunk/drivers/w1/w1.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,20 @@ static ssize_t w1_slave_read_name(struct device *dev, struct device_attribute *a
return sprintf(buf, "%s\n", sl->name);
}

static ssize_t w1_slave_read_id(struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
static ssize_t w1_slave_read_id(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct w1_slave *sl = kobj_to_w1_slave(kobj);

if (off > 8) {
count = 0;
} else {
if (off + count > 8)
count = 8 - off;

memcpy(buf, (u8 *)&sl->reg_num, count);
}
struct w1_slave *sl = dev_to_w1_slave(dev);
ssize_t count = sizeof(sl->reg_num);

memcpy(buf, (u8 *)&sl->reg_num, count);
return count;
}

static struct device_attribute w1_slave_attr_name =
__ATTR(name, S_IRUGO, w1_slave_read_name, NULL);

static struct bin_attribute w1_slave_attr_bin_id = {
.attr = {
.name = "id",
.mode = S_IRUGO,
},
.size = 8,
.read = w1_slave_read_id,
};
static struct device_attribute w1_slave_attr_id =
__ATTR(id, S_IRUGO, w1_slave_read_id, NULL);

/* Default family */

Expand Down Expand Up @@ -650,7 +635,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
}

/* Create "id" entry */
err = sysfs_create_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id);
err = device_create_file(&sl->dev, &w1_slave_attr_id);
if (err < 0) {
dev_err(&sl->dev,
"sysfs file creation for [%s] failed. err=%d\n",
Expand All @@ -672,7 +657,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
return 0;

out_rem2:
sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id);
device_remove_file(&sl->dev, &w1_slave_attr_id);
out_rem1:
device_remove_file(&sl->dev, &w1_slave_attr_name);
out_unreg:
Expand Down Expand Up @@ -754,7 +739,7 @@ void w1_slave_detach(struct w1_slave *sl)
msg.type = W1_SLAVE_REMOVE;
w1_netlink_send(sl->master, &msg);

sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id);
device_remove_file(&sl->dev, &w1_slave_attr_id);
device_remove_file(&sl->dev, &w1_slave_attr_name);
device_unregister(&sl->dev);

Expand Down

0 comments on commit 0ddf155

Please sign in to comment.