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/
Signed-off-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Evgeniy Polyakov <[email protected]>
---
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(-)
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 97304bd..d8a9709 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -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);
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 0d15b0e..3d781f8 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -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
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index a3b2630..cae556c 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -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)) {
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 21913df..99dd21b 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -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
{
--
1.5.2.5
Signed-off-by: Evgeniy Polyakov <[email protected]>
---
drivers/w1/w1_netlink.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++
drivers/w1/w1_netlink.h | 1 +
2 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index 65c5ebd..a3b2630 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -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) {
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 56122b9..21913df 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -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
--
1.5.2.5
Signed-off-by: Evgeniy Polyakov <[email protected]>
---
Documentation/w1/w1.netlink | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/Documentation/w1/w1.netlink b/Documentation/w1/w1.netlink
index 3640c7c..eae5c8b 100644
--- a/Documentation/w1/w1.netlink
+++ b/Documentation/w1/w1.netlink
@@ -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.
--
1.5.2.5
Signed-off-by: Evgeniy Polyakov <[email protected]>
---
Documentation/w1/w1.netlink | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/Documentation/w1/w1.netlink b/Documentation/w1/w1.netlink
index eae5c8b..c98ca30 100644
--- a/Documentation/w1/w1.netlink
+++ b/Documentation/w1/w1.netlink
@@ -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.
=======================================================
--
1.5.2.5
Signed-off-by: Evgeniy Polyakov <[email protected]>
---
drivers/w1/w1_netlink.c | 102 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 85 insertions(+), 17 deletions(-)
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index cae556c..24ad6bb 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -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)
--
1.5.2.5
Hi Evgeniy,
On Thu, Dec 04, 2008 at 05:50:06PM +0300, Evgeniy Polyakov wrote:
> + 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
On Thu, Dec 04, 2008 at 05:50:07PM +0300, Evgeniy Polyakov wrote:
> - cn->ack++
> + cn->ack++;
Which we find here, sorry for the noise :-)
On Thu, Dec 04, 2008 at 04:42:31PM +0100, Frederik Deweerdt ([email protected]) wrote:
> On Thu, Dec 04, 2008 at 05:50:07PM +0300, Evgeniy Polyakov wrote:
> > - 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.
--
Evgeniy Polyakov
Hi Evgeniy,
Evgeniy Polyakov wrote:
> Signed-off-by: Evgeniy Polyakov <[email protected]>
> ---
> Documentation/w1/w1.netlink | 34 +++++++++++++++++++++++++---------
> 1 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/Documentation/w1/w1.netlink b/Documentation/w1/w1.netlink
> index 3640c7c..eae5c8b 100644
> --- a/Documentation/w1/w1.netlink
> +++ b/Documentation/w1/w1.netlink
> @@ -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
> [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.
Please limit lines to a maximum of 80 characters. Around 72 would be Good.
(here and elsewhere)
> 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
> @@ -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
> + 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.
uses them for what?
> 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.
> 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
> ============================================
>
> 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
Hi Randy.
On Thu, Dec 04, 2008 at 03:53:25PM -0800, Randy Dunlap ([email protected]) wrote:
> > --- a/Documentation/w1/w1.netlink
> > +++ b/Documentation/w1/w1.netlink
> > @@ -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 :)
> > -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.
> > 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
> > + 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.
> > @@ -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.
> > 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.
> > @@ -93,6 +109,6 @@ Additional documantion, source code examples.
>
> documentation
Changed
> 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.
--
Evgeniy Polyakov