summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2011-04-15 09:10:11 +0200
committerDominik Brodowski <linux@dominikbrodowski.net>2011-04-15 09:10:11 +0200
commite97fdc7c0e12f54c7ac82495d1ad0f7e939854c9 (patch)
treea71aa3702144c24e92d362091d6a7e6e6ba7a36a
parent541ec60f449e814b2799ee3518c19b357d5fd8b3 (diff)
downloadpcmciautils-e97fdc7c0e12f54c7ac82495d1ad0f7e939854c9.tar.gz
src: coding style bugfixes
Also fix the remaining bison error messages. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r--src/cistpl.h350
-rw-r--r--src/lex_config.l6
-rw-r--r--src/pccardctl.c240
-rw-r--r--src/pcmcia-check-broken-cis.c52
-rw-r--r--src/read-cis.c23
-rw-r--r--src/startup.c90
-rw-r--r--src/startup.h36
-rw-r--r--src/yacc_config.y7
8 files changed, 429 insertions, 375 deletions
diff --git a/src/cistpl.h b/src/cistpl.h
index 79dd0a2..e324e3a 100644
--- a/src/cistpl.h
+++ b/src/cistpl.h
@@ -59,13 +59,13 @@
#define CISTPL_SPCL 0x90
typedef struct cistpl_longlink_t {
- unsigned int addr;
+ unsigned int addr;
} cistpl_longlink_t;
typedef struct cistpl_checksum_t {
- unsigned short addr;
- unsigned short len;
- unsigned char sum;
+ unsigned short addr;
+ unsigned short len;
+ unsigned char sum;
} cistpl_checksum_t;
#define CISTPL_MAX_FUNCTIONS 8
@@ -73,19 +73,19 @@ typedef struct cistpl_checksum_t {
#define CISTPL_MFC_COMMON 0x01
typedef struct cistpl_longlink_mfc_t {
- unsigned char nfn;
- struct {
- unsigned char space;
- unsigned int addr;
- } fn[CISTPL_MAX_FUNCTIONS];
+ unsigned char nfn;
+ struct {
+ unsigned char space;
+ unsigned int addr;
+ } fn[CISTPL_MAX_FUNCTIONS];
} cistpl_longlink_mfc_t;
#define CISTPL_MAX_ALTSTR_STRINGS 4
typedef struct cistpl_altstr_t {
- unsigned char ns;
- unsigned char ofs[CISTPL_MAX_ALTSTR_STRINGS];
- char str[254];
+ unsigned char ns;
+ unsigned char ofs[CISTPL_MAX_ALTSTR_STRINGS];
+ char str[254];
} cistpl_altstr_t;
#define CISTPL_DTYPE_NULL 0x00
@@ -102,44 +102,44 @@ typedef struct cistpl_altstr_t {
#define CISTPL_MAX_DEVICES 4
typedef struct cistpl_device_t {
- unsigned char ndev;
- struct {
- unsigned char type;
- unsigned char wp;
- unsigned int speed;
- unsigned int size;
- } dev[CISTPL_MAX_DEVICES];
+ unsigned char ndev;
+ struct {
+ unsigned char type;
+ unsigned char wp;
+ unsigned int speed;
+ unsigned int size;
+ } dev[CISTPL_MAX_DEVICES];
} cistpl_device_t;
#define CISTPL_DEVICE_MWAIT 0x01
#define CISTPL_DEVICE_3VCC 0x02
typedef struct cistpl_device_o_t {
- unsigned char flags;
- cistpl_device_t device;
+ unsigned char flags;
+ cistpl_device_t device;
} cistpl_device_o_t;
#define CISTPL_VERS_1_MAX_PROD_STRINGS 4
typedef struct cistpl_vers_1_t {
- unsigned char major;
- unsigned char minor;
- unsigned char ns;
- unsigned char ofs[CISTPL_VERS_1_MAX_PROD_STRINGS];
- char str[254];
+ unsigned char major;
+ unsigned char minor;
+ unsigned char ns;
+ unsigned char ofs[CISTPL_VERS_1_MAX_PROD_STRINGS];
+ char str[254];
} cistpl_vers_1_t;
typedef struct cistpl_jedec_t {
- unsigned char nid;
- struct {
- unsigned char mfr;
- unsigned char info;
- } id[CISTPL_MAX_DEVICES];
+ unsigned char nid;
+ struct {
+ unsigned char mfr;
+ unsigned char info;
+ } id[CISTPL_MAX_DEVICES];
} cistpl_jedec_t;
typedef struct cistpl_manfid_t {
- unsigned short manf;
- unsigned short card;
+ unsigned short manf;
+ unsigned short card;
} cistpl_manfid_t;
#define CISTPL_FUNCID_MULTI 0x00
@@ -156,13 +156,13 @@ typedef struct cistpl_manfid_t {
#define CISTPL_SYSINIT_ROM 0x02
typedef struct cistpl_funcid_t {
- unsigned char func;
- unsigned char sysinit;
+ unsigned char func;
+ unsigned char sysinit;
} cistpl_funcid_t;
typedef struct cistpl_funce_t {
- unsigned char type;
- unsigned char data[0];
+ unsigned char type;
+ unsigned char data[0];
} cistpl_funce_t;
/*======================================================================
@@ -205,16 +205,16 @@ typedef struct cistpl_funce_t {
#define CISTPL_SERIAL_UART_2STOP 0x40
typedef struct cistpl_serial_t {
- unsigned char uart_type;
- unsigned char uart_cap_0;
- unsigned char uart_cap_1;
+ unsigned char uart_type;
+ unsigned char uart_cap_0;
+ unsigned char uart_cap_1;
} cistpl_serial_t;
typedef struct cistpl_modem_cap_t {
- unsigned char flow;
- unsigned char cmd_buf;
- unsigned char rcv_buf_0, rcv_buf_1, rcv_buf_2;
- unsigned char xmit_buf_0, xmit_buf_1, xmit_buf_2;
+ unsigned char flow;
+ unsigned char cmd_buf;
+ unsigned char rcv_buf_0, rcv_buf_1, rcv_buf_2;
+ unsigned char xmit_buf_0, xmit_buf_1, xmit_buf_2;
} cistpl_modem_cap_t;
#define CISTPL_SERIAL_MOD_103 0x01
@@ -246,32 +246,32 @@ typedef struct cistpl_modem_cap_t {
#define CISTPL_SERIAL_CMD_DMCL 0x40
typedef struct cistpl_data_serv_t {
- unsigned char max_data_0;
- unsigned char max_data_1;
- unsigned char modulation_0;
- unsigned char modulation_1;
- unsigned char error_control;
- unsigned char compression;
- unsigned char cmd_protocol;
- unsigned char escape;
- unsigned char encrypt;
- unsigned char misc_features;
- unsigned char ccitt_code[0];
+ unsigned char max_data_0;
+ unsigned char max_data_1;
+ unsigned char modulation_0;
+ unsigned char modulation_1;
+ unsigned char error_control;
+ unsigned char compression;
+ unsigned char cmd_protocol;
+ unsigned char escape;
+ unsigned char encrypt;
+ unsigned char misc_features;
+ unsigned char ccitt_code[0];
} cistpl_data_serv_t;
typedef struct cistpl_fax_serv_t {
- unsigned char max_data_0;
- unsigned char max_data_1;
- unsigned char modulation;
- unsigned char encrypt;
- unsigned char features_0;
- unsigned char features_1;
- unsigned char ccitt_code[0];
+ unsigned char max_data_0;
+ unsigned char max_data_1;
+ unsigned char modulation;
+ unsigned char encrypt;
+ unsigned char features_0;
+ unsigned char features_1;
+ unsigned char ccitt_code[0];
} cistpl_fax_serv_t;
typedef struct cistpl_voice_serv_t {
- unsigned char max_data_0;
- unsigned char max_data_1;
+ unsigned char max_data_0;
+ unsigned char max_data_1;
} cistpl_voice_serv_t;
/*======================================================================
@@ -296,11 +296,11 @@ typedef struct cistpl_voice_serv_t {
#define CISTPL_LAN_TECH_WIRELESS 0x07
typedef struct cistpl_lan_tech_t {
- unsigned char tech;
+ unsigned char tech;
} cistpl_lan_tech_t;
typedef struct cistpl_lan_speed_t {
- unsigned int speed;
+ unsigned int speed;
} cistpl_lan_speed_t;
/* LAN media definitions */
@@ -316,16 +316,16 @@ typedef struct cistpl_lan_speed_t {
#define CISTPL_LAN_MEDIA_PTP_IR 0x0a
typedef struct cistpl_lan_media_t {
- unsigned char media;
+ unsigned char media;
} cistpl_lan_media_t;
typedef struct cistpl_lan_node_id_t {
- unsigned char nb;
- unsigned char id[16];
+ unsigned char nb;
+ unsigned char id[16];
} cistpl_lan_node_id_t;
typedef struct cistpl_lan_connector_t {
- unsigned char code;
+ unsigned char code;
} cistpl_lan_connector_t;
/*======================================================================
@@ -337,7 +337,7 @@ typedef struct cistpl_lan_connector_t {
#define CISTPL_IDE_INTERFACE 0x01
typedef struct cistpl_ide_interface_t {
- unsigned char interface;
+ unsigned char interface;
} cistpl_ide_interface_t;
/* First feature byte */
@@ -355,8 +355,8 @@ typedef struct cistpl_ide_interface_t {
#define CISTPL_IDE_IOIS16 0x40
typedef struct cistpl_ide_feature_t {
- unsigned char feature1;
- unsigned char feature2;
+ unsigned char feature1;
+ unsigned char feature2;
} cistpl_ide_feature_t;
#define CISTPL_FUNCE_IDE_IFACE 0x01
@@ -376,15 +376,15 @@ typedef struct cistpl_ide_feature_t {
#define CISTPL_BAR_1MEG_MAP 0x80
typedef struct cistpl_bar_t {
- unsigned char attr;
- unsigned int size;
+ unsigned char attr;
+ unsigned int size;
} cistpl_bar_t;
typedef struct cistpl_config_t {
- unsigned char last_idx;
- unsigned int base;
- unsigned int rmask[4];
- unsigned char subtuples;
+ unsigned char last_idx;
+ unsigned int base;
+ unsigned int rmask[4];
+ unsigned char subtuples;
} cistpl_config_t;
/* These are bits in the 'present' field, and indices in 'param' */
@@ -400,15 +400,15 @@ typedef struct cistpl_config_t {
#define CISTPL_POWER_HIGHZ_REQ 0x02
typedef struct cistpl_power_t {
- unsigned char present;
- unsigned char flags;
- unsigned int param[7];
+ unsigned char present;
+ unsigned char flags;
+ unsigned int param[7];
} cistpl_power_t;
typedef struct cistpl_timing_t {
- unsigned int wait, waitscale;
- unsigned int ready, rdyscale;
- unsigned int reserved, rsvscale;
+ unsigned int wait, waitscale;
+ unsigned int ready, rdyscale;
+ unsigned int reserved, rsvscale;
} cistpl_timing_t;
#define CISTPL_IO_LINES_MASK 0x1f
@@ -419,29 +419,29 @@ typedef struct cistpl_timing_t {
#define CISTPL_IO_MAX_WIN 16
typedef struct cistpl_io_t {
- unsigned char flags;
- unsigned char nwin;
- struct {
- unsigned int base;
- unsigned int len;
- } win[CISTPL_IO_MAX_WIN];
+ unsigned char flags;
+ unsigned char nwin;
+ struct {
+ unsigned int base;
+ unsigned int len;
+ } win[CISTPL_IO_MAX_WIN];
} cistpl_io_t;
typedef struct cistpl_irq_t {
- unsigned int IRQInfo1;
- unsigned int IRQInfo2;
+ unsigned int IRQInfo1;
+ unsigned int IRQInfo2;
} cistpl_irq_t;
#define CISTPL_MEM_MAX_WIN 8
typedef struct cistpl_mem_t {
- unsigned char flags;
- unsigned char nwin;
- struct {
- unsigned int len;
- unsigned int card_addr;
- unsigned int host_addr;
- } win[CISTPL_MEM_MAX_WIN];
+ unsigned char flags;
+ unsigned char nwin;
+ struct {
+ unsigned int len;
+ unsigned int card_addr;
+ unsigned int host_addr;
+ } win[CISTPL_MEM_MAX_WIN];
} cistpl_mem_t;
#define CISTPL_CFTABLE_DEFAULT 0x0001
@@ -454,15 +454,15 @@ typedef struct cistpl_mem_t {
#define CISTPL_CFTABLE_PWRDOWN 0x2000
typedef struct cistpl_cftable_entry_t {
- unsigned char index;
- unsigned short flags;
- unsigned char interface;
- cistpl_power_t vcc, vpp1, vpp2;
- cistpl_timing_t timing;
- cistpl_io_t io;
- cistpl_irq_t irq;
- cistpl_mem_t mem;
- unsigned char subtuples;
+ unsigned char index;
+ unsigned short flags;
+ unsigned char interface;
+ cistpl_power_t vcc, vpp1, vpp2;
+ cistpl_timing_t timing;
+ cistpl_io_t io;
+ cistpl_irq_t irq;
+ cistpl_mem_t mem;
+ unsigned char subtuples;
} cistpl_cftable_entry_t;
#define CISTPL_CFTABLE_MASTER 0x000100
@@ -476,40 +476,40 @@ typedef struct cistpl_cftable_entry_t {
#define CISTPL_CFTABLE_PWM_AUDIO 0x020000
typedef struct cistpl_cftable_entry_cb_t {
- unsigned char index;
- unsigned int flags;
- cistpl_power_t vcc, vpp1, vpp2;
- unsigned char io;
- cistpl_irq_t irq;
- unsigned char mem;
- unsigned char subtuples;
+ unsigned char index;
+ unsigned int flags;
+ cistpl_power_t vcc, vpp1, vpp2;
+ unsigned char io;
+ cistpl_irq_t irq;
+ unsigned char mem;
+ unsigned char subtuples;
} cistpl_cftable_entry_cb_t;
typedef struct cistpl_device_geo_t {
- unsigned char ngeo;
- struct {
- unsigned char buswidth;
- unsigned int erase_block;
- unsigned int read_block;
- unsigned int write_block;
- unsigned int partition;
- unsigned int interleave;
- } geo[CISTPL_MAX_DEVICES];
+ unsigned char ngeo;
+ struct {
+ unsigned char buswidth;
+ unsigned int erase_block;
+ unsigned int read_block;
+ unsigned int write_block;
+ unsigned int partition;
+ unsigned int interleave;
+ } geo[CISTPL_MAX_DEVICES];
} cistpl_device_geo_t;
typedef struct cistpl_vers_2_t {
- unsigned char vers;
- unsigned char comply;
- unsigned short dindex;
- unsigned char vspec8, vspec9;
- unsigned char nhdr;
- unsigned char vendor, info;
- char str[244];
+ unsigned char vers;
+ unsigned char comply;
+ unsigned short dindex;
+ unsigned char vspec8, vspec9;
+ unsigned char nhdr;
+ unsigned char vendor, info;
+ char str[244];
} cistpl_vers_2_t;
typedef struct cistpl_org_t {
- unsigned char data_org;
- char desc[30];
+ unsigned char data_org;
+ char desc[30];
} cistpl_org_t;
#define CISTPL_ORG_FS 0x00
@@ -517,10 +517,10 @@ typedef struct cistpl_org_t {
#define CISTPL_ORG_XIP 0x02
typedef struct cistpl_format_t {
- unsigned char type;
- unsigned char edc;
- unsigned int offset;
- unsigned int length;
+ unsigned char type;
+ unsigned char edc;
+ unsigned int offset;
+ unsigned int length;
} cistpl_format_t;
#define CISTPL_FORMAT_DISK 0x00
@@ -532,45 +532,45 @@ typedef struct cistpl_format_t {
#define CISTPL_EDC_PCC 0x03
typedef union cisparse_t {
- cistpl_device_t device;
- cistpl_checksum_t checksum;
- cistpl_longlink_t longlink;
- cistpl_longlink_mfc_t longlink_mfc;
- cistpl_vers_1_t version_1;
- cistpl_altstr_t altstr;
- cistpl_jedec_t jedec;
- cistpl_manfid_t manfid;
- cistpl_funcid_t funcid;
- cistpl_funce_t funce;
- cistpl_bar_t bar;
- cistpl_config_t config;
- cistpl_cftable_entry_t cftable_entry;
- cistpl_cftable_entry_cb_t cftable_entry_cb;
- cistpl_device_geo_t device_geo;
- cistpl_vers_2_t vers_2;
- cistpl_org_t org;
- cistpl_format_t format;
+ cistpl_device_t device;
+ cistpl_checksum_t checksum;
+ cistpl_longlink_t longlink;
+ cistpl_longlink_mfc_t longlink_mfc;
+ cistpl_vers_1_t version_1;
+ cistpl_altstr_t altstr;
+ cistpl_jedec_t jedec;
+ cistpl_manfid_t manfid;
+ cistpl_funcid_t funcid;
+ cistpl_funce_t funce;
+ cistpl_bar_t bar;
+ cistpl_config_t config;
+ cistpl_cftable_entry_t cftable_entry;
+ cistpl_cftable_entry_cb_t cftable_entry_cb;
+ cistpl_device_geo_t device_geo;
+ cistpl_vers_2_t vers_2;
+ cistpl_org_t org;
+ cistpl_format_t format;
} cisparse_t;
typedef struct tuple_flags {
- unsigned int link_space:4;
- unsigned int has_link:1;
- unsigned int mfc_fn:3;
- unsigned int space:4;
+ unsigned int link_space:4;
+ unsigned int has_link:1;
+ unsigned int mfc_fn:3;
+ unsigned int space:4;
} tuple_flags;
typedef struct tuple_t {
- unsigned int Attributes;
- unsigned char DesiredTuple;
- tuple_flags Flags; /* internal use */
- unsigned int LinkOffset; /* internal use */
- unsigned int CISOffset; /* internal use */
- unsigned char TupleCode;
- unsigned char TupleLink;
- unsigned char TupleOffset;
- unsigned char TupleDataMax;
- unsigned char TupleDataLen;
- unsigned char *TupleData;
+ unsigned int Attributes;
+ unsigned char DesiredTuple;
+ tuple_flags Flags; /* internal use */
+ unsigned int LinkOffset; /* internal use */
+ unsigned int CISOffset; /* internal use */
+ unsigned char TupleCode;
+ unsigned char TupleLink;
+ unsigned char TupleOffset;
+ unsigned char TupleDataMax;
+ unsigned char TupleDataLen;
+ unsigned char *TupleData;
} tuple_t;
/* Special unsigned char value */
@@ -582,20 +582,20 @@ typedef struct tuple_t {
/* For ValidateCIS */
typedef struct cisinfo_t {
- unsigned int Chains;
+ unsigned int Chains;
} cisinfo_t;
#define CISTPL_MAX_CIS_SIZE 0x200
/* For ReplaceCIS */
typedef struct cisdump_t {
- unsigned int Length;
- unsigned char Data[CISTPL_MAX_CIS_SIZE];
+ unsigned int Length;
+ unsigned char Data[CISTPL_MAX_CIS_SIZE];
} cisdump_t;
#define BIND_FN_ALL 0xff
-int read_out_cis (unsigned int socket_no, FILE *fd);
+int read_out_cis(unsigned int socket_no, FILE *fd);
int pcmcia_get_first_tuple(unsigned int function, tuple_t *tuple);
int pcmcia_get_next_tuple(unsigned int function, tuple_t *tuple);
int pcmcia_get_tuple_data(tuple_t *tuple);
diff --git a/src/lex_config.l b/src/lex_config.l
index 7b4d627..649245b 100644
--- a/src/lex_config.l
+++ b/src/lex_config.l
@@ -37,6 +37,8 @@
char *current_file;
int current_lineno;
+int yyparse(void);
+
static int lex_number(char *s);
static int lex_string(char *s);
static void do_source(char *fn);
@@ -128,7 +130,7 @@ static int get_glob(void)
while (s->fileno < s->word.we_wordc) {
char *fn = s->word.we_wordv[s->fileno];
#else
- while (s->fileno < s->glob.gl_pathc) {
+ while (s->fileno < (signed int) s->glob.gl_pathc) {
char *fn = s->glob.gl_pathv[s->fileno];
#endif
s->file = fopen(fn, "r");
@@ -204,7 +206,7 @@ static int do_eof(void)
int parse_configfile(char *fn)
{
FILE *f;
-
+
f = fopen(fn, "r");
if (!f) {
syslog(LOG_ERR, "could not open '%s': %m", fn);
diff --git a/src/pccardctl.c b/src/pccardctl.c
index a59aff9..05cb3a0 100644
--- a/src/pccardctl.c
+++ b/src/pccardctl.c
@@ -56,41 +56,42 @@ static int pccardctl_power_socket(unsigned long socket_no, unsigned int power)
{
int ret;
char file[SYSFS_PATH_MAX];
- struct sysfs_attribute *attr;
+ struct sysfs_attribute *attr;
snprintf(file, SYSFS_PATH_MAX,
"/sys/class/pcmcia_socket/pcmcia_socket%lu/card_pm_state",
socket_no);
- attr = sysfs_open_attribute(file);
- if (!attr)
- return -ENODEV;
+ attr = sysfs_open_attribute(file);
+ if (!attr)
+ return -ENODEV;
- ret = sysfs_write_attribute(attr, power ? "off" : "on", power ? 3 : 2);
+ ret = sysfs_write_attribute(attr, power ? "off" : "on", power ? 3 : 2);
- sysfs_close_attribute(attr);
+ sysfs_close_attribute(attr);
- return (ret);
+ return ret;
}
static int pccardctl_echo_one(unsigned long socket_no, const char *in_file)
{
- int ret;
- char file[SYSFS_PATH_MAX];
- struct sysfs_attribute *attr;
+ int ret;
+ char file[SYSFS_PATH_MAX];
+ struct sysfs_attribute *attr;
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/%s",
- socket_no, in_file);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu/%s",
+ socket_no, in_file);
- attr = sysfs_open_attribute(file);
- if (!attr)
- return -ENODEV;
+ attr = sysfs_open_attribute(file);
+ if (!attr)
+ return -ENODEV;
- ret = sysfs_write_attribute(attr, "42", 2);
+ ret = sysfs_write_attribute(attr, "42", 2);
- sysfs_close_attribute(attr);
+ sysfs_close_attribute(attr);
- return (ret);
+ return ret;
}
static int pccardctl_socket_exists(unsigned long socket_no)
@@ -101,10 +102,10 @@ static int pccardctl_socket_exists(unsigned long socket_no)
"/sys/class/pcmcia_socket/pcmcia_socket%lu/card_insert",
socket_no);
- return (!(sysfs_path_is_file(file)));
+ return !(sysfs_path_is_file(file));
}
-static int read_out_file(char * file, char **output)
+static int read_out_file(char *file, char **output)
{
struct sysfs_attribute *attr = sysfs_open_attribute(file);
int ret;
@@ -134,17 +135,20 @@ static int read_out_file(char * file, char **output)
return ret;
}
-static int pccardctl_get_string_socket(unsigned long socket_no, const char *in_file, char **output)
+static int pccardctl_get_string_socket(unsigned long socket_no,
+ const char *in_file, char **output)
{
char file[SYSFS_PATH_MAX];
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/%s",
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu/%s",
socket_no, in_file);
return read_out_file(file, output);
}
-static int pccardctl_get_string(unsigned long socket_no, const char *in_file, char **output)
+static int pccardctl_get_string(unsigned long socket_no,
+ const char *in_file, char **output)
{
char file[SYSFS_PATH_MAX];
@@ -154,7 +158,8 @@ static int pccardctl_get_string(unsigned long socket_no, const char *in_file, ch
return read_out_file(file, output);
}
-static int pccardctl_get_one_f(unsigned long socket_no, unsigned int dev, const char *in_file, unsigned int *result)
+static int pccardctl_get_one_f(unsigned long socket_no, unsigned int dev,
+ const char *in_file, unsigned int *result)
{
char *value;
char file[SYSFS_PATH_MAX];
@@ -171,17 +176,20 @@ static int pccardctl_get_one_f(unsigned long socket_no, unsigned int dev, const
return 0;
}
-static int pccardctl_get_one(unsigned long socket_no, const char *in_file, unsigned int *result)
+static int pccardctl_get_one(unsigned long socket_no, const char *in_file,
+ unsigned int *result)
{
return pccardctl_get_one_f(socket_no, 0, in_file, result);
}
-static int pccardctl_get_power_device(unsigned long socket_no, unsigned int func)
+static int pccardctl_get_power_device(unsigned long socket_no,
+ unsigned int func)
{
- char * value;
+ char *value;
char file[SYSFS_PATH_MAX];
- snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.%u/pm_state",
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/bus/pcmcia/devices/%lu.%u/pm_state",
socket_no, func);
read_out_file(file, &value);
if (value) {
@@ -195,10 +203,11 @@ static int pccardctl_get_power_device(unsigned long socket_no, unsigned int func
static int pccardctl_get_power_socket(unsigned long socket_no)
{
- char * value;
+ char *value;
char file[SYSFS_PATH_MAX];
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/card_pm_state",
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu/card_pm_state",
socket_no);
read_out_file(file, &value);
if (value) {
@@ -221,7 +230,7 @@ static int pccardctl_ident(unsigned long socket_no)
if (!pccardctl_socket_exists(socket_no))
return -ENODEV;
- for (i=1; i<=4; i++) {
+ for (i = 1; i <= 4; i++) {
char file[SYSFS_PATH_MAX];
snprintf(file, SYSFS_PATH_MAX, "prod_id%u", i);
@@ -232,9 +241,9 @@ static int pccardctl_ident(unsigned long socket_no)
if (valid_prod_id) {
printf(" product info: ");
- for (i=0;i<4;i++) {
- printf("%s\"%s\"", (i>0) ? ", " : "",
- prod_id[i] ? prod_id[i] : "" );
+ for (i = 0; i < 4; i++) {
+ printf("%s\"%s\"", (i > 0) ? ", " : "",
+ prod_id[i] ? prod_id[i] : "");
if (prod_id[i])
free(prod_id[i]);
}
@@ -266,7 +275,7 @@ static int pccardctl_info(unsigned long socket_no)
if (!pccardctl_socket_exists(socket_no))
return -ENODEV;
- for (i=1; i<=4; i++) {
+ for (i = 1; i <= 4; i++) {
char file[SYSFS_PATH_MAX];
snprintf(file, SYSFS_PATH_MAX, "prod_id%u", i);
@@ -279,11 +288,14 @@ static int pccardctl_info(unsigned long socket_no)
}
printf("MANFID=%04x,%04x\n",
- (!pccardctl_get_one(socket_no, "manf_id", &manf_id)) ? manf_id : 0,
- (!pccardctl_get_one(socket_no, "card_id", &card_id)) ? card_id : 0);
+ (!pccardctl_get_one(socket_no, "manf_id",
+ &manf_id)) ? manf_id : 0,
+ (!pccardctl_get_one(socket_no, "card_id",
+ &card_id)) ? card_id : 0);
printf("FUNCID=%d\n",
- (!pccardctl_get_one(socket_no, "func_id", &func_id)) ? func_id : 255);
+ (!pccardctl_get_one(socket_no, "func_id",
+ &func_id)) ? func_id : 255);
return 0;
}
@@ -309,19 +321,18 @@ static int pccardctl_status(unsigned long socket_no)
strncmp(card_type, "16", 2) ? is_cardbus = 0 : 1;
- printf(" %s %s %s", card_voltage, card_type, is_cardbus ? "CardBus card" : "PC Card");
+ printf(" %s %s %s", card_voltage, card_type, is_cardbus ?
+ "CardBus card" : "PC Card");
susp = pccardctl_get_power_socket(socket_no);
if (susp > 0)
printf(" [suspended]");
printf("\n");
- if (is_cardbus) {
- /* FIXME: handle functions */
+ if (is_cardbus)
return 0;
- }
- for (i=0; i<4; i++) {
+ for (i = 0; i < 4; i++) {
int function;
char drv[SYSFS_PATH_MAX];
char file[SYSFS_PATH_MAX];
@@ -330,13 +341,14 @@ static int pccardctl_status(unsigned long socket_no)
printf(" Subdevice %u (function %u)", i, function);
- snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.%u/driver",
- socket_no, i);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/bus/pcmcia/devices/%lu.%u/driver",
+ socket_no, i);
ret = readlink(file, drv, sizeof(drv) - 1);
if (ret <= 0)
printf(" [unbound]");
else if (ret > 0) {
- drv[ret]='\0';
+ drv[ret] = '\0';
printf(" bound to driver \"%s\"", basename(drv));
}
@@ -350,10 +362,13 @@ static int pccardctl_status(unsigned long socket_no)
return 0;
}
-static void print_header(void) {
+static void print_header(void)
+{
printf("pcmciautils %s\n", PCMCIAUTILS_VERSION);
- printf("Copyright (C) 2004-2005 Dominik Brodowski, (C) 1999 David A. Hinds\n");
- printf("Report errors and bugs to <linux-pcmcia@lists.infradead.org>, please.\n");
+ printf("Copyright (C) 2004-2005 Dominik Brodowski, "
+ "(C) 1999 David A. Hinds\n");
+ printf("Report errors and bugs to <linux-pcmcia@lists.infradead.org>,"
+ "please.\n");
}
static char *cmdname[] = {
@@ -369,40 +384,42 @@ static char *cmdname[] = {
"ident",
};
-static void print_help(void) {
+static void print_help(void)
+{
unsigned int i;
printf("Usage: pccardctl COMMAND\n");
printf("Supported commands are:\n");
- for (i = 0; i < sizeof(cmdname)/sizeof(cmdname[0]); i++) {
+ for (i = 0; i < sizeof(cmdname)/sizeof(cmdname[0]); i++)
printf("\t%s\n", cmdname[i]);
- }
}
-static void print_unknown_arg(void) {
+static void print_unknown_arg(void)
+{
print_header();
printf("invalid or unknown argument\n");
print_help();
}
static struct option pccardctl_opts[] = {
- { .name="version", .has_arg=no_argument, .flag=NULL, .val='V'},
- { .name="help", .has_arg=no_argument, .flag=NULL, .val='h'},
- { .name="verbose", .has_arg=no_argument, .flag=NULL, .val='v'},
-// { .name="socket", .has_arg=required_argument, .flag=NULL, .val='s'},
-// { .name="socketdir", .has_arg=required_argument, .flag=NULL, .val='d'},
+ { .name = "version", .has_arg = no_argument, .flag = NULL, .val = 'V'},
+ { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
+ { .name = "verbose", .has_arg = no_argument, .flag = NULL, .val = 'v'},
{ 0, 0, 0, 0 }
};
-static void lspcmcia_socket_available_resources(unsigned long socket_no, char *which) {
+static void lspcmcia_socket_available_resources(unsigned long socket_no,
+ char *which)
+{
char file[SYSFS_PATH_MAX];
struct sysfs_attribute *attr;
int ret, length, first = 0;
char *sep;
char *result = NULL;
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/available_resources_%s",
- socket_no, which);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu/available_resources_%s",
+ socket_no, which);
attr = sysfs_open_attribute(file);
if (!attr)
@@ -436,7 +453,7 @@ static void lspcmcia_socket_available_resources(unsigned long socket_no, char *w
break;
memcpy(file, &result[ret], length);
file[length] = '\0';
- printf("%s\n\t\t\t\t\t\t",file);
+ printf("%s\n\t\t\t\t\t\t", file);
first++;
ret += length + 1;
}
@@ -453,32 +470,37 @@ static void lspcmcia_socket_available_resources(unsigned long socket_no, char *w
return;
}
-static void lspcmcia_socket(unsigned long socket_no, int verbose, char *driver) {
+static void lspcmcia_socket(unsigned long socket_no, int verbose, char *driver)
+{
char *card_voltage, *card_vpp, *card_vcc, *ready;
int pm_state;
pm_state = pccardctl_get_power_socket(socket_no);
- pccardctl_get_string_socket(socket_no, "available_resources_setup_done", &ready);
+ pccardctl_get_string_socket(socket_no,
+ "available_resources_setup_done", &ready);
- printf("\tConfiguration:\tstate: %s\tready: %s\n", pm_state ? "suspended" : "on", ready ? ready : "unknown");
+ printf("\tConfiguration:\tstate: %s\tready: %s\n",
+ pm_state ? "suspended" : "on", ready ? ready : "unknown");
pccardctl_get_string_socket(socket_no, "card_voltage", &card_voltage);
pccardctl_get_string_socket(socket_no, "card_vpp", &card_vpp);
pccardctl_get_string_socket(socket_no, "card_vcc", &card_vcc);
if (card_voltage && card_vpp && card_vcc)
- printf("\t\t\tVoltage: %s Vcc: %s Vpp: %s\n", card_voltage, card_vcc, card_vpp);
+ printf("\t\t\tVoltage: %s Vcc: %s Vpp: %s\n",
+ card_voltage, card_vcc, card_vpp);
if (verbose > 1) {
char *irq_mask_s;
int i, irqs = 0;
unsigned int irq_mask;
- pccardctl_get_string_socket(socket_no, "card_irq_mask", &irq_mask_s);
+ pccardctl_get_string_socket(socket_no, "card_irq_mask",
+ &irq_mask_s);
if (irq_mask_s && sscanf(irq_mask_s, "0x%X", &irq_mask) == 1) {
printf("\t\t\tAvailable IRQs: ");
- for (i=0;i<32;i++) {
- if (!(irq_mask & (1 <<i)))
+ for (i = 0; i < 32; i++) {
+ if (!(irq_mask & (1 << i)))
continue;
if (irqs)
printf(", ");
@@ -496,7 +518,8 @@ static void lspcmcia_socket(unsigned long socket_no, int verbose, char *driver)
return;
}
-static void lspcmcia_device_resources(unsigned long socket_no, int fun) {
+static void lspcmcia_device_resources(unsigned long socket_no, int fun)
+{
char file[SYSFS_PATH_MAX];
struct sysfs_attribute *attr;
int ret, length;
@@ -536,7 +559,7 @@ static void lspcmcia_device_resources(unsigned long socket_no, int fun) {
break;
memcpy(file, &result[ret], length);
file[length] = '\0';
- printf("%s\n\t\t\t",file);
+ printf("%s\n\t\t\t", file);
ret += length + 1;
}
} while (sep);
@@ -561,32 +584,39 @@ static int lspcmcia(unsigned long socket_no, int verbose)
if (!pccardctl_socket_exists(socket_no))
return -ENODEV;
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/device", socket_no);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu/device", socket_no);
ret = readlink(file, dev_s, sizeof(dev_s) - 1);
if (ret > 0) {
- dev_s[ret]='\0';
+ dev_s[ret] = '\0';
dev = basename(dev_s);
} else {
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu", socket_no);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu", socket_no);
ret = readlink(file, dev_s, sizeof(dev_s) - 1);
if (ret <= 0)
return -ENODEV;
- dev_s[ret]='\0';
+ dev_s[ret] = '\0';
dev = basename(dirname(dev_s));
}
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/device/driver", socket_no);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu/device/driver",
+ socket_no);
ret = readlink(file, drv_s, sizeof(drv_s) - 1);
if (ret <= 0) {
- snprintf(file, SYSFS_PATH_MAX, "/sys/class/pcmcia_socket/pcmcia_socket%lu/../driver", socket_no);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/class/pcmcia_socket/pcmcia_socket%lu/../driver",
+ socket_no);
ret = readlink(file, drv_s, sizeof(drv_s) - 1);
if (ret <= 0)
return -ENODEV;
}
- drv_s[ret]='\0';
+ drv_s[ret] = '\0';
drv = basename(drv_s);
- printf("Socket %lu Bridge: \t[%s] \t(bus ID: %s)\n", socket_no, drv, dev);
+ printf("Socket %lu Bridge: \t[%s] \t(bus ID: %s)\n",
+ socket_no, drv, dev);
if (verbose)
lspcmcia_socket(socket_no, verbose, drv);
@@ -596,11 +626,12 @@ static int lspcmcia(unsigned long socket_no, int verbose)
return 0;
if (!strncmp(res, "32", 2)) {
- printf(" CardBus card -- see \"lspci\" for more information\n");
+ printf(" CardBus card -- see \"lspci\" "
+ "for more information\n");
return 0;
}
- for (i=0; i<4; i++) {
+ for (i = 0; i < 4; i++) {
int function;
if (pccardctl_get_one_f(socket_no, i, "function", &function))
@@ -608,13 +639,14 @@ static int lspcmcia(unsigned long socket_no, int verbose)
printf("Socket %lu Device %d:\t", socket_no, i);
- snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.%u/driver",
- socket_no, i);
+ snprintf(file, SYSFS_PATH_MAX,
+ "/sys/bus/pcmcia/devices/%lu.%u/driver",
+ socket_no, i);
ret = readlink(file, drv_s, sizeof(drv_s) - 1);
if (ret <= 0)
printf("[-- no driver --]\t");
else if (ret > 0) {
- drv_s[ret]='\0';
+ drv_s[ret] = '\0';
printf("[%s]\t\t", basename(drv_s));
}
printf("(bus ID: %lu.%d)\n", socket_no, i);
@@ -624,11 +656,12 @@ static int lspcmcia(unsigned long socket_no, int verbose)
unsigned int manf_id, card_id;
int pm_state = pccardctl_get_power_device(socket_no, i);
- printf("\tConfiguration:\tstate: %s\n", pm_state ? "suspended" : "on");
+ printf("\tConfiguration:\tstate: %s\n",
+ pm_state ? "suspended" : "on");
lspcmcia_device_resources(socket_no, i);
printf("\tProduct Name: ");
- for (j=1;j<=4;j++) {
+ for (j = 1; j <= 4; j++) {
snprintf(file, SYSFS_PATH_MAX, "prod_id%d", j);
pccardctl_get_string(socket_no, file, &res);
if (res)
@@ -638,22 +671,28 @@ static int lspcmcia(unsigned long socket_no, int verbose)
printf("\tIdentification:\t");
if (!pccardctl_get_one(socket_no, "manf_id", &manf_id))
- if (!pccardctl_get_one(socket_no, "card_id", &card_id))
- printf("manf_id: 0x%04x\tcard_id: 0x%04x\n\t\t\t", manf_id, card_id);
- if (!pccardctl_get_one(socket_no, "func_id", &manf_id)) {
+ if (!pccardctl_get_one(socket_no, "card_id",
+ &card_id))
+ printf("manf_id: 0x%04x\t"
+ "card_id: 0x%04x\n\t\t\t",
+ manf_id, card_id);
+ if (!pccardctl_get_one(socket_no, "func_id",
+ &manf_id)) {
const char *s = "unknown";
if (manf_id < sizeof(fn)/sizeof(*fn))
s = fn[manf_id];
printf("function: %d (%s)\n\t\t\t", manf_id, s);
}
- for (j=1;j<=4;j++) {
+ for (j = 1; j <= 4; j++) {
snprintf(file, SYSFS_PATH_MAX, "prod_id%d", j);
pccardctl_get_string(socket_no, file, &res);
if (res)
- printf("prod_id(%u): \"%s\" (0x%08x)\n", j, res, crc32(res, strlen(res)));
+ printf("prod_id(%u): \"%s\" "
+ "(0x%08x)\n", j, res,
+ crc32(res, strlen(res)));
else
printf("prod_id(%u): --- (---)\n", j);
- if (j<4)
+ if (j < 4)
printf("\t\t\t");
}
}
@@ -677,7 +716,8 @@ enum {
};
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
extern char *optarg;
extern int optind, opterr, optopt;
int ret = 0;
@@ -689,7 +729,8 @@ int main(int argc, char **argv) {
unsigned int cmd;
do {
- ret = getopt_long(argc, argv, "Vhvc:f:s:", pccardctl_opts, NULL);
+ ret = getopt_long(argc, argv, "Vhvc:f:s:",
+ pccardctl_opts, NULL);
switch (ret) {
case -1:
cont = 0;
@@ -739,7 +780,8 @@ int main(int argc, char **argv) {
if (argc == optind+2) {
socket_is_set = 1;
socket = strtol(argv[optind+1], &s, 0);
- if ((*argv[optind+1] == '\0') || (*s != '\0') || (socket >= MAX_SOCKET)) {
+ if ((*argv[optind+1] == '\0') || (*s != '\0') ||
+ (socket >= MAX_SOCKET)) {
print_unknown_arg();
return -EINVAL;
}
@@ -778,7 +820,7 @@ int main(int argc, char **argv) {
case PCCARDCTL_RESET:
ret = pccardctl_power_socket(cont, 1);
if (ret && socket_is_set)
- return (ret);
+ return ret;
/* fall through */
case PCCARDCTL_RESUME:
ret = pccardctl_power_socket(cont, 0);
@@ -787,12 +829,14 @@ int main(int argc, char **argv) {
ret = pccardctl_status(cont);
break;
default:
- fprintf(stderr, "command '%s' not yet handled by pccardctl\n", cmdname[cmd]);
+ fprintf(stderr,
+ "command '%s' not yet handled by pccardctl\n",
+ cmdname[cmd]);
return -EAGAIN;
}
if (ret && socket_is_set)
- return (ret);
+ return ret;
}
return 0;
diff --git a/src/pcmcia-check-broken-cis.c b/src/pcmcia-check-broken-cis.c
index dd65b1c..aec1f67 100644
--- a/src/pcmcia-check-broken-cis.c
+++ b/src/pcmcia-check-broken-cis.c
@@ -50,33 +50,35 @@ static const struct needs_cis cis_table[] = {
{ },
};
-int device_has_driver() {
+static int device_has_driver()
+{
char *devpath, *path;
struct stat sbuf;
devpath = getenv("DEVPATH");
if (!devpath)
- return ENODEV;
- path = alloca(strlen(devpath)+15);
- sprintf(path,"/sys/%s/driver", devpath);
- if (!stat(path,&sbuf)) {
+ return -ENODEV;
+ path = alloca(strlen(devpath) + 15);
+ sprintf(path, "/sys/%s/driver", devpath);
+ if (!stat(path, &sbuf))
return 1;
- }
+
return 0;
}
-char *read_cis(char *cis_file, int *size) {
+static char *read_cis(char *cis_file, int *size)
+{
char *cis_path;
char *ret;
int rc, cis_fd;
struct stat sbuf;
cis_path = alloca(strlen(FIRMWARE_PATH) + strlen(cis_file) + 2);
- sprintf(cis_path,"%s/%s", FIRMWARE_PATH, cis_file);
+ sprintf(cis_path, "%s/%s", FIRMWARE_PATH, cis_file);
cis_fd = open(cis_path, O_RDONLY);
if (cis_fd == -1) {
cis_path = alloca(strlen(CIS_PATH) + strlen(cis_file) + 2);
- sprintf(cis_path,"%s/%s", CIS_PATH, cis_file);
+ sprintf(cis_path, "%s/%s", CIS_PATH, cis_file);
if (cis_fd == -1) {
rc = errno;
errno = rc;
@@ -103,17 +105,17 @@ char *read_cis(char *cis_file, int *size) {
return ret;
}
-int write_cis(char *cis, int socket_no, int size) {
+static int write_cis(char *cis, int socket_no, int size)
+{
char *cis_path;
int cis_fd, count, rc;
cis_path = alloca(strlen(SOCKET_PATH) + 2);
- sprintf(cis_path,SOCKET_PATH, socket_no);
+ sprintf(cis_path, SOCKET_PATH, socket_no);
cis_fd = open(cis_path, O_RDWR);
- if (cis_fd == -1) {
+ if (cis_fd == -1)
return errno;
- }
count = 0;
while (count < size) {
@@ -131,13 +133,13 @@ int write_cis(char *cis, int socket_no, int size) {
return 0;
}
-int repair_cis(char *cis_file, int socket_no) {
+static int repair_cis(char *cis_file, int socket_no)
+{
char *cis;
int rc, size;
- if (device_has_driver()) {
+ if (device_has_driver())
return 0;
- }
cis = read_cis(cis_file, &size);
if (!cis)
@@ -148,7 +150,8 @@ int repair_cis(char *cis_file, int socket_no) {
return rc;
}
-static void usage(const char *progname) {
+static void usage(const char *progname)
+{
fprintf(stderr,
"Usage: %s [-r|--repair] <socketname>\n", progname);
exit(1);
@@ -157,11 +160,12 @@ static void usage(const char *progname) {
static struct option options[] = { { "repair", 0, NULL, 'r' },
{ NULL, 0, NULL, 0 } };
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int ret;
char *socket;
unsigned int socket_no;
- const struct needs_cis * entry = NULL;
+ const struct needs_cis *entry = NULL;
tuple_t tuple;
unsigned char buf[256];
int opt;
@@ -176,9 +180,11 @@ int main(int argc, char **argv) {
usage(argv[0]);
}
}
- if ((socket = getenv("SOCKET_NO"))) {
- socket_no = (unsigned int)strtoul(socket, NULL, 0);
- } else {
+
+ socket = getenv("SOCKET_NO");
+ if (socket)
+ socket_no = (unsigned int) strtoul(socket, NULL, 0);
+ else {
if (argc < optind + 1)
usage(argv[0]);
socket_no = strtoul(argv[optind], NULL, 0);
@@ -186,7 +192,7 @@ int main(int argc, char **argv) {
ret = read_out_cis(socket_no, NULL);
if (ret)
- return (ret);
+ return ret;
entry = &cis_table[0];
diff --git a/src/read-cis.c b/src/read-cis.c
index c0c74e0..0c2fb48 100644
--- a/src/read-cis.c
+++ b/src/read-cis.c
@@ -37,9 +37,9 @@ static unsigned int cis_length = MAX_TUPLES;
static void read_cis(int attr, unsigned int addr, unsigned int len, void *ptr)
{
if (cis_length > addr+len)
- memcpy(ptr, cis_copy+addr, len);
+ memcpy(ptr, cis_copy + addr, len);
else
- memset(ptr, 0xff, len);
+ memset(ptr, 0xff, len);
return;
}
@@ -102,7 +102,8 @@ int pcmcia_get_next_tuple(unsigned int function, tuple_t *tuple)
/* End of chain? Follow long link if possible */
if (link[0] == CISTPL_END) {
- if ((ofs = follow_link(tuple)) < 0)
+ ofs = follow_link(tuple);
+ if (ofs < 0)
return -ENODEV;
attr = tuple->Flags.space;
read_cis(attr, ofs, 2, link);
@@ -205,10 +206,10 @@ int pcmcia_get_tuple_data(tuple_t *tuple)
if (len == 0)
return 0;
- read_cis (tuple->Flags.space,
- tuple->CISOffset + tuple->TupleOffset,
- _MIN(len, tuple->TupleDataMax),
- tuple->TupleData);
+ read_cis(tuple->Flags.space,
+ tuple->CISOffset + tuple->TupleOffset,
+ _MIN(len, tuple->TupleDataMax),
+ tuple->TupleData);
return 0;
}
@@ -216,12 +217,12 @@ int pcmcia_get_tuple_data(tuple_t *tuple)
int read_out_cis(unsigned int socket_no, FILE *fd)
{
- char file[SYSFS_PATH_MAX];
- int ret, i;
+ char file[SYSFS_PATH_MAX];
+ int ret, i;
tuple_t tuple;
unsigned char buf[256];
- snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET "pcmcia_socket%d/cis",
+ snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET "pcmcia_socket%d/cis",
socket_no);
if (!fd) {
@@ -230,7 +231,7 @@ int read_out_cis(unsigned int socket_no, FILE *fd)
return -EIO;
}
- for (i=0; i<MAX_TUPLES; i++) {
+ for (i = 0; i < MAX_TUPLES; i++) {
ret = fgetc(fd);
if (ret == EOF) {
cis_length = i + 1;
diff --git a/src/startup.c b/src/startup.c
index f735db8..ac0ba54 100644
--- a/src/startup.c
+++ b/src/startup.c
@@ -25,19 +25,19 @@
#ifdef DEBUG
#define dprintf printf
#else
-#define dprintf(...) do { } while(0);
+#define dprintf(...) do { } while (0);
#endif
/* Linked list of resource adjustments */
-struct adjust_list_t *root_adjust = NULL;
+struct adjust_list_t *root_adjust;
/* path for config file, device scripts */
static char *configpath = "/etc/pcmcia";
enum {
- RESOURCE_MEM,
- RESOURCE_IO,
- MAX_RESOURCE_FILES
+ RESOURCE_MEM,
+ RESOURCE_IO,
+ MAX_RESOURCE_FILES
};
@@ -70,7 +70,7 @@ static int add_available_resource(unsigned int socket_no, unsigned int type,
snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET "pcmcia_socket%u/%s",
socket_no, resource_files[type]);
- switch(action) {
+ switch (action) {
case ADD_MANAGED_RESOURCE:
len = snprintf(content, SYSFS_PATH_MAX,
"0x%08lx - 0x%08lx", start, end);
@@ -101,7 +101,7 @@ static int add_available_resource(unsigned int socket_no, unsigned int type,
sysfs_close_attribute(attr);
- return (ret);
+ return ret;
}
static int setup_done(unsigned int socket_no)
@@ -122,7 +122,7 @@ static int setup_done(unsigned int socket_no)
sysfs_close_attribute(attr);
- return (ret);
+ return ret;
}
@@ -176,47 +176,48 @@ static int disallow_irq(unsigned int socket_no, unsigned int irq)
out:
sysfs_close_attribute(attr);
- return (ret);
+ return ret;
}
static void load_config(void)
{
- if (chdir(configpath) != 0) {
- syslog(LOG_ERR, "chdir to %s failed: %m", configpath);
- exit(EXIT_FAILURE);
- }
- parse_configfile("config.opts");
- return;
+ if (chdir(configpath) != 0) {
+ syslog(LOG_ERR, "chdir to %s failed: %m", configpath);
+ exit(EXIT_FAILURE);
+ }
+ parse_configfile("config.opts");
+ return;
}
static void adjust_resources(unsigned int socket_no)
{
- adjust_list_t *al;
-
- for (al = root_adjust; al; al = al->next) {
- switch (al->adj.Resource) {
- case RES_MEMORY_RANGE:
- add_available_resource(socket_no, RESOURCE_MEM,
- al->adj.Action,
- al->adj.resource.memory.Base,
- al->adj.resource.memory.Base +
- al->adj.resource.memory.Size - 1);
- break;
- case RES_IO_RANGE:
- add_available_resource(socket_no, RESOURCE_IO,
- al->adj.Action,
- al->adj.resource.io.BasePort,
- al->adj.resource.io.BasePort +
- al->adj.resource.io.NumPorts - 1);
- break;
- case RES_IRQ:
- if(al->adj.Action == REMOVE_MANAGED_RESOURCE)
- disallow_irq(socket_no, al->adj.resource.irq.IRQ);
- break;
- }
- }
+ adjust_list_t *al;
+
+ for (al = root_adjust; al; al = al->next) {
+ switch (al->adj.Resource) {
+ case RES_MEMORY_RANGE:
+ add_available_resource(socket_no, RESOURCE_MEM,
+ al->adj.Action,
+ al->adj.resource.memory.Base,
+ al->adj.resource.memory.Base +
+ al->adj.resource.memory.Size - 1);
+ break;
+ case RES_IO_RANGE:
+ add_available_resource(socket_no, RESOURCE_IO,
+ al->adj.Action,
+ al->adj.resource.io.BasePort,
+ al->adj.resource.io.BasePort +
+ al->adj.resource.io.NumPorts - 1);
+ break;
+ case RES_IRQ:
+ if (al->adj.Action == REMOVE_MANAGED_RESOURCE)
+ disallow_irq(socket_no,
+ al->adj.resource.irq.IRQ);
+ break;
+ }
+ }
}
@@ -226,17 +227,16 @@ int main(int argc, char *argv[])
unsigned long socket, i;
unsigned int all_sockets = 0;
-
- if ((socket_no = getenv("SOCKET_NO"))) {
+ socket_no = getenv("SOCKET_NO");
+ if (socket_no)
socket = strtoul(socket_no, NULL, 0);
- } else if (argc == 2) {
+ else if (argc == 2)
socket = strtoul(argv[1], NULL, 0);
- } else if (argc == 1) {
+ else if (argc == 1) {
socket = 0;
all_sockets = 1;
- } else {
+ } else
return -EINVAL;
- }
load_config();
diff --git a/src/startup.h b/src/startup.h
index ba6af2c..883e5ae 100644
--- a/src/startup.h
+++ b/src/startup.h
@@ -15,29 +15,29 @@
/* for AdjustResourceInfo */
typedef struct adjust_t {
- unsigned int Action;
- unsigned int Resource;
- unsigned int Attributes;
- union {
- struct memory {
- unsigned long Base;
- unsigned long Size;
- } memory;
- struct io {
- unsigned long BasePort;
- unsigned long NumPorts;
- unsigned int IOAddrLines;
- } io;
- struct irq {
- unsigned int IRQ;
- } irq;
- } resource;
+ unsigned int Action;
+ unsigned int Resource;
+ unsigned int Attributes;
+ union {
+ struct memory {
+ unsigned long Base;
+ unsigned long Size;
+ } memory;
+ struct io {
+ unsigned long BasePort;
+ unsigned long NumPorts;
+ unsigned int IOAddrLines;
+ } io;
+ struct irq {
+ unsigned int IRQ;
+ } irq;
+ } resource;
} adjust_t;
typedef struct adjust_list_t {
adjust_t adj;
- struct adjust_list_t *next;
+ struct adjust_list_t *next;
} adjust_list_t;
diff --git a/src/yacc_config.y b/src/yacc_config.y
index f6df721..ce14729 100644
--- a/src/yacc_config.y
+++ b/src/yacc_config.y
@@ -10,7 +10,7 @@
*
* License: GPL v2
*/
-
+
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
@@ -20,14 +20,15 @@
#include "startup.h"
-/* If bison: generate nicer error messages */
+/* If bison: generate nicer error messages */
#define YYERROR_VERBOSE 1
-
+
/* from lex_config, for nice error messages */
extern char *current_file;
extern int current_lineno;
void yyerror(char *msg, ...);
+int yylex(void);
%}