From 293b45b77c90d5ca0de36fe5c4c690cbb9753eca Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 26 Feb 2010 14:40:16 +0000 Subject: [PATCH] Use the common fingerprint function directly. --- src/mares_common.c | 4 +++- src/mares_common.h | 2 +- src/mares_nemo.c | 15 +-------------- src/mares_puck.c | 15 +-------------- 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/mares_common.c b/src/mares_common.c index 5da2e50..972db83 100644 --- a/src/mares_common.c +++ b/src/mares_common.c @@ -44,8 +44,10 @@ mares_common_device_init (mares_common_device_t *device, const device_backend_t device_status_t -mares_common_device_set_fingerprint (mares_common_device_t *device, const unsigned char data[], unsigned int size) +mares_common_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) { + mares_common_device_t *device = (mares_common_device_t *) abstract; + assert (device != NULL); if (size && size != sizeof (device->fingerprint)) diff --git a/src/mares_common.h b/src/mares_common.h index a90cc6b..d775806 100644 --- a/src/mares_common.h +++ b/src/mares_common.h @@ -44,7 +44,7 @@ void mares_common_device_init (mares_common_device_t *device, const device_backend_t *backend); device_status_t -mares_common_device_set_fingerprint (mares_common_device_t *device, const unsigned char data[], unsigned int size); +mares_common_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); device_status_t mares_common_extract_dives (mares_common_device_t *device, const mares_common_layout_t *layout, const unsigned char data[], dive_callback_t callback, void *userdata); diff --git a/src/mares_nemo.c b/src/mares_nemo.c index 8751442..fa81620 100644 --- a/src/mares_nemo.c +++ b/src/mares_nemo.c @@ -49,14 +49,13 @@ typedef struct mares_nemo_device_t { struct serial *port; } mares_nemo_device_t; -static device_status_t mares_nemo_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); static device_status_t mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer); static device_status_t mares_nemo_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); static device_status_t mares_nemo_device_close (device_t *abstract); static const device_backend_t mares_nemo_device_backend = { DEVICE_TYPE_MARES_NEMO, - mares_nemo_device_set_fingerprint, /* set_fingerprint */ + mares_common_device_set_fingerprint, /* set_fingerprint */ NULL, /* version */ NULL, /* read */ NULL, /* write */ @@ -162,18 +161,6 @@ mares_nemo_device_close (device_t *abstract) } -static device_status_t -mares_nemo_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) -{ - mares_common_device_t *device = (mares_common_device_t*) abstract; - - if (! device_is_mares_nemo (abstract)) - return DEVICE_STATUS_TYPE_MISMATCH; - - return mares_common_device_set_fingerprint (device, data, size); -} - - static device_status_t mares_nemo_device_dump (device_t *abstract, dc_buffer_t *buffer) { diff --git a/src/mares_puck.c b/src/mares_puck.c index 9c69780..422baa5 100644 --- a/src/mares_puck.c +++ b/src/mares_puck.c @@ -43,7 +43,6 @@ typedef struct mares_puck_device_t { struct serial *port; } mares_puck_device_t; -static device_status_t mares_puck_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); static device_status_t mares_puck_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); static device_status_t mares_puck_device_dump (device_t *abstract, dc_buffer_t *buffer); static device_status_t mares_puck_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); @@ -51,7 +50,7 @@ static device_status_t mares_puck_device_close (device_t *abstract); static const device_backend_t mares_puck_device_backend = { DEVICE_TYPE_MARES_PUCK, - mares_puck_device_set_fingerprint, /* set_fingerprint */ + mares_common_device_set_fingerprint, /* set_fingerprint */ NULL, /* version */ mares_puck_device_read, /* read */ NULL, /* write */ @@ -286,18 +285,6 @@ mares_puck_transfer (mares_puck_device_t *device, const unsigned char command[], } -static device_status_t -mares_puck_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) -{ - mares_common_device_t *device = (mares_common_device_t*) abstract; - - if (! device_is_mares_puck (abstract)) - return DEVICE_STATUS_TYPE_MISMATCH; - - return mares_common_device_set_fingerprint (device, data, size); -} - - static device_status_t mares_puck_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size) {