sr/srd: Consistency fixes for callbacks.

- Callback function pointer typedefs end with _t.

 - Variables holding callback functions are named 'cb' everywhere.
This commit is contained in:
Uwe Hermann 2012-02-29 21:56:24 +01:00
parent cfe064d8e7
commit d08490aaba
5 changed files with 20 additions and 20 deletions

View File

@ -315,7 +315,7 @@ SR_PRIV void sr_source_remove(int fd)
}
SR_PRIV void sr_source_add(int fd, int events, int timeout,
sr_receive_data_callback rcv_cb, void *user_data)
sr_receive_data_callback_t cb, void *user_data)
{
sr_session_source_add(fd, events, timeout, rcv_cb, user_data);
sr_session_source_add(fd, events, timeout, cb, user_data);
}

View File

@ -32,7 +32,7 @@ struct source {
int fd;
int events;
int timeout;
sr_receive_data_callback cb;
sr_receive_data_callback_t cb;
void *user_data;
};
@ -174,21 +174,21 @@ SR_API int sr_session_datafeed_callback_clear(void)
/**
* Add a datafeed callback to the current session.
*
* @param callback Function to call when a chunk of data is received.
* @param cb Function to call when a chunk of data is received.
*
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
*/
SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback)
SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb)
{
if (!session) {
sr_err("session: %s: session was NULL", __func__);
return SR_ERR_BUG;
}
/* TODO: Is 'callback' allowed to be NULL? */
/* TODO: Is 'cb' allowed to be NULL? */
session->datafeed_callbacks =
g_slist_append(session->datafeed_callbacks, callback);
g_slist_append(session->datafeed_callbacks, cb);
return SR_OK;
}
@ -427,7 +427,7 @@ SR_PRIV int sr_session_bus(struct sr_dev *dev,
struct sr_datafeed_packet *packet)
{
GSList *l;
sr_datafeed_callback cb;
sr_datafeed_callback_t cb;
if (!dev) {
sr_err("session: %s: dev was NULL", __func__);
@ -463,19 +463,19 @@ SR_PRIV int sr_session_bus(struct sr_dev *dev,
* @param fd TODO.
* @param events TODO.
* @param timeout TODO.
* @param callback TODO.
* @param cb TODO.
* @param user_data TODO.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
* SR_ERR_MALLOC upon memory allocation errors.
*/
SR_API int sr_session_source_add(int fd, int events, int timeout,
sr_receive_data_callback callback, void *user_data)
sr_receive_data_callback_t cb, void *user_data)
{
struct source *new_sources, *s;
if (!callback) {
sr_err("session: %s: callback was NULL", __func__);
if (!cb) {
sr_err("session: %s: cb was NULL", __func__);
return SR_ERR_ARG;
}
@ -497,7 +497,7 @@ SR_API int sr_session_source_add(int fd, int events, int timeout,
s->fd = fd;
s->events = events;
s->timeout = timeout;
s->cb = callback;
s->cb = cb;
s->user_data = user_data;
sources = new_sources;

View File

@ -93,7 +93,7 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
SR_PRIV void sr_source_remove(int fd);
SR_PRIV void sr_source_add(int fd, int events, int timeout,
sr_receive_data_callback rcv_cb, void *user_data);
sr_receive_data_callback_t cb, void *user_data);
/*--- hardware/common/serial.c ----------------------------------------------*/

View File

@ -78,8 +78,8 @@ SR_API struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap);
/*--- session.c -------------------------------------------------------------*/
typedef void (*sr_datafeed_callback)(struct sr_dev *dev,
struct sr_datafeed_packet *packet);
typedef void (*sr_datafeed_callback_t)(struct sr_dev *dev,
struct sr_datafeed_packet *packet);
/* Session setup */
SR_API int sr_session_load(const char *filename);
@ -90,7 +90,7 @@ SR_API int sr_session_dev_add(struct sr_dev *dev);
/* Datafeed setup */
SR_API int sr_session_datafeed_callback_clear(void);
SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback);
SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb);
/* Session control */
SR_API int sr_session_start(void);
@ -99,7 +99,7 @@ SR_API int sr_session_halt(void);
SR_API int sr_session_stop(void);
SR_API int sr_session_save(const char *filename);
SR_API int sr_session_source_add(int fd, int events, int timeout,
sr_receive_data_callback callback, void *user_data);
sr_receive_data_callback_t cb, void *user_data);
SR_API int sr_session_source_remove(int fd);
/*--- input/input.c ---------------------------------------------------------*/

View File

@ -92,7 +92,7 @@ extern "C" {
/* Marks private, non-public libsigrok symbols (not part of the API). */
#define SR_PRIV __attribute__((visibility("hidden")))
typedef int (*sr_receive_data_callback) (int fd, int revents, void *user_data);
typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *user_data);
/* Data types used by hardware drivers for dev_config_set() */
enum {
@ -360,7 +360,7 @@ struct sr_dev_driver {
struct sr_session {
/* List of struct sr_dev* */
GSList *devs;
/* list of sr_receive_data_callback */
/* list of sr_receive_data_callback_t */
GSList *datafeed_callbacks;
GTimeVal starttime;
gboolean running;