diff options
-rw-r--r-- | Documentation/DocBook/Makefile | 2 | ||||
-rw-r--r-- | Documentation/DocBook/w1.tmpl | 101 | ||||
-rw-r--r-- | Documentation/w1/w1.netlink | 8 | ||||
-rw-r--r-- | drivers/w1/w1.c | 30 | ||||
-rw-r--r-- | drivers/w1/w1.h | 136 | ||||
-rw-r--r-- | drivers/w1/w1_family.c | 8 | ||||
-rw-r--r-- | drivers/w1/w1_family.h | 13 | ||||
-rw-r--r-- | drivers/w1/w1_int.c | 8 | ||||
-rw-r--r-- | drivers/w1/w1_io.c | 102 | ||||
-rw-r--r-- | drivers/w1/w1_netlink.h | 6 |
10 files changed, 315 insertions, 99 deletions
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 0f9c6ff41aac..8d96ebf524e9 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile | |||
@@ -14,7 +14,7 @@ DOCBOOKS := z8530book.xml device-drivers.xml \ | |||
14 | genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ | 14 | genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ |
15 | 80211.xml debugobjects.xml sh.xml regulator.xml \ | 15 | 80211.xml debugobjects.xml sh.xml regulator.xml \ |
16 | alsa-driver-api.xml writing-an-alsa-driver.xml \ | 16 | alsa-driver-api.xml writing-an-alsa-driver.xml \ |
17 | tracepoint.xml drm.xml media_api.xml | 17 | tracepoint.xml drm.xml media_api.xml w1.xml |
18 | 18 | ||
19 | include $(srctree)/Documentation/DocBook/media/Makefile | 19 | include $(srctree)/Documentation/DocBook/media/Makefile |
20 | 20 | ||
diff --git a/Documentation/DocBook/w1.tmpl b/Documentation/DocBook/w1.tmpl new file mode 100644 index 000000000000..b0228d4c81bb --- /dev/null +++ b/Documentation/DocBook/w1.tmpl | |||
@@ -0,0 +1,101 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" | ||
3 | "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []> | ||
4 | |||
5 | <book id="w1id"> | ||
6 | <bookinfo> | ||
7 | <title>W1: Dallas' 1-wire bus</title> | ||
8 | |||
9 | <authorgroup> | ||
10 | <author> | ||
11 | <firstname>David</firstname> | ||
12 | <surname>Fries</surname> | ||
13 | <affiliation> | ||
14 | <address> | ||
15 | <email>David@Fries.net</email> | ||
16 | </address> | ||
17 | </affiliation> | ||
18 | </author> | ||
19 | |||
20 | </authorgroup> | ||
21 | |||
22 | <copyright> | ||
23 | <year>2013</year> | ||
24 | <!-- | ||
25 | <holder></holder> | ||
26 | --> | ||
27 | </copyright> | ||
28 | |||
29 | <legalnotice> | ||
30 | <para> | ||
31 | This documentation is free software; you can redistribute | ||
32 | it and/or modify it under the terms of the GNU General Public | ||
33 | License version 2. | ||
34 | </para> | ||
35 | |||
36 | <para> | ||
37 | This program is distributed in the hope that it will be | ||
38 | useful, but WITHOUT ANY WARRANTY; without even the implied | ||
39 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
40 | For more details see the file COPYING in the source | ||
41 | distribution of Linux. | ||
42 | </para> | ||
43 | </legalnotice> | ||
44 | </bookinfo> | ||
45 | |||
46 | <toc></toc> | ||
47 | |||
48 | <chapter id="w1_internal"> | ||
49 | <title>W1 API internal to the kernel</title> | ||
50 | |||
51 | <sect1 id="w1_internal_api"> | ||
52 | <title>W1 API internal to the kernel</title> | ||
53 | <sect2 id="w1.h"> | ||
54 | <title>drivers/w1/w1.h</title> | ||
55 | <para>W1 core functions.</para> | ||
56 | !Idrivers/w1/w1.h | ||
57 | </sect2> | ||
58 | |||
59 | <sect2 id="w1.c"> | ||
60 | <title>drivers/w1/w1.c</title> | ||
61 | <para>W1 core functions.</para> | ||
62 | !Idrivers/w1/w1.c | ||
63 | </sect2> | ||
64 | |||
65 | <sect2 id="w1_family.h"> | ||
66 | <title>drivers/w1/w1_family.h</title> | ||
67 | <para>Allows registering device family operations.</para> | ||
68 | !Idrivers/w1/w1_family.h | ||
69 | </sect2> | ||
70 | |||
71 | <sect2 id="w1_family.c"> | ||
72 | <title>drivers/w1/w1_family.c</title> | ||
73 | <para>Allows registering device family operations.</para> | ||
74 | !Edrivers/w1/w1_family.c | ||
75 | </sect2> | ||
76 | |||
77 | <sect2 id="w1_int.c"> | ||
78 | <title>drivers/w1/w1_int.c</title> | ||
79 | <para>W1 internal initialization for master devices.</para> | ||
80 | !Edrivers/w1/w1_int.c | ||
81 | </sect2> | ||
82 | |||
83 | <sect2 id="w1_netlink.h"> | ||
84 | <title>drivers/w1/w1_netlink.h</title> | ||
85 | <para>W1 external netlink API structures and commands.</para> | ||
86 | !Idrivers/w1/w1_netlink.h | ||
87 | </sect2> | ||
88 | |||
89 | <sect2 id="w1_io.c"> | ||
90 | <title>drivers/w1/w1_io.c</title> | ||
91 | <para>W1 input/output.</para> | ||
92 | !Edrivers/w1/w1_io.c | ||
93 | !Idrivers/w1/w1_io.c | ||
94 | </sect2> | ||
95 | |||
96 | </sect1> | ||
97 | |||
98 | |||
99 | </chapter> | ||
100 | |||
101 | </book> | ||
diff --git a/Documentation/w1/w1.netlink b/Documentation/w1/w1.netlink index f59a31965d50..927a52cc0519 100644 --- a/Documentation/w1/w1.netlink +++ b/Documentation/w1/w1.netlink | |||
@@ -5,8 +5,8 @@ Message types. | |||
5 | ============= | 5 | ============= |
6 | 6 | ||
7 | There are three types of messages between w1 core and userspace: | 7 | There are three types of messages between w1 core and userspace: |
8 | 1. Events. They are generated each time new master or slave device | 8 | 1. Events. They are generated each time a new master or slave device |
9 | found either due to automatic or requested search. | 9 | is found either due to automatic or requested search. |
10 | 2. Userspace commands. | 10 | 2. Userspace commands. |
11 | 3. Replies to userspace commands. | 11 | 3. Replies to userspace commands. |
12 | 12 | ||
@@ -131,7 +131,7 @@ of the w1_netlink_cmd structure and cn_msg.len will be equal to the sum | |||
131 | of the sizeof(struct w1_netlink_msg) and sizeof(struct w1_netlink_cmd). | 131 | of the sizeof(struct w1_netlink_msg) and sizeof(struct w1_netlink_cmd). |
132 | If reply is generated for master or root command (which do not have | 132 | If reply is generated for master or root command (which do not have |
133 | w1_netlink_cmd attached), reply will contain only cn_msg and w1_netlink_msg | 133 | w1_netlink_cmd attached), reply will contain only cn_msg and w1_netlink_msg |
134 | structires. | 134 | structures. |
135 | 135 | ||
136 | w1_netlink_msg.status field will carry positive error value | 136 | w1_netlink_msg.status field will carry positive error value |
137 | (EINVAL for example) or zero in case of success. | 137 | (EINVAL for example) or zero in case of success. |
@@ -160,7 +160,7 @@ procedure is started to select given device. | |||
160 | Then all requested in w1_netlink_msg operations are performed one by one. | 160 | Then all requested in w1_netlink_msg operations are performed one by one. |
161 | If command requires reply (like read command) it is sent on command completion. | 161 | If command requires reply (like read command) it is sent on command completion. |
162 | 162 | ||
163 | When all commands (w1_netlink_cmd) are processed muster device is unlocked | 163 | When all commands (w1_netlink_cmd) are processed master device is unlocked |
164 | and next w1_netlink_msg header processing started. | 164 | and next w1_netlink_msg header processing started. |
165 | 165 | ||
166 | 166 | ||
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 53846c7f24ff..9eb816b2ea5e 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -50,8 +50,21 @@ int w1_max_slave_count = 64; | |||
50 | int w1_max_slave_ttl = 10; | 50 | int w1_max_slave_ttl = 10; |
51 | 51 | ||
52 | module_param_named(timeout, w1_timeout, int, 0); | 52 | module_param_named(timeout, w1_timeout, int, 0); |
53 | MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches"); | ||
54 | /* A search stops when w1_max_slave_count devices have been found in that | ||
55 | * search. The next search will start over and detect the same set of devices | ||
56 | * on a static 1-wire bus. Memory is not allocated based on this number, just | ||
57 | * on the number of devices known to the kernel. Having a high number does not | ||
58 | * consume additional resources. As a special case, if there is only one | ||
59 | * device on the network and w1_max_slave_count is set to 1, the device id can | ||
60 | * be read directly skipping the normal slower search process. | ||
61 | */ | ||
53 | module_param_named(max_slave_count, w1_max_slave_count, int, 0); | 62 | module_param_named(max_slave_count, w1_max_slave_count, int, 0); |
63 | MODULE_PARM_DESC(max_slave_count, | ||
64 | "maximum number of slaves detected in a search"); | ||
54 | module_param_named(slave_ttl, w1_max_slave_ttl, int, 0); | 65 | module_param_named(slave_ttl, w1_max_slave_ttl, int, 0); |
66 | MODULE_PARM_DESC(slave_ttl, | ||
67 | "Number of searches not seeing a slave before it will be removed"); | ||
55 | 68 | ||
56 | DEFINE_MUTEX(w1_mlock); | 69 | DEFINE_MUTEX(w1_mlock); |
57 | LIST_HEAD(w1_masters); | 70 | LIST_HEAD(w1_masters); |
@@ -920,7 +933,12 @@ void w1_slave_found(struct w1_master *dev, u64 rn) | |||
920 | } | 933 | } |
921 | 934 | ||
922 | /** | 935 | /** |
923 | * Performs a ROM Search & registers any devices found. | 936 | * w1_search() - Performs a ROM Search & registers any devices found. |
937 | * @dev: The master device to search | ||
938 | * @search_type: W1_SEARCH to search all devices, or W1_ALARM_SEARCH | ||
939 | * to return only devices in the alarmed state | ||
940 | * @cb: Function to call when a device is found | ||
941 | * | ||
924 | * The 1-wire search is a simple binary tree search. | 942 | * The 1-wire search is a simple binary tree search. |
925 | * For each bit of the address, we read two bits and write one bit. | 943 | * For each bit of the address, we read two bits and write one bit. |
926 | * The bit written will put to sleep all devies that don't match that bit. | 944 | * The bit written will put to sleep all devies that don't match that bit. |
@@ -930,8 +948,6 @@ void w1_slave_found(struct w1_master *dev, u64 rn) | |||
930 | * | 948 | * |
931 | * See "Application note 187 1-wire search algorithm" at www.maxim-ic.com | 949 | * See "Application note 187 1-wire search algorithm" at www.maxim-ic.com |
932 | * | 950 | * |
933 | * @dev The master device to search | ||
934 | * @cb Function to call when a device is found | ||
935 | */ | 951 | */ |
936 | void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb) | 952 | void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb) |
937 | { | 953 | { |
@@ -990,7 +1006,7 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb | |||
990 | else | 1006 | else |
991 | search_bit = ((last_rn >> i) & 0x1); | 1007 | search_bit = ((last_rn >> i) & 0x1); |
992 | 1008 | ||
993 | /** Read two bits and write one bit */ | 1009 | /* Read two bits and write one bit */ |
994 | triplet_ret = w1_triplet(dev, search_bit); | 1010 | triplet_ret = w1_triplet(dev, search_bit); |
995 | 1011 | ||
996 | /* quit if no device responded */ | 1012 | /* quit if no device responded */ |
@@ -1074,6 +1090,12 @@ static void w1_search_process(struct w1_master *dev, u8 search_type) | |||
1074 | w1_search_process_cb(dev, search_type, w1_slave_found); | 1090 | w1_search_process_cb(dev, search_type, w1_slave_found); |
1075 | } | 1091 | } |
1076 | 1092 | ||
1093 | /** | ||
1094 | * w1_process_callbacks() - execute each dev->async_list callback entry | ||
1095 | * @dev: w1_master device | ||
1096 | * | ||
1097 | * Return: 1 if there were commands to executed 0 otherwise | ||
1098 | */ | ||
1077 | int w1_process_callbacks(struct w1_master *dev) | 1099 | int w1_process_callbacks(struct w1_master *dev) |
1078 | { | 1100 | { |
1079 | int ret = 0; | 1101 | int ret = 0; |
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 0eb50502f63f..734dab7fc687 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h | |||
@@ -22,6 +22,13 @@ | |||
22 | #ifndef __W1_H | 22 | #ifndef __W1_H |
23 | #define __W1_H | 23 | #define __W1_H |
24 | 24 | ||
25 | /** | ||
26 | * struct w1_reg_num - broken out slave device id | ||
27 | * | ||
28 | * @family: identifies the type of device | ||
29 | * @id: along with family is the unique device id | ||
30 | * @crc: checksum of the other bytes | ||
31 | */ | ||
25 | struct w1_reg_num | 32 | struct w1_reg_num |
26 | { | 33 | { |
27 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 34 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
@@ -60,6 +67,22 @@ struct w1_reg_num | |||
60 | #define W1_SLAVE_ACTIVE 0 | 67 | #define W1_SLAVE_ACTIVE 0 |
61 | #define W1_SLAVE_DETACH 1 | 68 | #define W1_SLAVE_DETACH 1 |
62 | 69 | ||
70 | /** | ||
71 | * struct w1_slave - holds a single slave device on the bus | ||
72 | * | ||
73 | * @owner: Points to the one wire "wire" kernel module. | ||
74 | * @name: Device id is ascii. | ||
75 | * @w1_slave_entry: data for the linked list | ||
76 | * @reg_num: the slave id in binary | ||
77 | * @refcnt: reference count, delete when 0 | ||
78 | * @flags: bit flags for W1_SLAVE_ACTIVE W1_SLAVE_DETACH | ||
79 | * @ttl: decrement per search this slave isn't found, deatch at 0 | ||
80 | * @master: bus which this slave is on | ||
81 | * @family: module for device family type | ||
82 | * @family_data: pointer for use by the family module | ||
83 | * @dev: kernel device identifier | ||
84 | * | ||
85 | */ | ||
63 | struct w1_slave | 86 | struct w1_slave |
64 | { | 87 | { |
65 | struct module *owner; | 88 | struct module *owner; |
@@ -80,77 +103,74 @@ typedef void (*w1_slave_found_callback)(struct w1_master *, u64); | |||
80 | 103 | ||
81 | 104 | ||
82 | /** | 105 | /** |
106 | * struct w1_bus_master - operations available on a bus master | ||
107 | * | ||
108 | * @data: the first parameter in all the functions below | ||
109 | * | ||
110 | * @read_bit: Sample the line level @return the level read (0 or 1) | ||
111 | * | ||
112 | * @write_bit: Sets the line level | ||
113 | * | ||
114 | * @touch_bit: the lowest-level function for devices that really support the | ||
115 | * 1-wire protocol. | ||
116 | * touch_bit(0) = write-0 cycle | ||
117 | * touch_bit(1) = write-1 / read cycle | ||
118 | * @return the bit read (0 or 1) | ||
119 | * | ||
120 | * @read_byte: Reads a bytes. Same as 8 touch_bit(1) calls. | ||
121 | * @return the byte read | ||
122 | * | ||
123 | * @write_byte: Writes a byte. Same as 8 touch_bit(x) calls. | ||
124 | * | ||
125 | * @read_block: Same as a series of read_byte() calls | ||
126 | * @return the number of bytes read | ||
127 | * | ||
128 | * @write_block: Same as a series of write_byte() calls | ||
129 | * | ||
130 | * @triplet: Combines two reads and a smart write for ROM searches | ||
131 | * @return bit0=Id bit1=comp_id bit2=dir_taken | ||
132 | * | ||
133 | * @reset_bus: long write-0 with a read for the presence pulse detection | ||
134 | * @return -1=Error, 0=Device present, 1=No device present | ||
135 | * | ||
136 | * @set_pullup: Put out a strong pull-up pulse of the specified duration. | ||
137 | * @return -1=Error, 0=completed | ||
138 | * | ||
139 | * @search: Really nice hardware can handles the different types of ROM search | ||
140 | * w1_master* is passed to the slave found callback. | ||
141 | * u8 is search_type, W1_SEARCH or W1_ALARM_SEARCH | ||
142 | * | ||
83 | * Note: read_bit and write_bit are very low level functions and should only | 143 | * Note: read_bit and write_bit are very low level functions and should only |
84 | * be used with hardware that doesn't really support 1-wire operations, | 144 | * be used with hardware that doesn't really support 1-wire operations, |
85 | * like a parallel/serial port. | 145 | * like a parallel/serial port. |
86 | * Either define read_bit and write_bit OR define, at minimum, touch_bit and | 146 | * Either define read_bit and write_bit OR define, at minimum, touch_bit and |
87 | * reset_bus. | 147 | * reset_bus. |
148 | * | ||
88 | */ | 149 | */ |
89 | struct w1_bus_master | 150 | struct w1_bus_master |
90 | { | 151 | { |
91 | /** the first parameter in all the functions below */ | ||
92 | void *data; | 152 | void *data; |
93 | 153 | ||
94 | /** | ||
95 | * Sample the line level | ||
96 | * @return the level read (0 or 1) | ||
97 | */ | ||
98 | u8 (*read_bit)(void *); | 154 | u8 (*read_bit)(void *); |
99 | 155 | ||
100 | /** Sets the line level */ | ||
101 | void (*write_bit)(void *, u8); | 156 | void (*write_bit)(void *, u8); |
102 | 157 | ||
103 | /** | ||
104 | * touch_bit is the lowest-level function for devices that really | ||
105 | * support the 1-wire protocol. | ||
106 | * touch_bit(0) = write-0 cycle | ||
107 | * touch_bit(1) = write-1 / read cycle | ||
108 | * @return the bit read (0 or 1) | ||
109 | */ | ||
110 | u8 (*touch_bit)(void *, u8); | 158 | u8 (*touch_bit)(void *, u8); |
111 | 159 | ||
112 | /** | ||
113 | * Reads a bytes. Same as 8 touch_bit(1) calls. | ||
114 | * @return the byte read | ||
115 | */ | ||
116 | u8 (*read_byte)(void *); | 160 | u8 (*read_byte)(void *); |
117 | 161 | ||
118 | /** | ||
119 | * Writes a byte. Same as 8 touch_bit(x) calls. | ||
120 | */ | ||
121 | void (*write_byte)(void *, u8); | 162 | void (*write_byte)(void *, u8); |
122 | 163 | ||
123 | /** | ||
124 | * Same as a series of read_byte() calls | ||
125 | * @return the number of bytes read | ||
126 | */ | ||
127 | u8 (*read_block)(void *, u8 *, int); | 164 | u8 (*read_block)(void *, u8 *, int); |
128 | 165 | ||
129 | /** Same as a series of write_byte() calls */ | ||
130 | void (*write_block)(void *, const u8 *, int); | 166 | void (*write_block)(void *, const u8 *, int); |
131 | 167 | ||
132 | /** | ||
133 | * Combines two reads and a smart write for ROM searches | ||
134 | * @return bit0=Id bit1=comp_id bit2=dir_taken | ||
135 | */ | ||
136 | u8 (*triplet)(void *, u8); | 168 | u8 (*triplet)(void *, u8); |
137 | 169 | ||
138 | /** | ||
139 | * long write-0 with a read for the presence pulse detection | ||
140 | * @return -1=Error, 0=Device present, 1=No device present | ||
141 | */ | ||
142 | u8 (*reset_bus)(void *); | 170 | u8 (*reset_bus)(void *); |
143 | 171 | ||
144 | /** | ||
145 | * Put out a strong pull-up pulse of the specified duration. | ||
146 | * @return -1=Error, 0=completed | ||
147 | */ | ||
148 | u8 (*set_pullup)(void *, int); | 172 | u8 (*set_pullup)(void *, int); |
149 | 173 | ||
150 | /** Really nice hardware can handles the different types of ROM search | ||
151 | * w1_master* is passed to the slave found callback. | ||
152 | * u8 is search_type, W1_SEARCH or W1_ALARM_SEARCH | ||
153 | */ | ||
154 | void (*search)(void *, struct w1_master *, | 174 | void (*search)(void *, struct w1_master *, |
155 | u8, w1_slave_found_callback); | 175 | u8, w1_slave_found_callback); |
156 | }; | 176 | }; |
@@ -165,6 +185,37 @@ enum w1_master_flags { | |||
165 | W1_WARN_MAX_COUNT = 1, | 185 | W1_WARN_MAX_COUNT = 1, |
166 | }; | 186 | }; |
167 | 187 | ||
188 | /** | ||
189 | * struct w1_master - one per bus master | ||
190 | * @w1_master_entry: master linked list | ||
191 | * @owner: module owner | ||
192 | * @name: dynamically allocate bus name | ||
193 | * @list_mutex: protect slist and async_list | ||
194 | * @slist: linked list of slaves | ||
195 | * @async_list: linked list of netlink commands to execute | ||
196 | * @max_slave_count: maximum number of slaves to search for at a time | ||
197 | * @slave_count: current number of slaves known | ||
198 | * @attempts: number of searches ran | ||
199 | * @slave_ttl: number of searches before a slave is timed out | ||
200 | * @initialized: prevent init/removal race conditions | ||
201 | * @id: w1 bus number | ||
202 | * @search_count: number of automatic searches to run, -1 unlimited | ||
203 | * @search_id: allows continuing a search | ||
204 | * @refcnt: reference count | ||
205 | * @priv: private data storage | ||
206 | * @priv_size: size allocated | ||
207 | * @enable_pullup: allows a strong pullup | ||
208 | * @pullup_duration: time for the next strong pullup | ||
209 | * @flags: one of w1_master_flags | ||
210 | * @thread: thread for bus search and netlink commands | ||
211 | * @mutex: protect most of w1_master | ||
212 | * @bus_mutex: pretect concurrent bus access | ||
213 | * @driver: sysfs driver | ||
214 | * @dev: sysfs device | ||
215 | * @bus_master: io operations available | ||
216 | * @seq: sequence number used for netlink broadcasts | ||
217 | * @portid: destination for the current netlink command | ||
218 | */ | ||
168 | struct w1_master | 219 | struct w1_master |
169 | { | 220 | { |
170 | struct list_head w1_master_entry; | 221 | struct list_head w1_master_entry; |
@@ -173,7 +224,7 @@ struct w1_master | |||
173 | /* list_mutex protects just slist and async_list so slaves can be | 224 | /* list_mutex protects just slist and async_list so slaves can be |
174 | * searched for and async commands added while the master has | 225 | * searched for and async commands added while the master has |
175 | * w1_master.mutex locked and is operating on the bus. | 226 | * w1_master.mutex locked and is operating on the bus. |
176 | * lock order w1_mlock, w1_master.mutex, w1_master_list_mutex | 227 | * lock order w1_mlock, w1_master.mutex, w1_master.list_mutex |
177 | */ | 228 | */ |
178 | struct mutex list_mutex; | 229 | struct mutex list_mutex; |
179 | struct list_head slist; | 230 | struct list_head slist; |
@@ -290,7 +341,6 @@ extern int w1_max_slave_ttl; | |||
290 | extern struct list_head w1_masters; | 341 | extern struct list_head w1_masters; |
291 | extern struct mutex w1_mlock; | 342 | extern struct mutex w1_mlock; |
292 | 343 | ||
293 | /* returns 1 if there were commands to executed 0 otherwise */ | ||
294 | extern int w1_process_callbacks(struct w1_master *dev); | 344 | extern int w1_process_callbacks(struct w1_master *dev); |
295 | extern int w1_process(void *); | 345 | extern int w1_process(void *); |
296 | 346 | ||
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c index e9309778ee72..3bff6b37b472 100644 --- a/drivers/w1/w1_family.c +++ b/drivers/w1/w1_family.c | |||
@@ -31,6 +31,10 @@ | |||
31 | DEFINE_SPINLOCK(w1_flock); | 31 | DEFINE_SPINLOCK(w1_flock); |
32 | static LIST_HEAD(w1_families); | 32 | static LIST_HEAD(w1_families); |
33 | 33 | ||
34 | /** | ||
35 | * w1_register_family() - register a device family driver | ||
36 | * @newf: family to register | ||
37 | */ | ||
34 | int w1_register_family(struct w1_family *newf) | 38 | int w1_register_family(struct w1_family *newf) |
35 | { | 39 | { |
36 | struct list_head *ent, *n; | 40 | struct list_head *ent, *n; |
@@ -59,6 +63,10 @@ int w1_register_family(struct w1_family *newf) | |||
59 | return ret; | 63 | return ret; |
60 | } | 64 | } |
61 | 65 | ||
66 | /** | ||
67 | * w1_unregister_family() - unregister a device family driver | ||
68 | * @fent: family to unregister | ||
69 | */ | ||
62 | void w1_unregister_family(struct w1_family *fent) | 70 | void w1_unregister_family(struct w1_family *fent) |
63 | { | 71 | { |
64 | struct list_head *ent, *n; | 72 | struct list_head *ent, *n; |
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h index 4ad0e81b6404..26ca1343055b 100644 --- a/drivers/w1/w1_family.h +++ b/drivers/w1/w1_family.h | |||
@@ -48,6 +48,12 @@ | |||
48 | 48 | ||
49 | struct w1_slave; | 49 | struct w1_slave; |
50 | 50 | ||
51 | /** | ||
52 | * struct w1_family_ops - operations for a family type | ||
53 | * @add_slave: add_slave | ||
54 | * @remove_slave: remove_slave | ||
55 | * @groups: sysfs group | ||
56 | */ | ||
51 | struct w1_family_ops | 57 | struct w1_family_ops |
52 | { | 58 | { |
53 | int (* add_slave)(struct w1_slave *); | 59 | int (* add_slave)(struct w1_slave *); |
@@ -55,6 +61,13 @@ struct w1_family_ops | |||
55 | const struct attribute_group **groups; | 61 | const struct attribute_group **groups; |
56 | }; | 62 | }; |
57 | 63 | ||
64 | /** | ||
65 | * struct w1_family - reference counted family structure. | ||
66 | * @family_entry: family linked list | ||
67 | * @fid: 8 bit family identifier | ||
68 | * @fops: operations for this family | ||
69 | * @refcnt: reference counter | ||
70 | */ | ||
58 | struct w1_family | 71 | struct w1_family |
59 | { | 72 | { |
60 | struct list_head family_entry; | 73 | struct list_head family_entry; |
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index 66b2caae48f3..9b084db739c7 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c | |||
@@ -105,6 +105,10 @@ static void w1_free_dev(struct w1_master *dev) | |||
105 | device_unregister(&dev->dev); | 105 | device_unregister(&dev->dev); |
106 | } | 106 | } |
107 | 107 | ||
108 | /** | ||
109 | * w1_add_master_device() - registers a new master device | ||
110 | * @master: master bus device to register | ||
111 | */ | ||
108 | int w1_add_master_device(struct w1_bus_master *master) | 112 | int w1_add_master_device(struct w1_bus_master *master) |
109 | { | 113 | { |
110 | struct w1_master *dev, *entry; | 114 | struct w1_master *dev, *entry; |
@@ -227,6 +231,10 @@ void __w1_remove_master_device(struct w1_master *dev) | |||
227 | w1_free_dev(dev); | 231 | w1_free_dev(dev); |
228 | } | 232 | } |
229 | 233 | ||
234 | /** | ||
235 | * w1_remove_master_device() - unregister a master device | ||
236 | * @bm: master bus device to remove | ||
237 | */ | ||
230 | void w1_remove_master_device(struct w1_bus_master *bm) | 238 | void w1_remove_master_device(struct w1_bus_master *bm) |
231 | { | 239 | { |
232 | struct w1_master *dev, *found = NULL; | 240 | struct w1_master *dev, *found = NULL; |
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c index e10acc237733..282092421cc9 100644 --- a/drivers/w1/w1_io.c +++ b/drivers/w1/w1_io.c | |||
@@ -62,7 +62,9 @@ static void w1_write_bit(struct w1_master *dev, int bit); | |||
62 | static u8 w1_read_bit(struct w1_master *dev); | 62 | static u8 w1_read_bit(struct w1_master *dev); |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Generates a write-0 or write-1 cycle and samples the level. | 65 | * w1_touch_bit() - Generates a write-0 or write-1 cycle and samples the level. |
66 | * @dev: the master device | ||
67 | * @bit: 0 - write a 0, 1 - write a 0 read the level | ||
66 | */ | 68 | */ |
67 | static u8 w1_touch_bit(struct w1_master *dev, int bit) | 69 | static u8 w1_touch_bit(struct w1_master *dev, int bit) |
68 | { | 70 | { |
@@ -77,7 +79,10 @@ static u8 w1_touch_bit(struct w1_master *dev, int bit) | |||
77 | } | 79 | } |
78 | 80 | ||
79 | /** | 81 | /** |
80 | * Generates a write-0 or write-1 cycle. | 82 | * w1_write_bit() - Generates a write-0 or write-1 cycle. |
83 | * @dev: the master device | ||
84 | * @bit: bit to write | ||
85 | * | ||
81 | * Only call if dev->bus_master->touch_bit is NULL | 86 | * Only call if dev->bus_master->touch_bit is NULL |
82 | */ | 87 | */ |
83 | static void w1_write_bit(struct w1_master *dev, int bit) | 88 | static void w1_write_bit(struct w1_master *dev, int bit) |
@@ -102,11 +107,12 @@ static void w1_write_bit(struct w1_master *dev, int bit) | |||
102 | } | 107 | } |
103 | 108 | ||
104 | /** | 109 | /** |
110 | * w1_pre_write() - pre-write operations | ||
111 | * @dev: the master device | ||
112 | * | ||
105 | * Pre-write operation, currently only supporting strong pullups. | 113 | * Pre-write operation, currently only supporting strong pullups. |
106 | * Program the hardware for a strong pullup, if one has been requested and | 114 | * Program the hardware for a strong pullup, if one has been requested and |
107 | * the hardware supports it. | 115 | * the hardware supports it. |
108 | * | ||
109 | * @param dev the master device | ||
110 | */ | 116 | */ |
111 | static void w1_pre_write(struct w1_master *dev) | 117 | static void w1_pre_write(struct w1_master *dev) |
112 | { | 118 | { |
@@ -118,11 +124,12 @@ static void w1_pre_write(struct w1_master *dev) | |||
118 | } | 124 | } |
119 | 125 | ||
120 | /** | 126 | /** |
127 | * w1_post_write() - post-write options | ||
128 | * @dev: the master device | ||
129 | * | ||
121 | * Post-write operation, currently only supporting strong pullups. | 130 | * Post-write operation, currently only supporting strong pullups. |
122 | * If a strong pullup was requested, clear it if the hardware supports | 131 | * If a strong pullup was requested, clear it if the hardware supports |
123 | * them, or execute the delay otherwise, in either case clear the request. | 132 | * them, or execute the delay otherwise, in either case clear the request. |
124 | * | ||
125 | * @param dev the master device | ||
126 | */ | 133 | */ |
127 | static void w1_post_write(struct w1_master *dev) | 134 | static void w1_post_write(struct w1_master *dev) |
128 | { | 135 | { |
@@ -136,10 +143,9 @@ static void w1_post_write(struct w1_master *dev) | |||
136 | } | 143 | } |
137 | 144 | ||
138 | /** | 145 | /** |
139 | * Writes 8 bits. | 146 | * w1_write_8() - Writes 8 bits. |
140 | * | 147 | * @dev: the master device |
141 | * @param dev the master device | 148 | * @byte: the byte to write |
142 | * @param byte the byte to write | ||
143 | */ | 149 | */ |
144 | void w1_write_8(struct w1_master *dev, u8 byte) | 150 | void w1_write_8(struct w1_master *dev, u8 byte) |
145 | { | 151 | { |
@@ -161,7 +167,9 @@ EXPORT_SYMBOL_GPL(w1_write_8); | |||
161 | 167 | ||
162 | 168 | ||
163 | /** | 169 | /** |
164 | * Generates a write-1 cycle and samples the level. | 170 | * w1_read_bit() - Generates a write-1 cycle and samples the level. |
171 | * @dev: the master device | ||
172 | * | ||
165 | * Only call if dev->bus_master->touch_bit is NULL | 173 | * Only call if dev->bus_master->touch_bit is NULL |
166 | */ | 174 | */ |
167 | static u8 w1_read_bit(struct w1_master *dev) | 175 | static u8 w1_read_bit(struct w1_master *dev) |
@@ -185,16 +193,17 @@ static u8 w1_read_bit(struct w1_master *dev) | |||
185 | } | 193 | } |
186 | 194 | ||
187 | /** | 195 | /** |
188 | * Does a triplet - used for searching ROM addresses. | 196 | * w1_triplet() - * Does a triplet - used for searching ROM addresses. |
197 | * @dev: the master device | ||
198 | * @bdir: the bit to write if both id_bit and comp_bit are 0 | ||
199 | * | ||
189 | * Return bits: | 200 | * Return bits: |
190 | * bit 0 = id_bit | 201 | * bit 0 = id_bit |
191 | * bit 1 = comp_bit | 202 | * bit 1 = comp_bit |
192 | * bit 2 = dir_taken | 203 | * bit 2 = dir_taken |
193 | * If both bits 0 & 1 are set, the search should be restarted. | 204 | * If both bits 0 & 1 are set, the search should be restarted. |
194 | * | 205 | * |
195 | * @param dev the master device | 206 | * Return: bit fields - see above |
196 | * @param bdir the bit to write if both id_bit and comp_bit are 0 | ||
197 | * @return bit fields - see above | ||
198 | */ | 207 | */ |
199 | u8 w1_triplet(struct w1_master *dev, int bdir) | 208 | u8 w1_triplet(struct w1_master *dev, int bdir) |
200 | { | 209 | { |
@@ -226,10 +235,10 @@ u8 w1_triplet(struct w1_master *dev, int bdir) | |||
226 | } | 235 | } |
227 | 236 | ||
228 | /** | 237 | /** |
229 | * Reads 8 bits. | 238 | * w1_read_8() - Reads 8 bits. |
239 | * @dev: the master device | ||
230 | * | 240 | * |
231 | * @param dev the master device | 241 | * Return: the byte read |
232 | * @return the byte read | ||
233 | */ | 242 | */ |
234 | u8 w1_read_8(struct w1_master *dev) | 243 | u8 w1_read_8(struct w1_master *dev) |
235 | { | 244 | { |
@@ -247,11 +256,10 @@ u8 w1_read_8(struct w1_master *dev) | |||
247 | EXPORT_SYMBOL_GPL(w1_read_8); | 256 | EXPORT_SYMBOL_GPL(w1_read_8); |
248 | 257 | ||
249 | /** | 258 | /** |
250 | * Writes a series of bytes. | 259 | * w1_write_block() - Writes a series of bytes. |
251 | * | 260 | * @dev: the master device |
252 | * @param dev the master device | 261 | * @buf: pointer to the data to write |
253 | * @param buf pointer to the data to write | 262 | * @len: the number of bytes to write |
254 | * @param len the number of bytes to write | ||
255 | */ | 263 | */ |
256 | void w1_write_block(struct w1_master *dev, const u8 *buf, int len) | 264 | void w1_write_block(struct w1_master *dev, const u8 *buf, int len) |
257 | { | 265 | { |
@@ -269,11 +277,10 @@ void w1_write_block(struct w1_master *dev, const u8 *buf, int len) | |||
269 | EXPORT_SYMBOL_GPL(w1_write_block); | 277 | EXPORT_SYMBOL_GPL(w1_write_block); |
270 | 278 | ||
271 | /** | 279 | /** |
272 | * Touches a series of bytes. | 280 | * w1_touch_block() - Touches a series of bytes. |
273 | * | 281 | * @dev: the master device |
274 | * @param dev the master device | 282 | * @buf: pointer to the data to write |
275 | * @param buf pointer to the data to write | 283 | * @len: the number of bytes to write |
276 | * @param len the number of bytes to write | ||
277 | */ | 284 | */ |
278 | void w1_touch_block(struct w1_master *dev, u8 *buf, int len) | 285 | void w1_touch_block(struct w1_master *dev, u8 *buf, int len) |
279 | { | 286 | { |
@@ -294,12 +301,11 @@ void w1_touch_block(struct w1_master *dev, u8 *buf, int len) | |||
294 | EXPORT_SYMBOL_GPL(w1_touch_block); | 301 | EXPORT_SYMBOL_GPL(w1_touch_block); |
295 | 302 | ||
296 | /** | 303 | /** |
297 | * Reads a series of bytes. | 304 | * w1_read_block() - Reads a series of bytes. |
298 | * | 305 | * @dev: the master device |
299 | * @param dev the master device | 306 | * @buf: pointer to the buffer to fill |
300 | * @param buf pointer to the buffer to fill | 307 | * @len: the number of bytes to read |
301 | * @param len the number of bytes to read | 308 | * Return: the number of bytes read |
302 | * @return the number of bytes read | ||
303 | */ | 309 | */ |
304 | u8 w1_read_block(struct w1_master *dev, u8 *buf, int len) | 310 | u8 w1_read_block(struct w1_master *dev, u8 *buf, int len) |
305 | { | 311 | { |
@@ -319,10 +325,9 @@ u8 w1_read_block(struct w1_master *dev, u8 *buf, int len) | |||
319 | EXPORT_SYMBOL_GPL(w1_read_block); | 325 | EXPORT_SYMBOL_GPL(w1_read_block); |
320 | 326 | ||
321 | /** | 327 | /** |
322 | * Issues a reset bus sequence. | 328 | * w1_reset_bus() - Issues a reset bus sequence. |
323 | * | 329 | * @dev: the master device |
324 | * @param dev The bus master pointer | 330 | * Return: 0=Device present, 1=No device present or error |
325 | * @return 0=Device present, 1=No device present or error | ||
326 | */ | 331 | */ |
327 | int w1_reset_bus(struct w1_master *dev) | 332 | int w1_reset_bus(struct w1_master *dev) |
328 | { | 333 | { |
@@ -383,12 +388,15 @@ void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_cal | |||
383 | } | 388 | } |
384 | 389 | ||
385 | /** | 390 | /** |
391 | * w1_reset_select_slave() - reset and select a slave | ||
392 | * @sl: the slave to select | ||
393 | * | ||
386 | * Resets the bus and then selects the slave by sending either a skip rom | 394 | * Resets the bus and then selects the slave by sending either a skip rom |
387 | * or a rom match. | 395 | * or a rom match. A skip rom is issued if there is only one device |
396 | * registered on the bus. | ||
388 | * The w1 master lock must be held. | 397 | * The w1 master lock must be held. |
389 | * | 398 | * |
390 | * @param sl the slave to select | 399 | * Return: 0=success, anything else=error |
391 | * @return 0=success, anything else=error | ||
392 | */ | 400 | */ |
393 | int w1_reset_select_slave(struct w1_slave *sl) | 401 | int w1_reset_select_slave(struct w1_slave *sl) |
394 | { | 402 | { |
@@ -409,6 +417,9 @@ int w1_reset_select_slave(struct w1_slave *sl) | |||
409 | EXPORT_SYMBOL_GPL(w1_reset_select_slave); | 417 | EXPORT_SYMBOL_GPL(w1_reset_select_slave); |
410 | 418 | ||
411 | /** | 419 | /** |
420 | * w1_reset_resume_command() - resume instead of another match ROM | ||
421 | * @dev: the master device | ||
422 | * | ||
412 | * When the workflow with a slave amongst many requires several | 423 | * When the workflow with a slave amongst many requires several |
413 | * successive commands a reset between each, this function is similar | 424 | * successive commands a reset between each, this function is similar |
414 | * to doing a reset then a match ROM for the last matched ROM. The | 425 | * to doing a reset then a match ROM for the last matched ROM. The |
@@ -420,8 +431,6 @@ EXPORT_SYMBOL_GPL(w1_reset_select_slave); | |||
420 | * doesn't work of course, but the resume command is the next best thing. | 431 | * doesn't work of course, but the resume command is the next best thing. |
421 | * | 432 | * |
422 | * The w1 master lock must be held. | 433 | * The w1 master lock must be held. |
423 | * | ||
424 | * @param dev the master device | ||
425 | */ | 434 | */ |
426 | int w1_reset_resume_command(struct w1_master *dev) | 435 | int w1_reset_resume_command(struct w1_master *dev) |
427 | { | 436 | { |
@@ -435,6 +444,10 @@ int w1_reset_resume_command(struct w1_master *dev) | |||
435 | EXPORT_SYMBOL_GPL(w1_reset_resume_command); | 444 | EXPORT_SYMBOL_GPL(w1_reset_resume_command); |
436 | 445 | ||
437 | /** | 446 | /** |
447 | * w1_next_pullup() - register for a strong pullup | ||
448 | * @dev: the master device | ||
449 | * @delay: time in milliseconds | ||
450 | * | ||
438 | * Put out a strong pull-up of the specified duration after the next write | 451 | * Put out a strong pull-up of the specified duration after the next write |
439 | * operation. Not all hardware supports strong pullups. Hardware that | 452 | * operation. Not all hardware supports strong pullups. Hardware that |
440 | * doesn't support strong pullups will sleep for the given time after the | 453 | * doesn't support strong pullups will sleep for the given time after the |
@@ -442,8 +455,7 @@ EXPORT_SYMBOL_GPL(w1_reset_resume_command); | |||
442 | * the next write, specifying zero will clear a previous request. | 455 | * the next write, specifying zero will clear a previous request. |
443 | * The w1 master lock must be held. | 456 | * The w1 master lock must be held. |
444 | * | 457 | * |
445 | * @param delay time in milliseconds | 458 | * Return: 0=success, anything else=error |
446 | * @return 0=success, anything else=error | ||
447 | */ | 459 | */ |
448 | void w1_next_pullup(struct w1_master *dev, int delay) | 460 | void w1_next_pullup(struct w1_master *dev, int delay) |
449 | { | 461 | { |
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h index ea9f3e453621..1e9504e67650 100644 --- a/drivers/w1/w1_netlink.h +++ b/drivers/w1/w1_netlink.h | |||
@@ -27,7 +27,8 @@ | |||
27 | 27 | ||
28 | #include "w1.h" | 28 | #include "w1.h" |
29 | 29 | ||
30 | /** enum w1_netlink_message_types - message type | 30 | /** |
31 | * enum w1_netlink_message_types - message type | ||
31 | * | 32 | * |
32 | * @W1_SLAVE_ADD: notification that a slave device was added | 33 | * @W1_SLAVE_ADD: notification that a slave device was added |
33 | * @W1_SLAVE_REMOVE: notification that a slave device was removed | 34 | * @W1_SLAVE_REMOVE: notification that a slave device was removed |
@@ -63,7 +64,8 @@ struct w1_netlink_msg | |||
63 | __u8 data[0]; | 64 | __u8 data[0]; |
64 | }; | 65 | }; |
65 | 66 | ||
66 | /** enum w1_commands - commands available for master or slave operations | 67 | /** |
68 | * enum w1_commands - commands available for master or slave operations | ||
67 | * @W1_CMD_READ: read len bytes | 69 | * @W1_CMD_READ: read len bytes |
68 | * @W1_CMD_WRITE: write len bytes | 70 | * @W1_CMD_WRITE: write len bytes |
69 | * @W1_CMD_SEARCH: initiate a standard search, returns only the slave | 71 | * @W1_CMD_SEARCH: initiate a standard search, returns only the slave |