hardware/common: Coding style fixes.

This commit is contained in:
Uwe Hermann 2010-04-15 20:55:57 +02:00
parent 99c1fc59ed
commit 986f7270bf
3 changed files with 20 additions and 60 deletions

View File

@ -56,15 +56,14 @@ int ezusb_install_firmware(libusb_device_handle *hdl, const char *filename)
return 1; return 1;
} }
result = 0; result = offset = 0;
offset = 0;
while (1) { while (1) {
chunksize = fread(buf, 1, 4096, fw); chunksize = fread(buf, 1, 4096, fw);
if (chunksize == 0) if (chunksize == 0)
break; break;
err = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR | err = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, 0xa0, offset, 0x0000, LIBUSB_ENDPOINT_OUT, 0xa0, offset,
buf, chunksize, 100); 0x0000, buf, chunksize, 100);
if (err < 0) { if (err < 0) {
g_warning("Unable to send firmware to device: %d", err); g_warning("Unable to send firmware to device: %d", err);
result = 1; result = 1;

View File

@ -26,10 +26,7 @@
#include <termios.h> #include <termios.h>
#include <stdlib.h> #include <stdlib.h>
#include <glib.h> #include <glib.h>
#include <sigrok.h>
#include "sigrok.h"
char *serial_port_glob[] = { char *serial_port_glob[] = {
/* Linux */ /* Linux */
@ -40,10 +37,9 @@ char *serial_port_glob[] = {
"/dev/ttys*", "/dev/ttys*",
"/dev/tty.USB-*", "/dev/tty.USB-*",
"/dev/tty.Modem-*", "/dev/tty.Modem-*",
NULL NULL,
}; };
GSList *list_serial_ports(void) GSList *list_serial_ports(void)
{ {
glob_t g; glob_t g;
@ -51,12 +47,11 @@ GSList *list_serial_ports(void)
unsigned int i, j; unsigned int i, j;
ports = NULL; ports = NULL;
for(i = 0; serial_port_glob[i]; i++) for (i = 0; serial_port_glob[i]; i++) {
{ if (!glob(serial_port_glob[i], 0, NULL, &g)) {
if(!glob(serial_port_glob[i], 0, NULL, &g)) for (j = 0; j < g.gl_pathc; j++)
{ ports = g_slist_append(ports,
for(j = 0; j < g.gl_pathc; j++) strdup(g.gl_pathv[j]));
ports = g_slist_append(ports, strdup(g.gl_pathv[j]));
globfree(&g); globfree(&g);
} }
} }
@ -64,21 +59,16 @@ GSList *list_serial_ports(void)
return ports; return ports;
} }
int serial_open(const char *pathname, int flags) int serial_open(const char *pathname, int flags)
{ {
return open(pathname, flags); return open(pathname, flags);
} }
int serial_close(int fd) int serial_close(int fd)
{ {
return close(fd); return close(fd);
} }
void *serial_backup_params(int fd) void *serial_backup_params(int fd)
{ {
struct termios *term; struct termios *term;
@ -89,37 +79,33 @@ void *serial_backup_params(int fd)
return term; return term;
} }
void serial_restore_params(int fd, void *backup) 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 */ /* 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; struct termios term;
/* only supporting what we need really -- currently just the OLS driver */ /* Only supporting what we need really, currently the OLS driver. */
if(speed != 115200 || bits != 8 || parity != 0 || stopbits != 1 || flowcontrol != 2) if (speed != 115200 || bits != 8 || parity != 0 || stopbits != 1
|| flowcontrol != 2)
return SIGROK_ERR; return SIGROK_ERR;
if(tcgetattr(fd, &term) < 0) if (tcgetattr(fd, &term) < 0)
return SIGROK_ERR; return SIGROK_ERR;
if(cfsetispeed(&term, B115200) < 0) if (cfsetispeed(&term, B115200) < 0)
return SIGROK_ERR; return SIGROK_ERR;
term.c_cflag &= ~CSIZE; term.c_cflag &= ~CSIZE;
term.c_cflag |= CS8; term.c_cflag |= CS8;
term.c_cflag &= ~CSTOPB; term.c_cflag &= ~CSTOPB;
term.c_cflag |= IXON | IXOFF; term.c_cflag |= IXON | IXOFF;
term.c_iflag |= IGNPAR; term.c_iflag |= IGNPAR;
if(tcsetattr(fd, TCSADRAIN, &term) < 0) if (tcsetattr(fd, TCSADRAIN, &term) < 0)
return SIGROK_ERR; return SIGROK_ERR;
return SIGROK_OK; return SIGROK_OK;
} }

View File

@ -21,77 +21,53 @@
static int hw_init(char *deviceinfo) static int hw_init(char *deviceinfo)
{ {
} }
static int hw_opendev(int device_index) static int hw_opendev(int device_index)
{ {
} }
static void hw_closedev(int device_index) static void hw_closedev(int device_index)
{ {
} }
static void hw_cleanup(void) static void hw_cleanup(void)
{ {
} }
static char *hw_get_identifier(int device_index) static char *hw_get_identifier(int device_index)
{ {
} }
static char *hw_get_device_info(int device_index, int device_info_id) 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_status(int device_index)
{ {
} }
static int *hw_get_capabilities(void) static int *hw_get_capabilities(void)
{ {
} }
static int hw_set_configuration(int device_index, int capability, char *value) 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 int hw_start_acquisition(int device_index, gpointer session_device_id)
{ {
} }
static void hw_stop_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 = { struct device_plugin skeleton_plugin_info = {
"skeleton", "skeleton",
1, 1,
hw_init, hw_init,
hw_cleanup, hw_cleanup,
hw_opendev, hw_opendev,
hw_closedev, hw_closedev,
hw_get_device_info, hw_get_device_info,
@ -99,6 +75,5 @@ struct device_plugin skeleton_plugin_info = {
hw_get_capabilities, hw_get_capabilities,
hw_set_configuration, hw_set_configuration,
hw_start_acquisition, hw_start_acquisition,
hw_stop_acquisition hw_stop_acquisition,
}; };