aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/w1.h
diff options
context:
space:
mode:
authorDavid Fries <David@Fries.net>2014-01-15 23:29:25 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 18:40:18 -0500
commitb3be177a19f0f9e4f0deb473cef0e95e1254f2e9 (patch)
treee124f5b65942b7883fb2dcdc29e8e4ffca2625a7 /drivers/w1/w1.h
parenteb2c0da4ac2f4614b0bd3a1b6a0e9b82d0802e08 (diff)
w1: format for DocBook and fixes
Switch the code documentation format style to DocBook format, enable DocBook documentation generation, and fix some comments. Signed-off-by: David Fries <David@Fries.net> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1/w1.h')
-rw-r--r--drivers/w1/w1.h136
1 files changed, 93 insertions, 43 deletions
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 */
25struct w1_reg_num 32struct 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 */
63struct w1_slave 86struct 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 */
89struct w1_bus_master 150struct 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 */
168struct w1_master 219struct 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;
290extern struct list_head w1_masters; 341extern struct list_head w1_masters;
291extern struct mutex w1_mlock; 342extern struct mutex w1_mlock;
292 343
293/* returns 1 if there were commands to executed 0 otherwise */
294extern int w1_process_callbacks(struct w1_master *dev); 344extern int w1_process_callbacks(struct w1_master *dev);
295extern int w1_process(void *); 345extern int w1_process(void *);
296 346