~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/serdev.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/serdev.h (Version linux-6.12-rc7) and /include/linux/serdev.h (Version policy-sample)


  1 /* SPDX-License-Identifier: GPL-2.0-only */         1 
  2 /*                                                
  3  * Copyright (C) 2016-2017 Linaro Ltd., Rob He    
  4  */                                               
  5 #ifndef _LINUX_SERDEV_H                           
  6 #define _LINUX_SERDEV_H                           
  7                                                   
  8 #include <linux/types.h>                          
  9 #include <linux/device.h>                         
 10 #include <linux/iopoll.h>                         
 11 #include <linux/uaccess.h>                        
 12 #include <linux/termios.h>                        
 13 #include <linux/delay.h>                          
 14                                                   
 15 struct serdev_controller;                         
 16 struct serdev_device;                             
 17                                                   
 18 /*                                                
 19  * serdev device structures                       
 20  */                                               
 21                                                   
 22 /**                                               
 23  * struct serdev_device_ops - Callback operati    
 24  * @receive_buf:        Function called with d    
 25  *                      returns number of byte    
 26  * @write_wakeup:       Function called when r    
 27  *                      not sleep.                
 28  */                                               
 29 struct serdev_device_ops {                        
 30         size_t (*receive_buf)(struct serdev_de    
 31         void (*write_wakeup)(struct serdev_dev    
 32 };                                                
 33                                                   
 34 /**                                               
 35  * struct serdev_device - Basic representation    
 36  * @dev:        Driver model representation of    
 37  * @nr:         Device number on serdev bus.      
 38  * @ctrl:       serdev controller managing thi    
 39  * @ops:        Device operations.                
 40  * @write_comp  Completion used by serdev_devi    
 41  * @write_lock  Lock to serialize access when     
 42  */                                               
 43 struct serdev_device {                            
 44         struct device dev;                        
 45         int nr;                                   
 46         struct serdev_controller *ctrl;           
 47         const struct serdev_device_ops *ops;      
 48         struct completion write_comp;             
 49         struct mutex write_lock;                  
 50 };                                                
 51                                                   
 52 static inline struct serdev_device *to_serdev_    
 53 {                                                 
 54         return container_of(d, struct serdev_d    
 55 }                                                 
 56                                                   
 57 /**                                               
 58  * struct serdev_device_driver - serdev slave     
 59  * @driver:     serdev device drivers should i    
 60  *              structure.                        
 61  * @probe:      binds this driver to a serdev     
 62  * @remove:     unbinds this driver from the s    
 63  */                                               
 64 struct serdev_device_driver {                     
 65         struct device_driver driver;              
 66         int     (*probe)(struct serdev_device     
 67         void    (*remove)(struct serdev_device    
 68 };                                                
 69                                                   
 70 static inline struct serdev_device_driver *to_    
 71 {                                                 
 72         return container_of(d, struct serdev_d    
 73 }                                                 
 74                                                   
 75 enum serdev_parity {                              
 76         SERDEV_PARITY_NONE,                       
 77         SERDEV_PARITY_EVEN,                       
 78         SERDEV_PARITY_ODD,                        
 79 };                                                
 80                                                   
 81 /*                                                
 82  * serdev controller structures                   
 83  */                                               
 84 struct serdev_controller_ops {                    
 85         ssize_t (*write_buf)(struct serdev_con    
 86         void (*write_flush)(struct serdev_cont    
 87         int (*write_room)(struct serdev_contro    
 88         int (*open)(struct serdev_controller *    
 89         void (*close)(struct serdev_controller    
 90         void (*set_flow_control)(struct serdev    
 91         int (*set_parity)(struct serdev_contro    
 92         unsigned int (*set_baudrate)(struct se    
 93         void (*wait_until_sent)(struct serdev_    
 94         int (*get_tiocm)(struct serdev_control    
 95         int (*set_tiocm)(struct serdev_control    
 96         int (*break_ctl)(struct serdev_control    
 97 };                                                
 98                                                   
 99 /**                                               
100  * struct serdev_controller - interface to the    
101  * @dev:        Driver model representation of    
102  * @host:       Serial port hardware controlle    
103  * @nr:         number identifier for this con    
104  * @serdev:     Pointer to slave device for th    
105  * @ops:        Controller operations.            
106  */                                               
107 struct serdev_controller {                        
108         struct device           dev;              
109         struct device           *host;            
110         unsigned int            nr;               
111         struct serdev_device    *serdev;          
112         const struct serdev_controller_ops *op    
113 };                                                
114                                                   
115 static inline struct serdev_controller *to_ser    
116 {                                                 
117         return container_of(d, struct serdev_c    
118 }                                                 
119                                                   
120 static inline void *serdev_device_get_drvdata(    
121 {                                                 
122         return dev_get_drvdata(&serdev->dev);     
123 }                                                 
124                                                   
125 static inline void serdev_device_set_drvdata(s    
126 {                                                 
127         dev_set_drvdata(&serdev->dev, data);      
128 }                                                 
129                                                   
130 /**                                               
131  * serdev_device_put() - decrement serdev devi    
132  * @serdev      serdev device.                    
133  */                                               
134 static inline void serdev_device_put(struct se    
135 {                                                 
136         if (serdev)                               
137                 put_device(&serdev->dev);         
138 }                                                 
139                                                   
140 static inline void serdev_device_set_client_op    
141                                                   
142 {                                                 
143         serdev->ops = ops;                        
144 }                                                 
145                                                   
146 static inline                                     
147 void *serdev_controller_get_drvdata(const stru    
148 {                                                 
149         return ctrl ? dev_get_drvdata(&ctrl->d    
150 }                                                 
151                                                   
152 static inline void serdev_controller_set_drvda    
153                                                   
154 {                                                 
155         dev_set_drvdata(&ctrl->dev, data);        
156 }                                                 
157                                                   
158 /**                                               
159  * serdev_controller_put() - decrement control    
160  * @ctrl        serdev controller.                
161  */                                               
162 static inline void serdev_controller_put(struc    
163 {                                                 
164         if (ctrl)                                 
165                 put_device(&ctrl->dev);           
166 }                                                 
167                                                   
168 struct serdev_device *serdev_device_alloc(stru    
169 int serdev_device_add(struct serdev_device *);    
170 void serdev_device_remove(struct serdev_device    
171                                                   
172 struct serdev_controller *serdev_controller_al    
173                                                   
174                                                   
175 int serdev_controller_add(struct serdev_contro    
176 void serdev_controller_remove(struct serdev_co    
177                                                   
178 static inline void serdev_controller_write_wak    
179 {                                                 
180         struct serdev_device *serdev = ctrl->s    
181                                                   
182         if (!serdev || !serdev->ops->write_wak    
183                 return;                           
184                                                   
185         serdev->ops->write_wakeup(serdev);        
186 }                                                 
187                                                   
188 static inline size_t serdev_controller_receive    
189                                                   
190                                                   
191 {                                                 
192         struct serdev_device *serdev = ctrl->s    
193                                                   
194         if (!serdev || !serdev->ops->receive_b    
195                 return 0;                         
196                                                   
197         return serdev->ops->receive_buf(serdev    
198 }                                                 
199                                                   
200 #if IS_ENABLED(CONFIG_SERIAL_DEV_BUS)             
201                                                   
202 int serdev_device_open(struct serdev_device *)    
203 void serdev_device_close(struct serdev_device     
204 int devm_serdev_device_open(struct device *, s    
205 unsigned int serdev_device_set_baudrate(struct    
206 void serdev_device_set_flow_control(struct ser    
207 int serdev_device_write_buf(struct serdev_devi    
208 void serdev_device_wait_until_sent(struct serd    
209 int serdev_device_get_tiocm(struct serdev_devi    
210 int serdev_device_set_tiocm(struct serdev_devi    
211 int serdev_device_break_ctl(struct serdev_devi    
212 void serdev_device_write_wakeup(struct serdev_    
213 ssize_t serdev_device_write(struct serdev_devi    
214 void serdev_device_write_flush(struct serdev_d    
215 int serdev_device_write_room(struct serdev_dev    
216                                                   
217 /*                                                
218  * serdev device driver functions                 
219  */                                               
220 int __serdev_device_driver_register(struct ser    
221 #define serdev_device_driver_register(sdrv) \     
222         __serdev_device_driver_register(sdrv,     
223                                                   
224 /**                                               
225  * serdev_device_driver_unregister() - unregis    
226  * @sdrv:       the driver to unregister          
227  */                                               
228 static inline void serdev_device_driver_unregi    
229 {                                                 
230         if (sdrv)                                 
231                 driver_unregister(&sdrv->drive    
232 }                                                 
233                                                   
234 #define module_serdev_device_driver(__serdev_d    
235         module_driver(__serdev_device_driver,     
236                         serdev_device_driver_u    
237                                                   
238 #else                                             
239                                                   
240 static inline int serdev_device_open(struct se    
241 {                                                 
242         return -ENODEV;                           
243 }                                                 
244 static inline void serdev_device_close(struct     
245 static inline unsigned int serdev_device_set_b    
246 {                                                 
247         return 0;                                 
248 }                                                 
249 static inline void serdev_device_set_flow_cont    
250 static inline int serdev_device_write_buf(stru    
251                                           cons    
252                                           size    
253 {                                                 
254         return -ENODEV;                           
255 }                                                 
256 static inline void serdev_device_wait_until_se    
257 static inline int serdev_device_get_tiocm(stru    
258 {                                                 
259         return -EOPNOTSUPP;                       
260 }                                                 
261 static inline int serdev_device_set_tiocm(stru    
262 {                                                 
263         return -EOPNOTSUPP;                       
264 }                                                 
265 static inline int serdev_device_break_ctl(stru    
266 {                                                 
267         return -EOPNOTSUPP;                       
268 }                                                 
269 static inline ssize_t serdev_device_write(stru    
270                                           cons    
271                                           unsi    
272 {                                                 
273         return -ENODEV;                           
274 }                                                 
275 static inline void serdev_device_write_flush(s    
276 static inline int serdev_device_write_room(str    
277 {                                                 
278         return 0;                                 
279 }                                                 
280                                                   
281 #define serdev_device_driver_register(x)          
282 #define serdev_device_driver_unregister(x)        
283                                                   
284 #endif /* CONFIG_SERIAL_DEV_BUS */                
285                                                   
286 static inline bool serdev_device_get_cts(struc    
287 {                                                 
288         int status = serdev_device_get_tiocm(s    
289         return !!(status & TIOCM_CTS);            
290 }                                                 
291                                                   
292 static inline int serdev_device_wait_for_cts(s    
293 {                                                 
294         bool signal;                              
295                                                   
296         return readx_poll_timeout(serdev_devic    
297                                   2000, timeou    
298 }                                                 
299                                                   
300 static inline int serdev_device_set_rts(struct    
301 {                                                 
302         if (enable)                               
303                 return serdev_device_set_tiocm    
304         else                                      
305                 return serdev_device_set_tiocm    
306 }                                                 
307                                                   
308 int serdev_device_set_parity(struct serdev_dev    
309                              enum serdev_parit    
310                                                   
311 /*                                                
312  * serdev hooks into TTY core                     
313  */                                               
314 struct tty_port;                                  
315 struct tty_driver;                                
316                                                   
317 #ifdef CONFIG_SERIAL_DEV_CTRL_TTYPORT             
318 struct device *serdev_tty_port_register(struct    
319                                         struct    
320                                         struct    
321                                         struct    
322 int serdev_tty_port_unregister(struct tty_port    
323 #else                                             
324 static inline struct device *serdev_tty_port_r    
325                                            str    
326                                            str    
327                                            str    
328 {                                                 
329         return ERR_PTR(-ENODEV);                  
330 }                                                 
331 static inline int serdev_tty_port_unregister(s    
332 {                                                 
333         return -ENODEV;                           
334 }                                                 
335 #endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */       
336                                                   
337 struct acpi_resource;                             
338 struct acpi_resource_uart_serialbus;              
339                                                   
340 #ifdef CONFIG_ACPI                                
341 bool serdev_acpi_get_uart_resource(struct acpi    
342                                    struct acpi    
343 #else                                             
344 static inline bool serdev_acpi_get_uart_resour    
345                                                   
346 {                                                 
347         return false;                             
348 }                                                 
349 #endif /* CONFIG_ACPI */                          
350                                                   
351 #endif /*_LINUX_SERDEV_H */                       
352                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php