From: Uwe Hermann Date: Thu, 15 Apr 2010 18:55:57 +0000 (+0200) Subject: hardware/common: Coding style fixes. X-Git-Tag: libsigrok-0.1.0~559 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=986f7270bf871046e5cf1f154b6ed6226f63c7a5 hardware/common: Coding style fixes. --- diff --git a/hardware/common/ezusb.c b/hardware/common/ezusb.c index 68692c3a..884ceafd 100644 --- a/hardware/common/ezusb.c +++ b/hardware/common/ezusb.c @@ -56,15 +56,14 @@ int ezusb_install_firmware(libusb_device_handle *hdl, const char *filename) return 1; } - result = 0; - offset = 0; + result = offset = 0; while (1) { chunksize = fread(buf, 1, 4096, fw); if (chunksize == 0) break; err = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR | - LIBUSB_ENDPOINT_OUT, 0xa0, offset, 0x0000, - buf, chunksize, 100); + LIBUSB_ENDPOINT_OUT, 0xa0, offset, + 0x0000, buf, chunksize, 100); if (err < 0) { g_warning("Unable to send firmware to device: %d", err); result = 1; diff --git a/hardware/common/serial.c b/hardware/common/serial.c index dfc6d557..50a884e9 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -26,10 +26,7 @@ #include #include #include - -#include "sigrok.h" - - +#include char *serial_port_glob[] = { /* Linux */ @@ -40,10 +37,9 @@ char *serial_port_glob[] = { "/dev/ttys*", "/dev/tty.USB-*", "/dev/tty.Modem-*", - NULL + NULL, }; - GSList *list_serial_ports(void) { glob_t g; @@ -51,12 +47,11 @@ GSList *list_serial_ports(void) unsigned int i, j; ports = NULL; - for(i = 0; serial_port_glob[i]; i++) - { - if(!glob(serial_port_glob[i], 0, NULL, &g)) - { - for(j = 0; j < g.gl_pathc; j++) - ports = g_slist_append(ports, strdup(g.gl_pathv[j])); + for (i = 0; serial_port_glob[i]; i++) { + if (!glob(serial_port_glob[i], 0, NULL, &g)) { + for (j = 0; j < g.gl_pathc; j++) + ports = g_slist_append(ports, + strdup(g.gl_pathv[j])); globfree(&g); } } @@ -64,21 +59,16 @@ GSList *list_serial_ports(void) return ports; } - int serial_open(const char *pathname, int flags) { - return open(pathname, flags); } - int serial_close(int fd) { - return close(fd); } - void *serial_backup_params(int fd) { struct termios *term; @@ -89,37 +79,33 @@ void *serial_backup_params(int fd) return term; } - void serial_restore_params(int fd, void *backup) { - - tcsetattr(fd, TCSADRAIN, (struct termios *) backup); - + tcsetattr(fd, TCSADRAIN, (struct termios *)backup); } - /* flowcontrol 1 = rts/cts 2 = xon/xoff */ -int serial_set_params(int fd, int speed, int bits, int parity, int stopbits, int flowcontrol) +int serial_set_params(int fd, int speed, int bits, int parity, int stopbits, + int flowcontrol) { struct termios term; - /* only supporting what we need really -- currently just the OLS driver */ - if(speed != 115200 || bits != 8 || parity != 0 || stopbits != 1 || flowcontrol != 2) + /* Only supporting what we need really, currently the OLS driver. */ + if (speed != 115200 || bits != 8 || parity != 0 || stopbits != 1 + || flowcontrol != 2) return SIGROK_ERR; - if(tcgetattr(fd, &term) < 0) + if (tcgetattr(fd, &term) < 0) return SIGROK_ERR; - if(cfsetispeed(&term, B115200) < 0) + if (cfsetispeed(&term, B115200) < 0) return SIGROK_ERR; term.c_cflag &= ~CSIZE; term.c_cflag |= CS8; term.c_cflag &= ~CSTOPB; term.c_cflag |= IXON | IXOFF; term.c_iflag |= IGNPAR; - if(tcsetattr(fd, TCSADRAIN, &term) < 0) + if (tcsetattr(fd, TCSADRAIN, &term) < 0) return SIGROK_ERR; return SIGROK_OK; } - - diff --git a/hardware/common/skeleton.c b/hardware/common/skeleton.c index bb838140..d6cbd24c 100644 --- a/hardware/common/skeleton.c +++ b/hardware/common/skeleton.c @@ -21,77 +21,53 @@ static int hw_init(char *deviceinfo) { - } - static int hw_opendev(int device_index) { - } - static void hw_closedev(int device_index) { - } - static void hw_cleanup(void) { - } - static char *hw_get_identifier(int device_index) { - } - static char *hw_get_device_info(int device_index, int device_info_id) { - } - static int hw_get_status(int device_index) { - } - static int *hw_get_capabilities(void) { - } - static int hw_set_configuration(int device_index, int capability, char *value) { - } - static int hw_start_acquisition(int device_index, gpointer session_device_id) { - } - static void hw_stop_acquisition(int device_index, gpointer session_device_id) { - } - - struct device_plugin skeleton_plugin_info = { "skeleton", 1, hw_init, hw_cleanup, - hw_opendev, hw_closedev, hw_get_device_info, @@ -99,6 +75,5 @@ struct device_plugin skeleton_plugin_info = { hw_get_capabilities, hw_set_configuration, hw_start_acquisition, - hw_stop_acquisition + hw_stop_acquisition, }; -