22
22
#ifndef __W1_H
23
23
#define __W1_H
24
24
25
- struct w1_reg_num
26
- {
25
+ struct w1_reg_num {
27
26
#if defined(__LITTLE_ENDIAN_BITFIELD )
28
- __u64 family :8 ,
29
- id :48 ,
30
- crc :8 ;
27
+ __u64 family :8 , id :48 , crc :8 ;
31
28
#elif defined(__BIG_ENDIAN_BITFIELD )
32
- __u64 crc :8 ,
33
- id :48 ,
34
- family :8 ;
29
+ __u64 crc :8 , id :48 , family :8 ;
35
30
#else
36
31
#error "Please fix <asm/byteorder.h>"
37
32
#endif
@@ -59,26 +54,24 @@ struct w1_reg_num
59
54
60
55
#define W1_SLAVE_ACTIVE 0
61
56
62
- struct w1_slave
63
- {
64
- struct module * owner ;
65
- unsigned char name [W1_MAXNAMELEN ];
66
- struct list_head w1_slave_entry ;
67
- struct w1_reg_num reg_num ;
68
- atomic_t refcnt ;
69
- u8 rom [9 ];
70
- u32 flags ;
71
- int ttl ;
72
-
73
- struct w1_master * master ;
74
- struct w1_family * family ;
75
- void * family_data ;
76
- struct device dev ;
77
- struct completion released ;
57
+ struct w1_slave {
58
+ struct module * owner ;
59
+ unsigned char name [W1_MAXNAMELEN ];
60
+ struct list_head w1_slave_entry ;
61
+ struct w1_reg_num reg_num ;
62
+ atomic_t refcnt ;
63
+ u8 rom [9 ];
64
+ u32 flags ;
65
+ int ttl ;
66
+
67
+ struct w1_master * master ;
68
+ struct w1_family * family ;
69
+ void * family_data ;
70
+ struct device dev ;
71
+ struct completion released ;
78
72
};
79
73
80
- typedef void (* w1_slave_found_callback )(struct w1_master * , u64 );
81
-
74
+ typedef void (* w1_slave_found_callback ) (struct w1_master * , u64 );
82
75
83
76
/**
84
77
* Note: read_bit and write_bit are very low level functions and should only
@@ -87,19 +80,18 @@ typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
87
80
* Either define read_bit and write_bit OR define, at minimum, touch_bit and
88
81
* reset_bus.
89
82
*/
90
- struct w1_bus_master
91
- {
83
+ struct w1_bus_master {
92
84
/** the first parameter in all the functions below */
93
- void * data ;
85
+ void * data ;
94
86
95
87
/**
96
88
* Sample the line level
97
89
* @return the level read (0 or 1)
98
90
*/
99
- u8 (* read_bit )(void * );
91
+ u8 (* read_bit ) (void * );
100
92
101
93
/** Sets the line level */
102
- void (* write_bit )(void * , u8 );
94
+ void (* write_bit ) (void * , u8 );
103
95
104
96
/**
105
97
* touch_bit is the lowest-level function for devices that really
@@ -108,102 +100,103 @@ struct w1_bus_master
108
100
* touch_bit(1) = write-1 / read cycle
109
101
* @return the bit read (0 or 1)
110
102
*/
111
- u8 (* touch_bit )(void * , u8 );
103
+ u8 (* touch_bit ) (void * , u8 );
112
104
113
105
/**
114
106
* Reads a bytes. Same as 8 touch_bit(1) calls.
115
107
* @return the byte read
116
108
*/
117
- u8 (* read_byte )(void * );
109
+ u8 (* read_byte ) (void * );
118
110
119
111
/**
120
112
* Writes a byte. Same as 8 touch_bit(x) calls.
121
113
*/
122
- void (* write_byte )(void * , u8 );
114
+ void (* write_byte ) (void * , u8 );
123
115
124
116
/**
125
117
* Same as a series of read_byte() calls
126
118
* @return the number of bytes read
127
119
*/
128
- u8 (* read_block )(void * , u8 * , int );
120
+ u8 (* read_block ) (void * , u8 * , int );
129
121
130
122
/** Same as a series of write_byte() calls */
131
- void (* write_block )(void * , const u8 * , int );
123
+ void (* write_block ) (void * , const u8 * , int );
132
124
133
125
/**
134
126
* Combines two reads and a smart write for ROM searches
135
127
* @return bit0=Id bit1=comp_id bit2=dir_taken
136
128
*/
137
- u8 (* triplet )(void * , u8 );
129
+ u8 (* triplet ) (void * , u8 );
138
130
139
131
/**
140
132
* long write-0 with a read for the presence pulse detection
141
133
* @return -1=Error, 0=Device present, 1=No device present
142
134
*/
143
- u8 (* reset_bus )(void * );
135
+ u8 (* reset_bus ) (void * );
144
136
145
137
/**
146
138
* Put out a strong pull-up pulse of the specified duration.
147
139
* @return -1=Error, 0=completed
148
140
*/
149
- u8 (* set_pullup )(void * , int );
141
+ u8 (* set_pullup ) (void * , int );
150
142
151
143
/**
152
144
* Turns the pullup on/off in bitbanging mode, takes an on/off argument.
153
145
* @return -1=Error, 0=completed
154
146
*/
155
- void (* bitbang_pullup )(void * , u8 );
147
+ void (* bitbang_pullup ) (void * , u8 );
156
148
157
149
/** Really nice hardware can handles the different types of ROM search
158
150
* w1_master* is passed to the slave found callback.
159
151
*/
160
- void (* search )(void * , struct w1_master * ,
161
- u8 , w1_slave_found_callback );
152
+ void (* search ) (void * , struct w1_master * ,
153
+ u8 , w1_slave_found_callback );
162
154
};
163
155
164
- struct w1_master
165
- {
166
- struct list_head w1_master_entry ;
167
- struct module * owner ;
168
- unsigned char name [W1_MAXNAMELEN ];
169
- struct list_head slist ;
170
- int max_slave_count , slave_count ;
171
- unsigned long attempts ;
172
- int slave_ttl ;
173
- int initialized ;
174
- u32 id ;
175
- int search_count ;
176
-
177
- atomic_t refcnt ;
178
-
179
- void * priv ;
180
- int priv_size ;
156
+ struct w1_master {
157
+ struct list_head w1_master_entry ;
158
+ struct module * owner ;
159
+ unsigned char name [W1_MAXNAMELEN ];
160
+ struct list_head slist ;
161
+ int max_slave_count , slave_count ;
162
+ unsigned long attempts ;
163
+ int slave_ttl ;
164
+ int initialized ;
165
+ u32 id ;
166
+ int search_count ;
167
+
168
+ atomic_t refcnt ;
169
+
170
+ void * priv ;
171
+ int priv_size ;
181
172
182
173
/** 5V strong pullup enabled flag, 1 enabled, zero disabled. */
183
- int enable_pullup ;
174
+ int enable_pullup ;
184
175
/** 5V strong pullup duration in milliseconds, zero disabled. */
185
- int pullup_duration ;
176
+ int pullup_duration ;
186
177
187
- struct task_struct * thread ;
188
- struct mutex mutex ;
189
- struct mutex bus_mutex ;
178
+ struct task_struct * thread ;
179
+ struct mutex mutex ;
180
+ struct mutex bus_mutex ;
190
181
191
- struct device_driver * driver ;
192
- struct device dev ;
182
+ struct device_driver * driver ;
183
+ struct device dev ;
193
184
194
- struct w1_bus_master * bus_master ;
185
+ struct w1_bus_master * bus_master ;
195
186
196
- u32 seq ;
187
+ u32 seq ;
197
188
};
198
189
199
190
int w1_create_master_attributes (struct w1_master * );
200
191
void w1_destroy_master_attributes (struct w1_master * master );
201
- void w1_search (struct w1_master * dev , u8 search_type , w1_slave_found_callback cb );
202
- void w1_search_devices (struct w1_master * dev , u8 search_type , w1_slave_found_callback cb );
192
+ void w1_search (struct w1_master * dev , u8 search_type ,
193
+ w1_slave_found_callback cb );
194
+ void w1_search_devices (struct w1_master * dev , u8 search_type ,
195
+ w1_slave_found_callback cb );
203
196
struct w1_slave * w1_search_slave (struct w1_reg_num * id );
204
197
void w1_slave_found (struct w1_master * dev , u64 rn );
205
198
void w1_search_process_cb (struct w1_master * dev , u8 search_type ,
206
- w1_slave_found_callback cb );
199
+ w1_slave_found_callback cb );
207
200
struct w1_master * w1_search_master_id (u32 id );
208
201
209
202
/* Disconnect and reconnect devices in the given family. Used for finding
@@ -226,17 +219,17 @@ int w1_reset_select_slave(struct w1_slave *sl);
226
219
int w1_reset_resume_command (struct w1_master * );
227
220
void w1_next_pullup (struct w1_master * , int );
228
221
229
- static inline struct w1_slave * dev_to_w1_slave (struct device * dev )
222
+ static inline struct w1_slave * dev_to_w1_slave (struct device * dev )
230
223
{
231
224
return container_of (dev , struct w1_slave , dev );
232
225
}
233
226
234
- static inline struct w1_slave * kobj_to_w1_slave (struct kobject * kobj )
227
+ static inline struct w1_slave * kobj_to_w1_slave (struct kobject * kobj )
235
228
{
236
229
return dev_to_w1_slave (container_of (kobj , struct device , kobj ));
237
230
}
238
231
239
- static inline struct w1_master * dev_to_w1_master (struct device * dev )
232
+ static inline struct w1_master * dev_to_w1_master (struct device * dev )
240
233
{
241
234
return container_of (dev , struct w1_master , dev );
242
235
}
0 commit comments