Skip to content

Commit 8a0427d

Browse files
dfriesgregkh
authored andcommitted
w1: optional bundling of netlink kernel replies
Applications can submit a set of commands in one packet to the kernel, and in some cases it is required such as reading the temperature sensor results. This adds an option W1_CN_BUNDLE to the flags of cn_msg to request the kernel to reply in one packet for efficiency. The cn_msg flags now check for unknown flag values and return an error if one is seen. See "Proper handling of unknown flags in system calls" http://lwn.net/Articles/588444/ This corrects the ack values returned as per the protocol standard, namely the original ack for status messages and seq + 1 for all others such as the data returned from a read. Some of the common variable names have been standardized as follows. struct cn_msg *cn struct w1_netlink_msg *msg struct w1_netlink_cmd *cmd struct w1_master *dev When an argument and a function scope variable would collide, add req_ to the argument. Signed-off-by: David Fries <David@Fries.net> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 34470e0 commit 8a0427d

6 files changed

Lines changed: 447 additions & 263 deletions

File tree

‎Documentation/connector/connector.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ acknowledge number MUST be the same + 1.
118118
If we receive a message and its sequence number is not equal to one we
119119
are expecting, then it is a new message. If we receive a message and
120120
its sequence number is the same as one we are expecting, but its
121-
acknowledge is not equal to the acknowledge number in the original
121+
acknowledge is not equal to the sequence number in the original
122122
message + 1, then it is a new message.
123123

124124
Obviously, the protocol header contains the above id.

‎Documentation/w1/w1.generic‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ driver - (standard) symlink to the w1 driver
8282
w1_master_add - Manually register a slave device
8383
w1_master_attempts - the number of times a search was attempted
8484
w1_master_max_slave_count
85-
- the maximum slaves that may be attached to a master
85+
- maximum number of slaves to search for at a time
8686
w1_master_name - the name of the device (w1_bus_masterX)
8787
w1_master_pullup - 5V strong pullup 0 enabled, 1 disabled
8888
w1_master_remove - Manually remove a slave device

‎Documentation/w1/w1.netlink‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Protocol.
3030
W1_SLAVE_CMD
3131
userspace command for slave device
3232
(read/write/touch)
33-
__u8 res - reserved
33+
__u8 status - error indication from kernel
3434
__u16 len - size of data attached to this header data
3535
union {
3636
__u8 id[8]; - slave unique device id
@@ -44,10 +44,14 @@ Protocol.
4444
__u8 cmd - command opcode.
4545
W1_CMD_READ - read command
4646
W1_CMD_WRITE - write command
47-
W1_CMD_TOUCH - touch command
48-
(write and sample data back to userspace)
4947
W1_CMD_SEARCH - search command
5048
W1_CMD_ALARM_SEARCH - alarm search command
49+
W1_CMD_TOUCH - touch command
50+
(write and sample data back to userspace)
51+
W1_CMD_RESET - send bus reset
52+
W1_CMD_SLAVE_ADD - add slave to kernel list
53+
W1_CMD_SLAVE_REMOVE - remove slave from kernel list
54+
W1_CMD_LIST_SLAVES - get slaves list from kernel
5155
__u8 res - reserved
5256
__u16 len - length of data for this command
5357
For read command data must be allocated like for write command
@@ -87,8 +91,7 @@ format:
8791
id0 ... idN
8892

8993
Each message is at most 4k in size, so if number of master devices
90-
exceeds this, it will be split into several messages,
91-
cn.seq will be increased for each one.
94+
exceeds this, it will be split into several messages.
9295

9396
W1 search and alarm search commands.
9497
request:

‎drivers/w1/w1.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ enum w1_master_flags {
203203
* @search_id: allows continuing a search
204204
* @refcnt: reference count
205205
* @priv: private data storage
206-
* @priv_size: size allocated
207206
* @enable_pullup: allows a strong pullup
208207
* @pullup_duration: time for the next strong pullup
209208
* @flags: one of w1_master_flags
@@ -214,7 +213,6 @@ enum w1_master_flags {
214213
* @dev: sysfs device
215214
* @bus_master: io operations available
216215
* @seq: sequence number used for netlink broadcasts
217-
* @portid: destination for the current netlink command
218216
*/
219217
struct w1_master
220218
{
@@ -241,7 +239,6 @@ struct w1_master
241239
atomic_t refcnt;
242240

243241
void *priv;
244-
int priv_size;
245242

246243
/** 5V strong pullup enabled flag, 1 enabled, zero disabled. */
247244
int enable_pullup;
@@ -260,11 +257,6 @@ struct w1_master
260257
struct w1_bus_master *bus_master;
261258

262259
u32 seq;
263-
/* port id to send netlink responses to. The value is temporarily
264-
* stored here while processing a message, set after locking the
265-
* mutex, zero before unlocking the mutex.
266-
*/
267-
u32 portid;
268260
};
269261

270262
/**

0 commit comments

Comments
 (0)