aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/w1_smem.c
diff options
context:
space:
mode:
authorEvgeniy Polyakov <johnpol@2ka.mipt.ru>2005-08-11 09:27:50 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-08 17:41:26 -0400
commitd2a4ef6a0ce4d841293b49bf2cdc17a0ebfaaf9d (patch)
tree2d49373e06fd65aae5217aad864fafb849c8cda2 /drivers/w1/w1_smem.c
parentea7d8f65c865ebfa1d7cd67c360a87333ff013c1 (diff)
[PATCH] w1: Added add/remove slave callbacks.
Patch is based on work from Ben Gardner <bgardner@wabtec.com> Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/w1/w1_smem.c')
-rw-r--r--drivers/w1/w1_smem.c47
1 files changed, 0 insertions, 47 deletions
diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c
index 2b6580c7e953..e3209d0aca9b 100644
--- a/drivers/w1/w1_smem.c
+++ b/drivers/w1/w1_smem.c
@@ -36,59 +36,12 @@ MODULE_LICENSE("GPL");
36MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 36MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
37MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); 37MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");
38 38
39static ssize_t w1_smem_read_name(struct device *, struct device_attribute *attr, char *);
40static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t);
41
42static struct w1_family_ops w1_smem_fops = {
43 .rname = &w1_smem_read_name,
44 .rbin = &w1_smem_read_bin,
45};
46
47static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf)
48{
49 struct w1_slave *sl = dev_to_w1_slave(dev);
50 return sprintf(buf, "%s\n", sl->name);
51}
52
53static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count)
54{
55 struct w1_slave *sl = kobj_to_w1_slave(kobj);
56 int i;
57
58 atomic_inc(&sl->refcnt);
59 if (down_interruptible(&sl->master->mutex)) {
60 count = 0;
61 goto out_dec;
62 }
63
64 if (off > W1_SLAVE_DATA_SIZE) {
65 count = 0;
66 goto out;
67 }
68 if (off + count > W1_SLAVE_DATA_SIZE) {
69 count = 0;
70 goto out;
71 }
72 for (i = 0; i < 8; ++i)
73 count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]);
74 count += sprintf(buf + count, "\n");
75
76out:
77 up(&sl->master->mutex);
78out_dec:
79 atomic_dec(&sl->refcnt);
80
81 return count;
82}
83
84static struct w1_family w1_smem_family_01 = { 39static struct w1_family w1_smem_family_01 = {
85 .fid = W1_FAMILY_SMEM_01, 40 .fid = W1_FAMILY_SMEM_01,
86 .fops = &w1_smem_fops,
87}; 41};
88 42
89static struct w1_family w1_smem_family_81 = { 43static struct w1_family w1_smem_family_81 = {
90 .fid = W1_FAMILY_SMEM_81, 44 .fid = W1_FAMILY_SMEM_81,
91 .fops = &w1_smem_fops,
92}; 45};
93 46
94static int __init w1_smem_init(void) 47static int __init w1_smem_init(void)