]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/mfd/dln2.h
1 #ifndef __LINUX_USB_DLN2_H
2 #define __LINUX_USB_DLN2_H
4 #define DLN2_CMD(cmd, id) ((cmd) | ((id) << 8))
6 struct dln2_platform_data
{
7 u16 handle
; /* sub-driver handle (internally used only) */
8 u8 port
; /* I2C/SPI port */
12 * dln2_event_cb_t - event callback function signature
14 * @pdev - the sub-device that registered this callback
15 * @echo - the echo header field received in the message
16 * @data - the data payload
17 * @len - the data payload length
19 * The callback function is called in interrupt context and the data payload is
20 * only valid during the call. If the user needs later access of the data, it
24 typedef void (*dln2_event_cb_t
)(struct platform_device
*pdev
, u16 echo
,
25 const void *data
, int len
);
28 * dl2n_register_event_cb - register a callback function for an event
30 * @pdev - the sub-device that registers the callback
31 * @event - the event for which to register a callback
32 * @event_cb - the callback function
34 * @return 0 in case of success, negative value in case of error
36 int dln2_register_event_cb(struct platform_device
*pdev
, u16 event
,
37 dln2_event_cb_t event_cb
);
40 * dln2_unregister_event_cb - unregister the callback function for an event
42 * @pdev - the sub-device that registered the callback
43 * @event - the event for which to register a callback
45 void dln2_unregister_event_cb(struct platform_device
*pdev
, u16 event
);
48 * dln2_transfer - issue a DLN2 command and wait for a response and the
51 * @pdev - the sub-device which is issuing this transfer
52 * @cmd - the command to be sent to the device
53 * @obuf - the buffer to be sent to the device; it can be NULL if the user
54 * doesn't need to transmit data with this command
55 * @obuf_len - the size of the buffer to be sent to the device
56 * @ibuf - any data associated with the response will be copied here; it can be
57 * NULL if the user doesn't need the response data
58 * @ibuf_len - must be initialized to the input buffer size; it will be modified
59 * to indicate the actual data transferred;
61 * @return 0 for success, negative value for errors
63 int dln2_transfer(struct platform_device
*pdev
, u16 cmd
,
64 const void *obuf
, unsigned obuf_len
,
65 void *ibuf
, unsigned *ibuf_len
);
68 * dln2_transfer_rx - variant of @dln2_transfer() where TX buffer is not needed
70 * @pdev - the sub-device which is issuing this transfer
71 * @cmd - the command to be sent to the device
72 * @ibuf - any data associated with the response will be copied here; it can be
73 * NULL if the user doesn't need the response data
74 * @ibuf_len - must be initialized to the input buffer size; it will be modified
75 * to indicate the actual data transferred;
77 * @return 0 for success, negative value for errors
80 static inline int dln2_transfer_rx(struct platform_device
*pdev
, u16 cmd
,
81 void *ibuf
, unsigned *ibuf_len
)
83 return dln2_transfer(pdev
, cmd
, NULL
, 0, ibuf
, ibuf_len
);
87 * dln2_transfer_tx - variant of @dln2_transfer() where RX buffer is not needed
89 * @pdev - the sub-device which is issuing this transfer
90 * @cmd - the command to be sent to the device
91 * @obuf - the buffer to be sent to the device; it can be NULL if the
92 * user doesn't need to transmit data with this command
93 * @obuf_len - the size of the buffer to be sent to the device
95 * @return 0 for success, negative value for errors
97 static inline int dln2_transfer_tx(struct platform_device
*pdev
, u16 cmd
,
98 const void *obuf
, unsigned obuf_len
)
100 return dln2_transfer(pdev
, cmd
, obuf
, obuf_len
, NULL
, NULL
);