Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
The Linux Kernal Code Style will be the death of me
  • Loading branch information
Ytuf committed Nov 13, 2024
1 parent 7d70f5d commit 279fa7a
Showing 1 changed file with 67 additions and 72 deletions.
139 changes: 67 additions & 72 deletions src/hardware/fwili/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ static gboolean is_plausible(const struct libusb_device_descriptor* des)
return TRUE;
}

static void scan_device(
struct ftdi_context* ftdic, struct libusb_device* dev, GSList** devices)
static void scan_device(struct ftdi_context* ftdic, struct libusb_device* dev,
GSList** devices)
{
static const int usb_str_maxlen = 32;

Expand All @@ -97,8 +97,7 @@ static void scan_device(

/* Allocate memory for the incoming data. */
devc->raw_data_buf = g_malloc0(RAW_DATA_BUF_SIZE);
devc->decoded_data_buf =
g_malloc0(RAW_DATA_BUF_SIZE * RLE_SIZE);
devc->decoded_data_buf = g_malloc0(RAW_DATA_BUF_SIZE * RLE_SIZE);

vendor = g_malloc(usb_str_maxlen);
model = g_malloc(usb_str_maxlen);
Expand Down Expand Up @@ -148,7 +147,7 @@ static void scan_device(

for (i = 0; i < ARRAY_SIZE(channel_names); i++)
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i]);
channel_names[i]);

*devices = g_slist_append(*devices, sdi);
return;
Expand Down Expand Up @@ -228,19 +227,17 @@ static GSList* scan(struct sr_dev_driver* di, GSList* options)
for (l = conn_devices; l; l = l->next) {
usb = l->data;
if (usb->bus ==
libusb_get_bus_number(
devlist[i]) &&
usb->address ==
libusb_get_device_address(
devlist[i])) {
scan_device(
ftdic, devlist[i], &devices);
libusb_get_bus_number(devlist[i])
&& usb->address ==
libusb_get_device_address(devlist[i])) {
scan_device(ftdic, devlist[i], &devices);
}
}
}
libusb_free_device_list(devlist, 1);
} else
} else {
devices = scan_all(ftdic, options);
}

ftdi_free(ftdic);

Expand All @@ -255,7 +252,8 @@ static void clear_helper(struct dev_context *devc)

static int dev_clear(const struct sr_dev_driver *di)
{
return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
return std_dev_clear_with_callback(di,
(std_dev_clear_callback)clear_helper);
}

static int dev_open(struct sr_dev_inst* sdi)
Expand Down Expand Up @@ -342,26 +340,25 @@ static int config_get(uint32_t key, GVariant** data,
devc = sdi->priv;

switch (key) {
case SR_CONF_CONN:
if (!sdi->conn)
return SR_ERR_ARG;
usb = sdi->conn;
*data = g_variant_new_printf(
"%d.%d", usb->bus, usb->address);
break;
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(devc->cur_samplerate);
break;
case SR_CONF_CAPTURE_RATIO:
*data = g_variant_new_uint64(devc->capture_ratio);
break;
case SR_CONF_LIMIT_SAMPLES:
*data = g_variant_new_uint64(devc->limit_samples);
break;
case SR_CONF_ENABLED:
break;
default:
return SR_ERR_NA;
case SR_CONF_CONN:
if (!sdi->conn)
return SR_ERR_ARG;
usb = sdi->conn;
*data = g_variant_new_printf("%d.%d", usb->bus, usb->address);
break;
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(devc->cur_samplerate);
break;
case SR_CONF_CAPTURE_RATIO:
*data = g_variant_new_uint64(devc->capture_ratio);
break;
case SR_CONF_LIMIT_SAMPLES:
*data = g_variant_new_uint64(devc->limit_samples);
break;
case SR_CONF_ENABLED:
break;
default:
return SR_ERR_NA;
}

return SR_OK;
Expand All @@ -380,19 +377,19 @@ static int config_set(uint32_t key, GVariant* data,
devc = sdi->priv;

switch (key) {
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
break;
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
break;
case SR_CONF_SAMPLERATE:
devc->cur_samplerate = g_variant_get_uint64(data);
break;
case SR_CONF_ENABLED:
break;
default:
return SR_ERR_NA;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
break;
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
break;
case SR_CONF_SAMPLERATE:
devc->cur_samplerate = g_variant_get_uint64(data);
break;
case SR_CONF_ENABLED:
break;
default:
return SR_ERR_NA;
}

return SR_OK;
Expand All @@ -401,30 +398,28 @@ static int config_set(uint32_t key, GVariant* data,
static int config_list(uint32_t key, GVariant** data,
const struct sr_dev_inst* sdi, const struct sr_channel_group* cg)
{

struct dev_context* devc;

devc = (sdi) ? sdi->priv : NULL;

switch (key) {
case SR_CONF_SCAN_OPTIONS:
case SR_CONF_DEVICE_OPTIONS:
if (cg)
return SR_ERR_NA;
return STD_CONFIG_LIST(
key, data, sdi, cg, scanopts, drvopts, devopts);
case SR_CONF_SAMPLERATE:
if (!devc)
return SR_ERR_NA;
*data = std_gvar_samplerates(
samplerates, ARRAY_SIZE(samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
*data = std_gvar_array_i32(
ARRAY_AND_SIZE(trigger_matches));
break;
default:
case SR_CONF_SCAN_OPTIONS:
case SR_CONF_DEVICE_OPTIONS:
if (cg)
return SR_ERR_NA;
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts,
drvopts, devopts);
case SR_CONF_SAMPLERATE:
if (!devc)
return SR_ERR_NA;
*data = std_gvar_samplerates(samplerates,
ARRAY_SIZE(samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
break;
default:
return SR_ERR_NA;
}

return SR_OK;
Expand All @@ -433,8 +428,8 @@ static int config_list(uint32_t key, GVariant** data,
static int dev_acquisition_start(const struct sr_dev_inst* sdi)
{
struct dev_context *devc;
struct sr_trigger *trigger;
int res;
struct sr_trigger *trigger;
int res;

devc = sdi->priv;

Expand Down Expand Up @@ -506,17 +501,17 @@ static int dev_acquisition_start(const struct sr_dev_inst* sdi)
res = ftdi_write_data(devc->ftdic, cmd_samplerate, sizeof(cmd_stop));
if (res < 0) {
sr_err("Failed to write samplerate to fwili. Plese ensure "
"the FPGA is programmed with the default logic "
"analyzer application.");
"the FPGA is programmed with the default logic "
"analyzer application.");
sr_dev_acquisition_stop(sdi);
}

/* Start the FPGA */
res = ftdi_write_data(devc->ftdic, cmd_start, sizeof(cmd_start));
if (res < 0) {
sr_err("Failed to write start bit to fwili. Plese ensure "
"the FPGA is programmed with the default logic "
"analyzer application.");
"the FPGA is programmed with the default logic "
"analyzer application.");
sr_dev_acquisition_stop(sdi);
}

Expand All @@ -543,7 +538,7 @@ static int dev_acquisition_stop(struct sr_dev_inst* sdi)
res = ftdi_write_data(devc->ftdic, cmd_stop, sizeof(cmd_stop));
if (res < 0) {
sr_err("Failed to stop hardware. Hardware must have power "
"cycled.");
"cycled.");
}

sr_session_source_remove(sdi->session, -1);
Expand Down

0 comments on commit 279fa7a

Please sign in to comment.