]> sigrok.org Git - libsigrok.git/blob - src/hardware/deree-de5000/api.c
std_init(): Drop check if pass in driver is non-NULL
[libsigrok.git] / src / hardware / deree-de5000 / api.c
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2014 Janne Huttunen <jahuttun@gmail.com>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include <config.h>
21 #include <stdint.h>
22 #include <string.h>
23 #include <math.h>
24 #include <glib.h>
25 #include <libsigrok/libsigrok.h>
26 #include "libsigrok-internal.h"
27
28 static void std_dev_attach(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
29 {
30         struct drv_context *drvc;
31
32         drvc = di->context;
33
34         sdi->driver = di;
35         drvc->instances = g_slist_append(drvc->instances, sdi);
36 }
37
38 #define LOG_PREFIX "deree-de5000"
39
40 SR_PRIV struct sr_dev_driver deree_de5000_driver_info;
41
42 static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
43 {
44         return std_init(di, sr_ctx);
45 }
46
47 static int dev_clear(const struct sr_dev_driver *di)
48 {
49         return std_dev_clear(di, es51919_serial_clean);
50 }
51
52 static GSList *scan(struct sr_dev_driver *di, GSList *options)
53 {
54         struct sr_dev_inst *sdi;
55
56         if (!(sdi = es51919_serial_scan(options, "DER EE", "DE-5000")))
57                 return NULL;
58
59         std_dev_attach(di, sdi);
60
61         return g_slist_append(NULL, sdi);
62 }
63
64 SR_PRIV struct sr_dev_driver deree_de5000_driver_info = {
65         .name = "deree-de5000",
66         .longname = "DER EE DE-5000",
67         .api_version = 1,
68         .init = init,
69         .cleanup = std_cleanup,
70         .scan = scan,
71         .dev_list = std_dev_list,
72         .dev_clear = dev_clear,
73         .config_get = es51919_serial_config_get,
74         .config_set = es51919_serial_config_set,
75         .config_list = es51919_serial_config_list,
76         .dev_open = std_serial_dev_open,
77         .dev_close = std_serial_dev_close,
78         .dev_acquisition_start = es51919_serial_acquisition_start,
79         .dev_acquisition_stop = es51919_serial_acquisition_stop,
80         .context = NULL,
81 };