From: Uwe Hermann Date: Sat, 2 Feb 2013 18:52:26 +0000 (+0100) Subject: Shorten/simplify hw_dev_list() implementations. X-Git-Tag: dsupstream~279 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0e94d524c19fe89c564243421d37c17818f87631;p=libsigrok.git Shorten/simplify hw_dev_list() implementations. --- diff --git a/hardware/agilent-dmm/api.c b/hardware/agilent-dmm/api.c index 26213938..61d4b313 100644 --- a/hardware/agilent-dmm/api.c +++ b/hardware/agilent-dmm/api.c @@ -188,11 +188,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/alsa/api.c b/hardware/alsa/api.c index d9dd83ef..57516750 100644 --- a/hardware/alsa/api.c +++ b/hardware/alsa/api.c @@ -62,11 +62,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index afbf51de..6d7fcde4 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -513,11 +513,7 @@ free: static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int upload_firmware(int firmware_idx, struct dev_context *devc) diff --git a/hardware/brymen-dmm/api.c b/hardware/brymen-dmm/api.c index b1b3acb9..83c7bc47 100644 --- a/hardware/brymen-dmm/api.c +++ b/hardware/brymen-dmm/api.c @@ -172,11 +172,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/chronovu-la8/api.c b/hardware/chronovu-la8/api.c index b1f88919..6bbdcdbb 100644 --- a/hardware/chronovu-la8/api.c +++ b/hardware/chronovu-la8/api.c @@ -180,11 +180,7 @@ err_free_nothing: static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/colead-slm/api.c b/hardware/colead-slm/api.c index 5532b1a1..cfeb45bd 100644 --- a/hardware/colead-slm/api.c +++ b/hardware/colead-slm/api.c @@ -134,11 +134,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index be989fe7..248ee11e 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -187,11 +187,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/fluke-dmm/api.c b/hardware/fluke-dmm/api.c index 0d73fb63..3ef69e97 100644 --- a/hardware/fluke-dmm/api.c +++ b/hardware/fluke-dmm/api.c @@ -222,11 +222,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index fb673d67..75b4557c 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -478,11 +478,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index 97742ffe..4b0dfe37 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -341,11 +341,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/lascar-el-usb/api.c b/hardware/lascar-el-usb/api.c index 1ab2a68f..2b442d6d 100644 --- a/hardware/lascar-el-usb/api.c +++ b/hardware/lascar-el-usb/api.c @@ -127,14 +127,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - if (!(drvc = di->priv)) { - sr_err("Driver was not initialized."); - return NULL; - } - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/link-mso19/api.c b/hardware/link-mso19/api.c index 93b77673..4a71863d 100644 --- a/hardware/link-mso19/api.c +++ b/hardware/link-mso19/api.c @@ -200,11 +200,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/mic-985xx/api.c b/hardware/mic-985xx/api.c index b8983a6d..ccc21f73 100644 --- a/hardware/mic-985xx/api.c +++ b/hardware/mic-985xx/api.c @@ -169,11 +169,7 @@ static GSList *hw_scan(GSList *options, int idx) static GSList *hw_dev_list(int idx) { - struct drv_context *drvc; - - drvc = mic_devs[idx].di->priv; - - return drvc->instances; + return ((struct drv_context *)(mic_devs[idx].di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/nexus-osciprime/api.c b/hardware/nexus-osciprime/api.c index bb3936b8..af90b753 100644 --- a/hardware/nexus-osciprime/api.c +++ b/hardware/nexus-osciprime/api.c @@ -218,11 +218,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index b2717016..6511e678 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -173,11 +173,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/rigol-ds1xx2/api.c b/hardware/rigol-ds1xx2/api.c index 8107fb8a..fe2ca5d2 100644 --- a/hardware/rigol-ds1xx2/api.c +++ b/hardware/rigol-ds1xx2/api.c @@ -273,11 +273,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index 987fafbf..2b5739f4 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -315,11 +315,7 @@ static GSList *hw_scan(GSList *options, int dmm) static GSList *hw_dev_list(int dmm) { - struct drv_context *drvc; - - drvc = dmms[dmm].di->priv; - - return drvc->instances; + return ((struct drv_context *)(dmms[dmm].di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/tondaj-sl-814/api.c b/hardware/tondaj-sl-814/api.c index da88bd07..36ec5c26 100644 --- a/hardware/tondaj-sl-814/api.c +++ b/hardware/tondaj-sl-814/api.c @@ -144,11 +144,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/uni-t-dmm/api.c b/hardware/uni-t-dmm/api.c index fcc8c0f6..9870130a 100644 --- a/hardware/uni-t-dmm/api.c +++ b/hardware/uni-t-dmm/api.c @@ -142,11 +142,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/victor-dmm/api.c b/hardware/victor-dmm/api.c index 75c893d1..bfe57c43 100644 --- a/hardware/victor-dmm/api.c +++ b/hardware/victor-dmm/api.c @@ -135,14 +135,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - if (!(drvc = di->priv)) { - sr_err("Driver was not initialized."); - return NULL; - } - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi) diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index c4add3fc..3acc977d 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -382,11 +382,7 @@ static GSList *hw_scan(GSList *options) static GSList *hw_dev_list(void) { - struct drv_context *drvc; - - drvc = di->priv; - - return drvc->instances; + return ((struct drv_context *)(di->priv))->instances; } static int hw_dev_open(struct sr_dev_inst *sdi)