Skip to contentSkip to conversation

extend userspace commands.

W1 Evgeniy Polyakov 3 participants 12 messages Dec 4, 2008 – Dec 5, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi.

This patch series introduces and extends several userspace commands used with netlink protocol.

Touch block command allows to write data and return sampled data to the userspace.

Extended search and alarm seach commands to return list of slave devices found during given search.

List masters command allows to send all registered master IDs to the userspace.

Great thanks to Paul Alfille <[email protected]> (owfs) who tested this implementation and wrote w1-to-network daemon
http://sourceforge.net/projects/w1repeater/

#2 lore raw

[W1] Added list masters w1 command.

---
 drivers/w1/w1_netlink.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/w1/w1_netlink.h |    1 +
 2 files changed, 57 insertions(+), 0 deletions(-)
drivers/w1/w1_netlink.c +56 -0
index 65c5ebd..a3b2630 100644
@@ -128,6 +128,59 @@ static int w1_process_command_slave(struct w1_slave *sl, struct cn_msg *msg,
 	return err;
 }
 
+static int w1_process_command_root(struct cn_msg *msg, struct w1_netlink_msg *mcmd)
+{
+	struct w1_master *m;
+	struct cn_msg *cn;
+	struct w1_netlink_msg *w;
+	u32 *id;
+
+	if (mcmd->type != W1_LIST_MASTERS) {
+		printk(KERN_NOTICE "%s: msg: %x.%x, wrong type: %u, len: %u.\n",
+				__func__, msg->id.idx, msg->id.val, mcmd->type, mcmd->len);
+		return -EPROTO;
+	}
+
+	cn = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!cn)
+		return -ENOMEM;
+
+	cn->id.idx = CN_W1_IDX;
+	cn->id.val = CN_W1_VAL;
+
+	cn->seq = msg->seq;
+	cn->ack = 1;
+	cn->len = sizeof(struct w1_netlink_msg);
+	w = (struct w1_netlink_msg *)(cn + 1);
+
+	w->type = W1_LIST_MASTERS;
+	w->reserved = 0;
+	w->len = 0;
+	id = (u32 *)(w + 1);
+
+	mutex_lock(&w1_mlock);
+	list_for_each_entry(m, &w1_masters, w1_master_entry) {
+		if (cn->len + sizeof(*id) > PAGE_SIZE - sizeof(struct cn_msg)) {
+			cn_netlink_send(cn, 0, GFP_KERNEL);
+			cn->ack++
+			cn->len = sizeof(struct w1_netlink_msg);
+			w->len = 0;
+			id = (u32 *)(w + 1);
+		}
+
+		*id = m->id;
+		w->len += sizeof(*id);
+		cn->len += sizeof(*id);
+		id++;
+	}
+	cn->ack = 0;
+	cn_netlink_send(cn, 0, GFP_KERNEL);
+	mutex_unlock(&w1_mlock);
+
+	kfree(cn);
+	return 0;
+}
+
 static void w1_cn_callback(void *data)
 {
 	struct cn_msg *msg = data;
@@ -164,6 +217,9 @@ static void w1_cn_callback(void *data)
 			sl = w1_search_slave(&id);
 			if (sl)
 				dev = sl->master;
+		} else {
+			err = w1_process_command_root(msg, m);
+			goto out_cont;
 		}
 
 		if (!dev) {
drivers/w1/w1_netlink.h +1 -0
index 56122b9..21913df 100644
@@ -34,6 +34,7 @@ enum w1_netlink_message_types {
 	W1_MASTER_REMOVE,
 	W1_MASTER_CMD,
 	W1_SLAVE_CMD,
+	W1_LIST_MASTERS,
 };
 
 struct w1_netlink_msg
Signature · 1 line
1.5.2.5
#3 lore raw

[W1] Added touch block command.

---
 drivers/w1/w1.h         |    1 +
 drivers/w1/w1_io.c      |   26 +++++++++++++++++++++++++-
 drivers/w1/w1_netlink.c |   13 +++++++++----
 drivers/w1/w1_netlink.h |    1 +
 4 files changed, 36 insertions(+), 5 deletions(-)
drivers/w1/w1.h +1 -0
index 97304bd..d8a9709 100644
@@ -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);
drivers/w1/w1_io.c +25 -1
index 0d15b0e..3d781f8 100644
@@ -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)
 {
@@ -256,6 +255,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.
  *
  * @param dev     the master device
drivers/w1/w1_netlink.c +9 -4
index a3b2630..cae556c 100644
@@ -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);
@@ -162,7 +166,7 @@ static int w1_process_command_root(struct cn_msg *msg, struct w1_netlink_msg *mc
 	list_for_each_entry(m, &w1_masters, w1_master_entry) {
 		if (cn->len + sizeof(*id) > PAGE_SIZE - sizeof(struct cn_msg)) {
 			cn_netlink_send(cn, 0, GFP_KERNEL);
-			cn->ack++
+			cn->ack++;
 			cn->len = sizeof(struct w1_netlink_msg);
 			w->len = 0;
 			id = (u32 *)(w + 1);
@@ -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)) {
drivers/w1/w1_netlink.h +1 -0
index 21913df..99dd21b 100644
@@ -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
 {
Signature · 1 line
1.5.2.5
#4 lore raw

[W1] Updated documentation.

---
 Documentation/w1/w1.netlink |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)
Documentation/w1/w1.netlink +25 -9
index 3640c7c..eae5c8b 100644
@@ -17,25 +17,27 @@ Protocol.
 [struct cn_msg] - connector header. It's length field is equal to size of the attached data.
 [struct w1_netlink_msg] - w1 netlink header.
 	__u8 type 	- message type.
+			W1_LIST_MASTERS - list current bus master list
 			W1_SLAVE_ADD/W1_SLAVE_REMOVE - slave add/remove events.
 			W1_MASTER_ADD/W1_MASTER_REMOVE - master add/remove events.
 			W1_MASTER_CMD - userspace command for bus master device (search/alarm search).
 			W1_SLAVE_CMD - userspace command for slave device (read/write/ search/alarm search
 					for bus master device where given slave device found).
 	__u8 res	- reserved
-	__u16 len	- size of attached to this header data.
+	__u16 len	- size of data attached to this header data.
 	union {
-		__u8 id;			 - slave unique device id
+		__u8 id[8];			 - slave unique device id
 		struct w1_mst {
 			__u32		id;	 - master's id.
 			__u32		res;	 - reserved
 		} mst;
 	} id;
 
-[strucrt w1_netlink_cmd] - command for gived master or slave device.
+[struct w1_netlink_cmd] - command for given master or slave device.
 	__u8 cmd	- command opcode.
 			W1_CMD_READ 	- read command.
 			W1_CMD_WRITE	- write command.
+			W1_CMD_TOUCH	- touch command (write and sample data back to userspace).
 			W1_CMD_SEARCH	- search command.
 			W1_CMD_ALARM_SEARCH - alarm search command.
 	__u8 res	- reserved
@@ -44,7 +46,7 @@ Protocol.
 	__u8 data[0]	- data for this command.
 
 
-Each connector message can include one or more w1_netlink_msg with zero of more attached w1_netlink_cmd messages.
+Each connector message can include one or more w1_netlink_msg with zero or more attached w1_netlink_cmd messages.
 
 For event messages there are no w1_netlink_cmd embedded structures, only connector header
 and w1_netlink_msg strucutre with "len" field being zero and filled type (one of event types)
@@ -59,11 +61,25 @@ cn_msg.len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + cmd
 w1_netlink_msg.len = sizeof(struct w1_netlink_cmd) + cmd->len;
 w1_netlink_cmd.len = cmd->len;
 
+Replies to W1_LIST_MASTERS should send a message back to the userspace
+which will contain list of all registered master ids in the following
+format:
+	
+	cn_msg (CN_W1_IDX.CN_W1_VAL as id, len is equal to sizeof(struct
+	w1_netlink_msg) plus number of masters multipled by 4)
+	w1_netlink_msg (type: W1_LIST_MASTERS, len is equal to number of masters
+	multiplied by 4 (u32 size))
+	id0 ... idN
+	
+	Each message is at most 4k in size, so if number of master devices
+	exceeds this, it will be split into several messages, cn.seq will be
+	increased for each one.
+	
 
 Operation steps in w1 core when new command is received.
 =======================================================
 
-When new message (w1_netlink_msg) is received w1 core detects if it is master of slave request,
+When new message (w1_netlink_msg) is received w1 core detects if it is master or slave request,
 according to w1_netlink_msg.type field.
 Then master or slave device is searched for.
 When found, master device (requested or those one on where slave device is found) is locked.
@@ -82,10 +98,10 @@ Connector [1] specific documentation.
 Each connector message includes two u32 fields as "address".
 w1 uses CN_W1_IDX and CN_W1_VAL defined in include/linux/connector.h header.
 Each message also includes sequence and acknowledge numbers.
-Sequence number for event messages is appropriate bus master sequence number increased with
+Sequence number for event messages is appropriate bus master sequence number increased with 
 each event message sent "through" this master.
 Sequence number for userspace requests is set by userspace application.
-Sequence number for reply is the same as was in request, and
+Sequence number for reply is the same as was in request, and 
 acknowledge number is set to seq+1.
 
 
@@ -93,6 +109,6 @@ Additional documantion, source code examples.
 ============================================
 
 1. Documentation/connector
-2. http://tservice.net.ru/~s0mbre/archive/w1
-This archive includes userspace application w1d.c which
+2. http://www.ioremap.net/archive/w1
+This archive includes userspace application w1d.c which 
 uses read/write/search commands for all master/slave devices found on the bus.
Signature · 1 line
1.5.2.5
#5 lore raw

[W1] List slaves commands.

---
 drivers/w1/w1_netlink.c |  102 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 85 insertions(+), 17 deletions(-)
drivers/w1/w1_netlink.c +85 -17
index cae556c..24ad6bb 100644
@@ -47,19 +47,97 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
 	cn_netlink_send(m, 0, GFP_KERNEL);
 }
 
-static int w1_process_command_master(struct w1_master *dev, struct cn_msg *msg,
-		struct w1_netlink_msg *hdr, struct w1_netlink_cmd *cmd)
+static void w1_send_slave(struct w1_master *dev, u64 rn)
 {
-	dev_dbg(&dev->dev, "%s: %s: cmd=%02x, len=%u.\n",
-		__func__, dev->name, cmd->cmd, cmd->len);
+	struct cn_msg *msg = dev->priv;
+	struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
+	struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
+	int avail;
+	
+	avail = dev->priv_size - cmd->len;
+
+	if (avail > 8) {
+		u64 *data = (void *)(cmd + 1) + cmd->len;
+
+		*data = rn;
+		cmd->len += 8;
+		hdr->len += 8;
+		msg->len += 8;
+		return;
+	}
+
+	msg->ack++;
+	cn_netlink_send(msg, 0, GFP_KERNEL);
+
+	msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
+	hdr->len = sizeof(struct w1_netlink_cmd);
+	cmd->len = 0;
+}
+
+static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg,
+		unsigned int avail)
+{
+	struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
+	struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
+	int search_type = (cmd->cmd == W1_CMD_ALARM_SEARCH)?W1_ALARM_SEARCH:W1_SEARCH;
+
+	dev->priv = msg;
+	dev->priv_size = avail;
+
+	w1_search_devices(dev, search_type, w1_send_slave);
 
-	if (cmd->cmd != W1_CMD_SEARCH && cmd->cmd != W1_CMD_ALARM_SEARCH)
-		return -EINVAL;
+	msg->ack = 0;
+	cn_netlink_send(msg, 0, GFP_KERNEL);
+
+	dev->priv = NULL;
+	dev->priv_size = 0;
 
-	w1_search_process(dev, (cmd->cmd == W1_CMD_ALARM_SEARCH)?W1_ALARM_SEARCH:W1_SEARCH);
 	return 0;
 }
 
+static int w1_process_command_master(struct w1_master *dev, struct cn_msg *req_msg,
+		struct w1_netlink_msg *req_hdr, struct w1_netlink_cmd *req_cmd)
+{
+	int err = -EINVAL;
+	struct cn_msg *msg;
+	struct w1_netlink_msg *hdr;
+	struct w1_netlink_cmd *cmd;
+
+	msg = kzalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!msg)
+		return -ENOMEM;
+
+	msg->id = req_msg->id;
+	msg->seq = req_msg->seq;
+	msg->ack = 0;
+	msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
+
+	hdr = (struct w1_netlink_msg *)(msg + 1);
+	cmd = (struct w1_netlink_cmd *)(hdr + 1);
+
+	hdr->type = W1_MASTER_CMD;
+	hdr->id = req_hdr->id;
+	hdr->len = sizeof(struct w1_netlink_cmd);
+
+	cmd->cmd = req_cmd->cmd;
+	cmd->len = 0;
+
+	switch (cmd->cmd) {
+		case W1_CMD_SEARCH:
+		case W1_CMD_ALARM_SEARCH:
+			err = w1_process_search_command(dev, msg,
+				PAGE_SIZE - msg->len - sizeof(struct cn_msg));
+			break;
+		default:
+			cmd->res = EINVAL;
+			cn_netlink_send(msg, 0, GFP_KERNEL);
+			break;
+	}
+
+	kfree(msg);
+	return err;
+}
+
 static int w1_send_read_reply(struct w1_slave *sl, struct cn_msg *msg,
 		struct w1_netlink_msg *hdr, struct w1_netlink_cmd *cmd)
 {
@@ -119,11 +197,6 @@ static int w1_process_command_slave(struct w1_slave *sl, struct cn_msg *msg,
 		case W1_CMD_WRITE:
 			w1_write_block(sl->master, cmd->data, cmd->len);
 			break;
-		case W1_CMD_SEARCH:
-		case W1_CMD_ALARM_SEARCH:
-			w1_search_process(sl->master,
-					(cmd->cmd == W1_CMD_ALARM_SEARCH)?W1_ALARM_SEARCH:W1_SEARCH);
-			break;
 		default:
 			err = -1;
 			break;
@@ -270,11 +343,6 @@ out_cont:
 		if (err == -ENODEV)
 			err = 0;
 	}
-#if 0
-	if (err) {
-		printk("%s: malformed message. Dropping.\n", __func__);
-	}
-#endif
 }
 
 int w1_init_netlink(void)
Signature · 1 line
1.5.2.5
#6 lore raw

[W1] W1 search/alarm search documentation.

---
 Documentation/w1/w1.netlink |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
Documentation/w1/w1.netlink +17 -1
index eae5c8b..c98ca30 100644
@@ -74,7 +74,23 @@ format:
 	Each message is at most 4k in size, so if number of master devices
 	exceeds this, it will be split into several messages, cn.seq will be
 	increased for each one.
-	
+
+W1 search and alarm search commands.
+request:
+[cn_msg]
+  [w1_netlink_msg type = W1_MASTER_CMD id is equal to the bus master id to use for searching]
+  [w1_netlink_cmd cmd = W1_CMD_SEARCH or W1_CMD_ALARM_SEARCH]
+
+reply:
+  [cn_msg, ack = 1 and increasing, 0 means the last message, seq is equal to the request seq]
+  [w1_netlink_msg type = W1_MASTER_CMD]
+  [w1_netlink_cmd cmd = W1_CMD_SEARCH or W1_CMD_ALARM_SEARCH
+	len is equal to number of IDs multiplied by 8]
+  [64bit-id0 ... 64bit-idN]
+Length in each header corresponds to the size of the data behind it, so
+w1_netlink_cmd->len = N * 8; where N is number of IDs in this message. Can be zero.
+w1_netlink_msg->len = sizeof(struct w1_netlink_cmd) + N * 8;
+cn_msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + N*8;
 
 Operation steps in w1 core when new command is received.
 =======================================================
Signature · 1 line
1.5.2.5
#7 lore raw

Re: [W1] Updated documentation.

In reply to Evgeniy Polyakov

Hi Evgeniy,

Documentation/w1/w1.netlink Protocol. · line 17

Quoted 11 lines · Evgeniy Polyakov
---
 Documentation/w1/w1.netlink |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)
Documentation/w1/w1.netlink +0 -0
index 3640c7c..eae5c8b 100644
@@ -17,25 +17,27 @@ Protocol.
 [struct cn_msg] - connector header. It's length field is equal to size of the attached data.

(not in this patch, but:) Its

Quoted 30 lines
Documentation/w1/w1.netlink +5 -3
 [struct w1_netlink_msg] - w1 netlink header.
 	__u8 type 	- message type.
+			W1_LIST_MASTERS - list current bus master list
 			W1_SLAVE_ADD/W1_SLAVE_REMOVE - slave add/remove events.
 			W1_MASTER_ADD/W1_MASTER_REMOVE - master add/remove events.
 			W1_MASTER_CMD - userspace command for bus master device (search/alarm search).
 			W1_SLAVE_CMD - userspace command for slave device (read/write/ search/alarm search
 					for bus master device where given slave device found).
 	__u8 res	- reserved
-	__u16 len	- size of attached to this header data.
+	__u16 len	- size of data attached to this header data.
 	union {
-		__u8 id;			 - slave unique device id
+		__u8 id[8];			 - slave unique device id
 		struct w1_mst {
 			__u32		id;	 - master's id.
 			__u32		res;	 - reserved
 		} mst;
 	} id;
 
-[strucrt w1_netlink_cmd] - command for gived master or slave device.
+[struct w1_netlink_cmd] - command for given master or slave device.
 	__u8 cmd	- command opcode.
 			W1_CMD_READ 	- read command.
 			W1_CMD_WRITE	- write command.
+			W1_CMD_TOUCH	- touch command (write and sample data back to userspace).
 			W1_CMD_SEARCH	- search command.
 			W1_CMD_ALARM_SEARCH - alarm search command.
 	__u8 res	- reserved

Documentation/w1/w1.netlink Protocol. · line 49

Quoted 5 lines
Documentation/w1/w1.netlink +1 -1
@@ -44,7 +46,7 @@ Protocol.
 	__u8 data[0]	- data for this command.
 
 
-Each connector message can include one or more w1_netlink_msg with zero of more attached w1_netlink_cmd messages.
+Each connector message can include one or more w1_netlink_msg with zero or more attached w1_netlink_cmd messages.

Please limit lines to a maximum of 80 characters. Around 72 would be Good. (here and elsewhere)

Documentation/w1/w1.netlink Protocol. · line 52

Quoted 2 lines
Documentation/w1/w1.netlink +0 -0
 For event messages there are no w1_netlink_cmd embedded structures, only connector header
 and w1_netlink_msg strucutre with "len" field being zero and filled type (one of event types)

structure

Documentation/w1/w1.netlink cn_msg.len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + cmd · line 69

Quoted 10 lines
Documentation/w1/w1.netlink +6 -0
@@ -59,11 +61,25 @@ cn_msg.len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + cmd
 w1_netlink_msg.len = sizeof(struct w1_netlink_cmd) + cmd->len;
 w1_netlink_cmd.len = cmd->len;
 
+Replies to W1_LIST_MASTERS should send a message back to the userspace
+which will contain list of all registered master ids in the following
+format:
+	
+	cn_msg (CN_W1_IDX.CN_W1_VAL as id, len is equal to sizeof(struct
+	w1_netlink_msg) plus number of masters multipled by 4)

multiplied

Quoted 18 lines
Documentation/w1/w1.netlink +9 -1
+	w1_netlink_msg (type: W1_LIST_MASTERS, len is equal to number of masters
+	multiplied by 4 (u32 size))
+	id0 ... idN
+	
+	Each message is at most 4k in size, so if number of master devices
+	exceeds this, it will be split into several messages, cn.seq will be
+	increased for each one.
+	
 
 Operation steps in w1 core when new command is received.
 =======================================================
 
-When new message (w1_netlink_msg) is received w1 core detects if it is master of slave request,
+When new message (w1_netlink_msg) is received w1 core detects if it is master or slave request,
 according to w1_netlink_msg.type field.
 Then master or slave device is searched for.
 When found, master device (requested or those one on where slave device is found) is locked.

Documentation/w1/w1.netlink Connector [1] specific documentation. · line 99

Quoted 2 lines
Documentation/w1/w1.netlink +0 -0
@@ -82,10 +98,10 @@ Connector [1] specific documentation.
 Each connector message includes two u32 fields as "address".
 w1 uses CN_W1_IDX and CN_W1_VAL defined in include/linux/connector.h header.

uses them for what?

Documentation/w1/w1.netlink Connector [1] specific documentation. · line 101

Quoted 3 lines
Documentation/w1/w1.netlink +1 -1
 Each message also includes sequence and acknowledge numbers.
-Sequence number for event messages is appropriate bus master sequence number increased with
+Sequence number for event messages is appropriate bus master sequence number increased with 

Line ends with space. Please check for that throughout the file.

Documentation/w1/w1.netlink Additional documantion, source code examples.

Quoted 8 lines
Documentation/w1/w1.netlink +1 -1
 each event message sent "through" this master.
 Sequence number for userspace requests is set by userspace application.
-Sequence number for reply is the same as was in request, and
+Sequence number for reply is the same as was in request, and 
 acknowledge number is set to seq+1.
 
 
@@ -93,6 +109,6 @@ Additional documantion, source code examples.

documentation

Documentation/w1/w1.netlink Additional documantion, source code examples. · line 114

Quoted 8 lines
Documentation/w1/w1.netlink +2 -2
 ============================================
 
 1. Documentation/connector
-2. http://tservice.net.ru/~s0mbre/archive/w1
-This archive includes userspace application w1d.c which
+2. http://www.ioremap.net/archive/w1
+This archive includes userspace application w1d.c which 
 uses read/write/search commands for all master/slave devices found on the bus.

I'll plan to review the entire doc file.

Thanks,
~Randy

#8 lore raw

Re: [W1] Updated documentation.

Hi Randy.

Quoted 6 lines · Randy Dunlap

Documentation/w1/w1.netlink Protocol. · line 17

Quoted 4 lines
Documentation/w1/w1.netlink +0 -0
@@ -17,25 +17,27 @@ Protocol.
 [struct cn_msg] - connector header. It's length field is equal to size of the attached data.

(not in this patch, but:) Its

Yup :)

Quoted 5 lines

Documentation/w1/w1.netlink Protocol. · line 49

Quoted 2 lines
Documentation/w1/w1.netlink +1 -1
-Each connector message can include one or more w1_netlink_msg with zero of more attached w1_netlink_cmd messages.
+Each connector message can include one or more w1_netlink_msg with zero or more attached w1_netlink_cmd messages.

Please limit lines to a maximum of 80 characters. Around 72 would be Good. (here and elsewhere)

Will change.

Quoted 9 lines

Documentation/w1/w1.netlink Protocol. · line 52

Quoted 2 lines
Documentation/w1/w1.netlink +0 -0
 For event messages there are no w1_netlink_cmd embedded structures, only connector header
 and w1_netlink_msg strucutre with "len" field being zero and filled type (one of event types)

structure

Documentation/w1/w1.netlink cn_msg.len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + cmd · line 69

Quoted 2 lines
Documentation/w1/w1.netlink +2 -0
+	cn_msg (CN_W1_IDX.CN_W1_VAL as id, len is equal to sizeof(struct
+	w1_netlink_msg) plus number of masters multipled by 4)

multiplied

Changed.

Quoted 5 lines

Documentation/w1/w1.netlink Connector [1] specific documentation. · line 99

Quoted 3 lines
Documentation/w1/w1.netlink +0 -0
@@ -82,10 +98,10 @@ Connector [1] specific documentation.
 Each connector message includes two u32 fields as "address".
 w1 uses CN_W1_IDX and CN_W1_VAL defined in include/linux/connector.h header.

uses them for what?

They define destination address in connector subsystem.

Quoted 5 lines

Documentation/w1/w1.netlink Connector [1] specific documentation. · line 101

Quoted 3 lines
Documentation/w1/w1.netlink +1 -1
 Each message also includes sequence and acknowledge numbers.
-Sequence number for event messages is appropriate bus master sequence number increased with
+Sequence number for event messages is appropriate bus master sequence number increased with 

Line ends with space. Please check for that throughout the file.

Ok.

Quoted 3 lines

Documentation/w1/w1.netlink Additional documantion, source code examples.

Quoted 1 line
Documentation/w1/w1.netlink +0 -0
@@ -93,6 +109,6 @@ Additional documantion, source code examples.

documentation

Changed

Quoted 1 line

I'll plan to review the entire doc file.

Great, thank you!
I will roll out updated version today with this changes and fixed patch mentioned by Frederik.

Signature · 1 line
	Evgeniy Polyakov
#9 lore raw

Re: [W1] Added touch block command.

In reply to Evgeniy Polyakov

drivers/w1/w1_netlink.c static int w1_process_command_root(struct cn_msg *msg, struct w1_netlink_msg *mc · line 169

Quoted 2 lines · Evgeniy Polyakov
drivers/w1/w1_netlink.c +1 -1
-			cn->ack++
+			cn->ack++;

Which we find here, sorry for the noise :-)

#10 lore raw

Re: [W1] Added touch block command.

Quoted 4 lines · Frederik Deweerdt

drivers/w1/w1_netlink.c static int w1_process_command_root(struct cn_msg *msg, struct w1_netlink_msg *mc · line 169

Quoted 2 lines · Evgeniy Polyakov
drivers/w1/w1_netlink.c +1 -1
-			cn->ack++
+			cn->ack++;

Which we find here, sorry for the noise :-)

I know, It is a fix from the previous patch.
I just sent a patch series how it was committed, and yes, it contains this error, I could resubmit with hand-edited patches if needed.

Signature · 1 line
	Evgeniy Polyakov
#11 lore raw

Re: [W1] Added list masters w1 command.

In reply to Evgeniy Polyakov

Hi Evgeniy,

drivers/w1/w1_netlink.c static int w1_process_command_slave(struct w1_slave *sl, struct cn_msg *msg, · line 165

Quoted 5 lines · Evgeniy Polyakov
drivers/w1/w1_netlink.c +5 -0
+	mutex_lock(&w1_mlock);
+	list_for_each_entry(m, &w1_masters, w1_master_entry) {
+		if (cn->len + sizeof(*id) > PAGE_SIZE - sizeof(struct cn_msg)) {
+			cn_netlink_send(cn, 0, GFP_KERNEL);
+			cn->ack++
			^^^^^^^^^^

';' is missing here

Regards,
Frederik