aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/w1/w1.c69
-rw-r--r--drivers/w1/w1.h2
2 files changed, 69 insertions, 2 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index a698b517e863..c9486c168505 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -139,7 +139,74 @@ static struct bin_attribute w1_slave_attr_bin_id = {
139}; 139};
140 140
141/* Default family */ 141/* Default family */
142static struct w1_family w1_default_family; 142
143static ssize_t w1_default_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
144{
145 struct w1_slave *sl = kobj_to_w1_slave(kobj);
146
147 if (down_interruptible(&sl->master->mutex)) {
148 count = 0;
149 goto out;
150 }
151
152 if (w1_reset_select_slave(sl)) {
153 count = 0;
154 goto out_up;
155 }
156
157 w1_write_block(sl->master, buf, count);
158
159out_up:
160 up(&sl->master->mutex);
161out:
162 return count;
163}
164
165static ssize_t w1_default_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
166{
167 struct w1_slave *sl = kobj_to_w1_slave(kobj);
168
169 if (down_interruptible(&sl->master->mutex)) {
170 count = 0;
171 goto out;
172 }
173
174 w1_read_block(sl->master, buf, count);
175
176 up(&sl->master->mutex);
177out:
178 return count;
179}
180
181static struct bin_attribute w1_default_attr = {
182 .attr = {
183 .name = "rw",
184 .mode = S_IRUGO | S_IWUSR,
185 .owner = THIS_MODULE,
186 },
187 .size = PAGE_SIZE,
188 .read = w1_default_read,
189 .write = w1_default_write,
190};
191
192static int w1_default_add_slave(struct w1_slave *sl)
193{
194 return sysfs_create_bin_file(&sl->dev.kobj, &w1_default_attr);
195}
196
197static void w1_default_remove_slave(struct w1_slave *sl)
198{
199 sysfs_remove_bin_file(&sl->dev.kobj, &w1_default_attr);
200}
201
202static struct w1_family_ops w1_default_fops = {
203 .add_slave = w1_default_add_slave,
204 .remove_slave = w1_default_remove_slave,
205};
206
207static struct w1_family w1_default_family = {
208 .fops = &w1_default_fops,
209};
143 210
144static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); 211static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size);
145 212
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 56980505e6c4..02e8caddfb36 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -60,7 +60,7 @@ struct w1_reg_num
60#define W1_READ_PSUPPLY 0xB4 60#define W1_READ_PSUPPLY 0xB4
61#define W1_MATCH_ROM 0x55 61#define W1_MATCH_ROM 0x55
62 62
63#define W1_SLAVE_ACTIVE (1<<0) 63#define W1_SLAVE_ACTIVE 0
64 64
65struct w1_slave 65struct w1_slave
66{ 66{