![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef __LINUX_USB_DLN2_H 0003 #define __LINUX_USB_DLN2_H 0004 0005 #define DLN2_CMD(cmd, id) ((cmd) | ((id) << 8)) 0006 0007 struct dln2_platform_data { 0008 u16 handle; /* sub-driver handle (internally used only) */ 0009 u8 port; /* I2C/SPI port */ 0010 }; 0011 0012 /** 0013 * dln2_event_cb_t - event callback function signature 0014 * 0015 * @pdev - the sub-device that registered this callback 0016 * @echo - the echo header field received in the message 0017 * @data - the data payload 0018 * @len - the data payload length 0019 * 0020 * The callback function is called in interrupt context and the data payload is 0021 * only valid during the call. If the user needs later access of the data, it 0022 * must copy it. 0023 */ 0024 0025 typedef void (*dln2_event_cb_t)(struct platform_device *pdev, u16 echo, 0026 const void *data, int len); 0027 0028 /** 0029 * dl2n_register_event_cb - register a callback function for an event 0030 * 0031 * @pdev - the sub-device that registers the callback 0032 * @event - the event for which to register a callback 0033 * @event_cb - the callback function 0034 * 0035 * @return 0 in case of success, negative value in case of error 0036 */ 0037 int dln2_register_event_cb(struct platform_device *pdev, u16 event, 0038 dln2_event_cb_t event_cb); 0039 0040 /** 0041 * dln2_unregister_event_cb - unregister the callback function for an event 0042 * 0043 * @pdev - the sub-device that registered the callback 0044 * @event - the event for which to register a callback 0045 */ 0046 void dln2_unregister_event_cb(struct platform_device *pdev, u16 event); 0047 0048 /** 0049 * dln2_transfer - issue a DLN2 command and wait for a response and the 0050 * associated data 0051 * 0052 * @pdev - the sub-device which is issuing this transfer 0053 * @cmd - the command to be sent to the device 0054 * @obuf - the buffer to be sent to the device; it can be NULL if the user 0055 * doesn't need to transmit data with this command 0056 * @obuf_len - the size of the buffer to be sent to the device 0057 * @ibuf - any data associated with the response will be copied here; it can be 0058 * NULL if the user doesn't need the response data 0059 * @ibuf_len - must be initialized to the input buffer size; it will be modified 0060 * to indicate the actual data transferred; 0061 * 0062 * @return 0 for success, negative value for errors 0063 */ 0064 int dln2_transfer(struct platform_device *pdev, u16 cmd, 0065 const void *obuf, unsigned obuf_len, 0066 void *ibuf, unsigned *ibuf_len); 0067 0068 /** 0069 * dln2_transfer_rx - variant of @dln2_transfer() where TX buffer is not needed 0070 * 0071 * @pdev - the sub-device which is issuing this transfer 0072 * @cmd - the command to be sent to the device 0073 * @ibuf - any data associated with the response will be copied here; it can be 0074 * NULL if the user doesn't need the response data 0075 * @ibuf_len - must be initialized to the input buffer size; it will be modified 0076 * to indicate the actual data transferred; 0077 * 0078 * @return 0 for success, negative value for errors 0079 */ 0080 0081 static inline int dln2_transfer_rx(struct platform_device *pdev, u16 cmd, 0082 void *ibuf, unsigned *ibuf_len) 0083 { 0084 return dln2_transfer(pdev, cmd, NULL, 0, ibuf, ibuf_len); 0085 } 0086 0087 /** 0088 * dln2_transfer_tx - variant of @dln2_transfer() where RX buffer is not needed 0089 * 0090 * @pdev - the sub-device which is issuing this transfer 0091 * @cmd - the command to be sent to the device 0092 * @obuf - the buffer to be sent to the device; it can be NULL if the 0093 * user doesn't need to transmit data with this command 0094 * @obuf_len - the size of the buffer to be sent to the device 0095 * 0096 * @return 0 for success, negative value for errors 0097 */ 0098 static inline int dln2_transfer_tx(struct platform_device *pdev, u16 cmd, 0099 const void *obuf, unsigned obuf_len) 0100 { 0101 return dln2_transfer(pdev, cmd, obuf, obuf_len, NULL, NULL); 0102 } 0103 0104 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |