Skip to content

Commit c9b4656

Browse files
gwendalcrEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec: Put docs with the code
To avoid doc rot, put function documentations with code, not header. Use kernel-doc style comments for exported functions. Signed-off-by: Gwendal Grignou <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent 54ecb8f commit c9b4656

File tree

3 files changed

+103
-103
lines changed

3 files changed

+103
-103
lines changed

drivers/platform/chrome/cros_ec.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event)
104104
return ret;
105105
}
106106

107+
/**
108+
* cros_ec_register() - Register a new ChromeOS EC, using the provided info.
109+
* @ec_dev: Device to register.
110+
*
111+
* Before calling this, allocate a pointer to a new device and then fill
112+
* in all the fields up to the --private-- marker.
113+
*
114+
* Return: 0 on success or negative error code.
115+
*/
107116
int cros_ec_register(struct cros_ec_device *ec_dev)
108117
{
109118
struct device *dev = ec_dev->dev;
@@ -198,6 +207,14 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
198207
}
199208
EXPORT_SYMBOL(cros_ec_register);
200209

210+
/**
211+
* cros_ec_unregister() - Remove a ChromeOS EC.
212+
* @ec_dev: Device to unregister.
213+
*
214+
* Call this to deregister a ChromeOS EC, then clean up any private data.
215+
*
216+
* Return: 0 on success or negative error code.
217+
*/
201218
int cros_ec_unregister(struct cros_ec_device *ec_dev)
202219
{
203220
if (ec_dev->pd)
@@ -209,6 +226,14 @@ int cros_ec_unregister(struct cros_ec_device *ec_dev)
209226
EXPORT_SYMBOL(cros_ec_unregister);
210227

211228
#ifdef CONFIG_PM_SLEEP
229+
/**
230+
* cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device.
231+
* @ec_dev: Device to suspend.
232+
*
233+
* This can be called by drivers to handle a suspend event.
234+
*
235+
* Return: 0 on success or negative error code.
236+
*/
212237
int cros_ec_suspend(struct cros_ec_device *ec_dev)
213238
{
214239
struct device *dev = ec_dev->dev;
@@ -243,6 +268,14 @@ static void cros_ec_report_events_during_suspend(struct cros_ec_device *ec_dev)
243268
1, ec_dev);
244269
}
245270

271+
/**
272+
* cros_ec_resume() - Handle a resume operation for the ChromeOS EC device.
273+
* @ec_dev: Device to resume.
274+
*
275+
* This can be called by drivers to handle a resume event.
276+
*
277+
* Return: 0 on success or negative error code.
278+
*/
246279
int cros_ec_resume(struct cros_ec_device *ec_dev)
247280
{
248281
int ret;

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ static int send_command(struct cros_ec_device *ec_dev,
117117
return ret;
118118
}
119119

120+
/**
121+
* cros_ec_prepare_tx() - Prepare an outgoing message in the output buffer.
122+
* @ec_dev: Device to register.
123+
* @msg: Message to write.
124+
*
125+
* This is intended to be used by all ChromeOS EC drivers, but at present
126+
* only SPI uses it. Once LPC uses the same protocol it can start using it.
127+
* I2C could use it now, with a refactor of the existing code.
128+
*
129+
* Return: 0 on success or negative error code.
130+
*/
120131
int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
121132
struct cros_ec_command *msg)
122133
{
@@ -141,6 +152,16 @@ int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
141152
}
142153
EXPORT_SYMBOL(cros_ec_prepare_tx);
143154

155+
/**
156+
* cros_ec_check_result() - Check ec_msg->result.
157+
* @ec_dev: EC device.
158+
* @msg: Message to check.
159+
*
160+
* This is used by ChromeOS EC drivers to check the ec_msg->result for
161+
* errors and to warn about them.
162+
*
163+
* Return: 0 on success or negative error code.
164+
*/
144165
int cros_ec_check_result(struct cros_ec_device *ec_dev,
145166
struct cros_ec_command *msg)
146167
{
@@ -326,6 +347,13 @@ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev,
326347
return ret;
327348
}
328349

350+
/**
351+
* cros_ec_query_all() - Query the protocol version supported by the
352+
* ChromeOS EC.
353+
* @ec_dev: Device to register.
354+
*
355+
* Return: 0 on success or negative error code.
356+
*/
329357
int cros_ec_query_all(struct cros_ec_device *ec_dev)
330358
{
331359
struct device *dev = ec_dev->dev;
@@ -453,6 +481,16 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
453481
}
454482
EXPORT_SYMBOL(cros_ec_query_all);
455483

484+
/**
485+
* cros_ec_cmd_xfer() - Send a command to the ChromeOS EC.
486+
* @ec_dev: EC device.
487+
* @msg: Message to write.
488+
*
489+
* Call this to send a command to the ChromeOS EC. This should be used
490+
* instead of calling the EC's cmd_xfer() callback directly.
491+
*
492+
* Return: 0 on success or negative error code.
493+
*/
456494
int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
457495
struct cros_ec_command *msg)
458496
{
@@ -500,6 +538,18 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
500538
}
501539
EXPORT_SYMBOL(cros_ec_cmd_xfer);
502540

541+
/**
542+
* cros_ec_cmd_xfer_status() - Send a command to the ChromeOS EC.
543+
* @ec_dev: EC device.
544+
* @msg: Message to write.
545+
*
546+
* This function is identical to cros_ec_cmd_xfer, except it returns success
547+
* status only if both the command was transmitted successfully and the EC
548+
* replied with success status. It's not necessary to check msg->result when
549+
* using this function.
550+
*
551+
* Return: The number of bytes transferred on success or negative error code.
552+
*/
503553
int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
504554
struct cros_ec_command *msg)
505555
{
@@ -584,6 +634,16 @@ static int get_keyboard_state_event(struct cros_ec_device *ec_dev)
584634
return ec_dev->event_size;
585635
}
586636

637+
/**
638+
* cros_ec_get_next_event() - Fetch next event from the ChromeOS EC.
639+
* @ec_dev: Device to fetch event from.
640+
* @wake_event: Pointer to a bool set to true upon return if the event might be
641+
* treated as a wake event. Ignored if null.
642+
*
643+
* Return: negative error code on errors; 0 for no data; or else number of
644+
* bytes received (i.e., an event was retrieved successfully). Event types are
645+
* written out to @ec_dev->event_data.event_type on success.
646+
*/
587647
int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event)
588648
{
589649
u8 event_type;
@@ -628,6 +688,16 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event)
628688
}
629689
EXPORT_SYMBOL(cros_ec_get_next_event);
630690

691+
/**
692+
* cros_ec_get_host_event() - Return a mask of event set by the ChromeOS EC.
693+
* @ec_dev: Device to fetch event from.
694+
*
695+
* When MKBP is supported, when the EC raises an interrupt, we collect the
696+
* events raised and call the functions in the ec notifier. This function
697+
* is a helper to know which events are raised.
698+
*
699+
* Return: 0 on error or non-zero bitmask of one or more EC_HOST_EVENT_*.
700+
*/
631701
u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev)
632702
{
633703
u32 host_event;

include/linux/platform_data/cros_ec_proto.h

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -187,133 +187,30 @@ struct cros_ec_platform {
187187
u16 cmd_offset;
188188
};
189189

190-
/**
191-
* cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device.
192-
* @ec_dev: Device to suspend.
193-
*
194-
* This can be called by drivers to handle a suspend event.
195-
*
196-
* Return: 0 on success or negative error code.
197-
*/
198190
int cros_ec_suspend(struct cros_ec_device *ec_dev);
199191

200-
/**
201-
* cros_ec_resume() - Handle a resume operation for the ChromeOS EC device.
202-
* @ec_dev: Device to resume.
203-
*
204-
* This can be called by drivers to handle a resume event.
205-
*
206-
* Return: 0 on success or negative error code.
207-
*/
208192
int cros_ec_resume(struct cros_ec_device *ec_dev);
209193

210-
/**
211-
* cros_ec_prepare_tx() - Prepare an outgoing message in the output buffer.
212-
* @ec_dev: Device to register.
213-
* @msg: Message to write.
214-
*
215-
* This is intended to be used by all ChromeOS EC drivers, but at present
216-
* only SPI uses it. Once LPC uses the same protocol it can start using it.
217-
* I2C could use it now, with a refactor of the existing code.
218-
*
219-
* Return: 0 on success or negative error code.
220-
*/
221194
int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
222195
struct cros_ec_command *msg);
223196

224-
/**
225-
* cros_ec_check_result() - Check ec_msg->result.
226-
* @ec_dev: EC device.
227-
* @msg: Message to check.
228-
*
229-
* This is used by ChromeOS EC drivers to check the ec_msg->result for
230-
* errors and to warn about them.
231-
*
232-
* Return: 0 on success or negative error code.
233-
*/
234197
int cros_ec_check_result(struct cros_ec_device *ec_dev,
235198
struct cros_ec_command *msg);
236199

237-
/**
238-
* cros_ec_cmd_xfer() - Send a command to the ChromeOS EC.
239-
* @ec_dev: EC device.
240-
* @msg: Message to write.
241-
*
242-
* Call this to send a command to the ChromeOS EC. This should be used
243-
* instead of calling the EC's cmd_xfer() callback directly.
244-
*
245-
* Return: 0 on success or negative error code.
246-
*/
247200
int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
248201
struct cros_ec_command *msg);
249202

250-
/**
251-
* cros_ec_cmd_xfer_status() - Send a command to the ChromeOS EC.
252-
* @ec_dev: EC device.
253-
* @msg: Message to write.
254-
*
255-
* This function is identical to cros_ec_cmd_xfer, except it returns success
256-
* status only if both the command was transmitted successfully and the EC
257-
* replied with success status. It's not necessary to check msg->result when
258-
* using this function.
259-
*
260-
* Return: The number of bytes transferred on success or negative error code.
261-
*/
262203
int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
263204
struct cros_ec_command *msg);
264205

265-
/**
266-
* cros_ec_register() - Register a new ChromeOS EC, using the provided info.
267-
* @ec_dev: Device to register.
268-
*
269-
* Before calling this, allocate a pointer to a new device and then fill
270-
* in all the fields up to the --private-- marker.
271-
*
272-
* Return: 0 on success or negative error code.
273-
*/
274206
int cros_ec_register(struct cros_ec_device *ec_dev);
275207

276-
/**
277-
* cros_ec_unregister() - Remove a ChromeOS EC.
278-
* @ec_dev: Device to unregister.
279-
*
280-
* Call this to deregister a ChromeOS EC, then clean up any private data.
281-
*
282-
* Return: 0 on success or negative error code.
283-
*/
284208
int cros_ec_unregister(struct cros_ec_device *ec_dev);
285209

286-
/**
287-
* cros_ec_query_all() - Query the protocol version supported by the
288-
* ChromeOS EC.
289-
* @ec_dev: Device to register.
290-
*
291-
* Return: 0 on success or negative error code.
292-
*/
293210
int cros_ec_query_all(struct cros_ec_device *ec_dev);
294211

295-
/**
296-
* cros_ec_get_next_event() - Fetch next event from the ChromeOS EC.
297-
* @ec_dev: Device to fetch event from.
298-
* @wake_event: Pointer to a bool set to true upon return if the event might be
299-
* treated as a wake event. Ignored if null.
300-
*
301-
* Return: negative error code on errors; 0 for no data; or else number of
302-
* bytes received (i.e., an event was retrieved successfully). Event types are
303-
* written out to @ec_dev->event_data.event_type on success.
304-
*/
305212
int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event);
306213

307-
/**
308-
* cros_ec_get_host_event() - Return a mask of event set by the ChromeOS EC.
309-
* @ec_dev: Device to fetch event from.
310-
*
311-
* When MKBP is supported, when the EC raises an interrupt, we collect the
312-
* events raised and call the functions in the ec notifier. This function
313-
* is a helper to know which events are raised.
314-
*
315-
* Return: 0 on error or non-zero bitmask of one or more EC_HOST_EVENT_*.
316-
*/
317214
u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);
318215

319216
#endif /* __LINUX_CROS_EC_PROTO_H */

0 commit comments

Comments
 (0)