aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <jaylink-dev@marcschink.de>2016-05-15 13:10:41 +0200
committerMarc Schink <jaylink-dev@marcschink.de>2016-05-15 14:56:28 +0200
commita390aa84c5b3c791c285e435cde541cc78578986 (patch)
tree743b5abc0c70113b71c2fa93dd4db3ae81df815b
parent2b7b780fc63a334d0d2013b5e32ee0be33fed9d3 (diff)
Use enums where appropriate
Signed-off-by: Marc Schink <jaylink-dev@marcschink.de>
-rw-r--r--libjaylink/jtag.c6
-rw-r--r--libjaylink/libjaylink-internal.h7
-rw-r--r--libjaylink/libjaylink.h16
-rw-r--r--libjaylink/log.c12
4 files changed, 20 insertions, 21 deletions
diff --git a/libjaylink/jtag.c b/libjaylink/jtag.c
index 83fbf3c..06bf4fe 100644
--- a/libjaylink/jtag.c
+++ b/libjaylink/jtag.c
@@ -50,9 +50,7 @@
* on failure. The buffer must be large enough to contain at
* least the specified number of bits to transfer.
* @param[in] length Number of bits to transfer.
- * @param[in] version Version of the JTAG command to use. See
- * #jaylink_jtag_version for further information and a
- * description of the different versions.
+ * @param[in] version Version of the JTAG command to use.
*
* @retval JAYLINK_OK Success.
* @retval JAYLINK_ERR_ARG Invalid arguments.
@@ -66,7 +64,7 @@
*/
JAYLINK_API int jaylink_jtag_io(struct jaylink_device_handle *devh,
const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
- uint16_t length, int version)
+ uint16_t length, enum jaylink_jtag_version version)
{
int ret;
struct jaylink_context *ctx;
diff --git a/libjaylink/libjaylink-internal.h b/libjaylink/libjaylink-internal.h
index b53e49c..65e88f3 100644
--- a/libjaylink/libjaylink-internal.h
+++ b/libjaylink/libjaylink-internal.h
@@ -54,7 +54,7 @@ struct jaylink_context {
*/
struct list *devs;
/** Current log level. */
- int log_level;
+ enum jaylink_log_level log_level;
/** Log callback function. */
jaylink_log_callback log_callback;
/** User data to be passed to the log callback function. */
@@ -161,8 +161,9 @@ JAYLINK_PRIV void list_free(struct list *list);
/*--- log.c -----------------------------------------------------------------*/
-JAYLINK_PRIV int log_vprintf(const struct jaylink_context *ctx, int level,
- const char *format, va_list args, void *user_data);
+JAYLINK_PRIV int log_vprintf(const struct jaylink_context *ctx,
+ enum jaylink_log_level level, const char *format, va_list args,
+ void *user_data);
JAYLINK_PRIV void log_err(const struct jaylink_context *ctx,
const char *format, ...);
JAYLINK_PRIV void log_warn(const struct jaylink_context *ctx,
diff --git a/libjaylink/libjaylink.h b/libjaylink/libjaylink.h
index 27b212e..ffb7389 100644
--- a/libjaylink/libjaylink.h
+++ b/libjaylink/libjaylink.h
@@ -225,12 +225,8 @@ struct jaylink_swo_speed {
/** Device hardware version. */
struct jaylink_hardware_version {
- /**
- * Hardware type.
- *
- * See #jaylink_hardware_type for a description of the hardware types.
- */
- uint8_t type;
+ /** Hardware type. */
+ enum jaylink_hardware_type type;
/** Major version. */
uint8_t major;
/** Minor version. */
@@ -353,7 +349,8 @@ struct jaylink_device_handle;
/** Log callback function type. */
typedef int (*jaylink_log_callback)(const struct jaylink_context *ctx,
- int level, const char *format, va_list args, void *user_data);
+ enum jaylink_log_level level, const char *format, va_list args,
+ void *user_data);
/*--- core.c ----------------------------------------------------------------*/
@@ -437,13 +434,14 @@ JAYLINK_API int jaylink_file_delete(struct jaylink_device_handle *devh,
JAYLINK_API int jaylink_jtag_io(struct jaylink_device_handle *devh,
const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
- uint16_t length, int version);
+ uint16_t length, enum jaylink_jtag_version version);
JAYLINK_API int jaylink_jtag_clear_trst(struct jaylink_device_handle *devh);
JAYLINK_API int jaylink_jtag_set_trst(struct jaylink_device_handle *devh);
/*--- log.c -----------------------------------------------------------------*/
-JAYLINK_API int jaylink_log_set_level(struct jaylink_context *ctx, int level);
+JAYLINK_API int jaylink_log_set_level(struct jaylink_context *ctx,
+ enum jaylink_log_level level);
JAYLINK_API int jaylink_log_get_level(const struct jaylink_context *ctx);
JAYLINK_API int jaylink_log_set_callback(struct jaylink_context *ctx,
jaylink_log_callback callback, void *user_data);
diff --git a/libjaylink/log.c b/libjaylink/log.c
index 0017855..8535f39 100644
--- a/libjaylink/log.c
+++ b/libjaylink/log.c
@@ -37,17 +37,18 @@
* Set the libjaylink log level.
*
* @param[in,out] ctx libjaylink context.
- * @param[in] level Log level to set. See #jaylink_log_level for valid values.
+ * @param[in] level Log level to set.
*
* @retval JAYLINK_OK Success.
* @retval JAYLINK_ERR_ARG Invalid arguments.
*/
-JAYLINK_API int jaylink_log_set_level(struct jaylink_context *ctx, int level)
+JAYLINK_API int jaylink_log_set_level(struct jaylink_context *ctx,
+ enum jaylink_log_level level)
{
if (!ctx)
return JAYLINK_ERR_ARG;
- if (level < JAYLINK_LOG_LEVEL_NONE || level > JAYLINK_LOG_LEVEL_DEBUG)
+ if (level > JAYLINK_LOG_LEVEL_DEBUG)
return JAYLINK_ERR_ARG;
ctx->log_level = level;
@@ -154,8 +155,9 @@ JAYLINK_API const char *jaylink_log_get_domain(
}
/** @private */
-JAYLINK_PRIV int log_vprintf(const struct jaylink_context *ctx, int level,
- const char *format, va_list args, void *user_data)
+JAYLINK_PRIV int log_vprintf(const struct jaylink_context *ctx,
+ enum jaylink_log_level level, const char *format, va_list args,
+ void *user_data)
{
(void)user_data;