X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbeaglelogic%2Fapi.c;h=46abde3d881aa8e16a89e8272e7fb58efe5c9c19;hb=c368e6f3d248a73d69cd0c2c4a7c88a92def55e3;hp=8af44d1e6ffa140109162e42426311e4c6f84051;hpb=af945a6625474e039fb7730483c5d07aa7f45969;p=libsigrok.git diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 8af44d1e..46abde3d 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -65,12 +65,11 @@ static int init(struct sr_context *sr_ctx) return std_init(sr_ctx, di, LOG_PREFIX); } -static struct dev_context * beaglelogic_devc_alloc(void) +static struct dev_context *beaglelogic_devc_alloc(void) { struct dev_context *devc; - /* Allocate zeroed structure */ - devc = g_try_malloc0(sizeof(*devc)); + devc = g_malloc0(sizeof(struct dev_context)); /* Default non-zero values (if any) */ devc->fd = -1; @@ -97,7 +96,10 @@ static GSList *scan(GSList *options) if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS)) return NULL; - sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, "BeagleLogic", "1.0"); + sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INACTIVE; + sdi->model = g_strdup("BeagleLogic"); + sdi->version = g_strdup("1.0"); sdi->driver = di; /* Unless explicitly specified, keep max channels to 8 only */ @@ -134,9 +136,8 @@ static GSList *scan(GSList *options) /* Fill the channels */ for (i = 0; i < maxch; i++) { - if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, - beaglelogic_channel_names[i]))) - return NULL; + ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, + beaglelogic_channel_names[i]); sdi->channels = g_slist_append(sdi->channels, ch); }