harmonize coding style and messages; silence warnings; add more checks
This commit is contained in:
+16
-11
@@ -20,6 +20,7 @@
|
||||
#include "wirz-sli.h"
|
||||
//#include "drv_base.h"
|
||||
#include "report.h"
|
||||
#include "lcd_lib.h"
|
||||
|
||||
//#include "shared/debug.h"
|
||||
#include "shared/str.h"
|
||||
@@ -34,7 +35,7 @@ typedef enum {
|
||||
beat = 8
|
||||
} custom_type;
|
||||
|
||||
static int fd;
|
||||
static int fd = -1;
|
||||
static char *framebuf = NULL;
|
||||
static int width = 0;
|
||||
static int height = 0;
|
||||
@@ -66,6 +67,7 @@ sli_init (Driver *drvthis)
|
||||
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
|
||||
SLI_DEFAULT_DEVICE), sizeof(device));
|
||||
device[sizeof(device)-1] = '\0';
|
||||
report(RPT_INFO, "%s: using Device %s", drvthis->name, device);
|
||||
|
||||
/* What speed to use */
|
||||
speed = drvthis->config_get_int(drvthis->name, "Speed", 0, 19200);
|
||||
@@ -78,7 +80,8 @@ sli_init (Driver *drvthis)
|
||||
else if (speed == 57600) speed = B57600;
|
||||
else if (speed == 115200) speed = B115200;
|
||||
else {
|
||||
report(RPT_WARNING, "sli: Illegal speed: %d. Must be one of 1200, 2400, 9600, 19200, 38400, 57600, or 115200. Using default.\n", speed);
|
||||
report(RPT_WARNING, "%s: illegal Speed: %d; must be one of 1200, 2400, 9600, 19200, 38400, 57600, or 115200; using default %d",
|
||||
drvthis->name, speed);
|
||||
speed = B19200;
|
||||
}
|
||||
|
||||
@@ -87,10 +90,10 @@ sli_init (Driver *drvthis)
|
||||
// Set up io port correctly, and open it...
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1) {
|
||||
report(RPT_ERR, "sli_init: open(%s) failed (%s)\n", device, strerror (errno));
|
||||
report(RPT_ERR, "%s: open(%s) failed (%s)", drvthis->name, device, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
report(RPT_DEBUG, "sli_init: opened device %s\n", device);
|
||||
report(RPT_DEBUG, "%s: opened device %s", drvthis->name, device);
|
||||
|
||||
tcgetattr(fd, &portset);
|
||||
|
||||
@@ -134,7 +137,9 @@ sli_init (Driver *drvthis)
|
||||
width = 15;
|
||||
height = 2;
|
||||
|
||||
return fd;
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -143,11 +148,11 @@ sli_init (Driver *drvthis)
|
||||
MODULE_EXPORT void
|
||||
sli_close (Driver *drvthis)
|
||||
{
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
|
||||
if (framebuf)
|
||||
free(framebuf);
|
||||
|
||||
framebuf = NULL;
|
||||
}
|
||||
|
||||
@@ -220,8 +225,8 @@ sli_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
x--; // Convert 1-based coords to 0-based...
|
||||
y--;
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
// Check for buffer overflows...
|
||||
@@ -451,10 +456,9 @@ sli_set_char (Driver *drvthis, int n, char *dat)
|
||||
{
|
||||
char out[2];
|
||||
int row, col;
|
||||
int letter;
|
||||
|
||||
/* SLI also has 8 user definable characters */
|
||||
if (n < 0 || n > 7)
|
||||
if ((n < 0) || (n > 7))
|
||||
return;
|
||||
if (!dat)
|
||||
return;
|
||||
@@ -465,7 +469,8 @@ sli_set_char (Driver *drvthis, int n, char *dat)
|
||||
write(fd, out, 2);
|
||||
|
||||
for (row = 0; row < LCD_DEFAULT_CELLHEIGHT; row++) {
|
||||
letter = 0;
|
||||
int letter = 0;
|
||||
|
||||
for (col = 0; col < LCD_DEFAULT_CELLWIDTH; col++) {
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row * LCD_DEFAULT_CELLWIDTH) + col] > 0);
|
||||
|
||||
Reference in New Issue
Block a user