]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
w1: add touch block command
authorEvgeniy Polyakov <zbr@ioremap.net>
Thu, 8 Jan 2009 02:09:01 +0000 (18:09 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 8 Jan 2009 16:31:13 +0000 (08:31 -0800)
Writes and returns sampled data back to userspace.

Signed-off-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/w1/w1.h
drivers/w1/w1_io.c
drivers/w1/w1_netlink.c
drivers/w1/w1_netlink.h

index 97304bd83ec9674105bc837a4e9ecea6ba373cfd..d8a9709f3449159a2f8ada1c2ca328316414ed79 100644 (file)
@@ -210,6 +210,7 @@ u8 w1_read_8(struct w1_master *);
 int w1_reset_bus(struct w1_master *);
 u8 w1_calc_crc8(u8 *, int);
 void w1_write_block(struct w1_master *, const u8 *, int);
+void w1_touch_block(struct w1_master *, u8 *, int);
 u8 w1_read_block(struct w1_master *, u8 *, int);
 int w1_reset_select_slave(struct w1_slave *sl);
 void w1_next_pullup(struct w1_master *, int);
index 5139c25ca96288474cf976cf5577be12c6d6d30b..442bd8bbd4a5dcbed086cae48fed1350ba9e31b6 100644 (file)
@@ -238,7 +238,6 @@ EXPORT_SYMBOL_GPL(w1_read_8);
  * @param dev     the master device
  * @param buf     pointer to the data to write
  * @param len     the number of bytes to write
- * @return        the byte read
  */
 void w1_write_block(struct w1_master *dev, const u8 *buf, int len)
 {
@@ -255,6 +254,31 @@ void w1_write_block(struct w1_master *dev, const u8 *buf, int len)
 }
 EXPORT_SYMBOL_GPL(w1_write_block);
 
+/**
+ * Touches a series of bytes.
+ *
+ * @param dev     the master device
+ * @param buf     pointer to the data to write
+ * @param len     the number of bytes to write
+ */
+void w1_touch_block(struct w1_master *dev, u8 *buf, int len)
+{
+       int i, j;
+       u8 tmp;
+
+       for (i = 0; i < len; ++i) {
+               tmp = 0;
+               for (j = 0; j < 8; ++j) {
+                       if (j == 7)
+                               w1_pre_write(dev);
+                       tmp |= w1_touch_bit(dev, (buf[i] >> j) & 0x1) << j;
+               }
+
+               buf[i] = tmp;
+       }
+}
+EXPORT_SYMBOL_GPL(w1_touch_block);
+
 /**
  * Reads a series of bytes.
  *
index 2e07b59b9859a9d28dcf0e71b7b9b217b7bb8dff..cae556c8577b6ca8f1a0df916259229907edc40b 100644 (file)
@@ -108,6 +108,10 @@ static int w1_process_command_slave(struct w1_slave *sl, struct cn_msg *msg,
                cmd->cmd, cmd->len);
 
        switch (cmd->cmd) {
+               case W1_CMD_TOUCH:
+                       w1_touch_block(sl->master, cmd->data, cmd->len);
+                       w1_send_read_reply(sl, msg, hdr, cmd);
+                       break;
                case W1_CMD_READ:
                        w1_read_block(sl->master, cmd->data, cmd->len);
                        w1_send_read_reply(sl, msg, hdr, cmd);
@@ -208,9 +212,6 @@ static void w1_cn_callback(void *data)
                        break;
                }
 
-               if (!mlen)
-                       goto out_cont;
-
                if (m->type == W1_MASTER_CMD) {
                        dev = w1_search_master_id(m->id.mst.id);
                } else if (m->type == W1_SLAVE_CMD) {
@@ -227,6 +228,10 @@ static void w1_cn_callback(void *data)
                        goto out_cont;
                }
 
+               err = 0;
+               if (!mlen)
+                       goto out_cont;
+
                mutex_lock(&dev->mutex);
 
                if (sl && w1_reset_select_slave(sl)) {
index 21913dfc0f3acbb2a15f2492652f79d19961ac89..99dd21ba14c6143d632bf9a8c4d3f8fb63eb44f3 100644 (file)
@@ -56,6 +56,7 @@ struct w1_netlink_msg
 #define W1_CMD_WRITE           0x1
 #define W1_CMD_SEARCH          0x2
 #define W1_CMD_ALARM_SEARCH    0x3
+#define W1_CMD_TOUCH           0x4
 
 struct w1_netlink_cmd
 {