Commit 4bc7073e authored by David S. Miller's avatar David S. Miller

Merge bk://kernel.bkbits.net/acme/net-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 5a4a60ae 652fb411
......@@ -73,7 +73,7 @@ int init_module(void);
void cleanup_module(void);
/* Hardware-specific functions */
static int load_cyc2x(cycxhw_t *hw, cfm_t *cfm, u32 len);
static int load_cyc2x(cycxhw_t *hw, struct cycx_firmware *cfm, u32 len);
static void cycx_bootcfg(cycxhw_t *hw);
static int reset_cyc2x(u32 addr);
......@@ -398,10 +398,10 @@ static int cycx_code_boot(u32 addr, u8 *code, u32 len)
/* Load adapter from the memory image of the CYCX firmware module.
* o verify firmware integrity and compatibility
* o start adapter up */
static int load_cyc2x(cycxhw_t *hw, cfm_t *cfm, u32 len)
static int load_cyc2x(cycxhw_t *hw, struct cycx_firmware *cfm, u32 len)
{
int i, j;
cycx_header_t *img_hdr;
struct cycx_fw_header *img_hdr;
u8 *reset_image,
*data_image,
*code_image;
......@@ -430,17 +430,18 @@ static int load_cyc2x(cycxhw_t *hw, cfm_t *cfm, u32 len)
}
/* Verify firmware module length and checksum */
cksum = checksum((u8*)&cfm->info, sizeof(cfm_info_t) +
cksum = checksum((u8*)&cfm->info, sizeof(struct cycx_fw_info) +
cfm->info.codesize);
/*
FIXME cfm->info.codesize is off by 2
if (((len - sizeof(cfm_t) - 1) != cfm->info.codesize) ||
if (((len - sizeof(struct cycx_firmware) - 1) != cfm->info.codesize) ||
*/
if (cksum != cfm->checksum) {
printk(KERN_ERR "%s:%s: firmware corrupted!\n",
modname, __FUNCTION__);
printk(KERN_ERR " cdsize = 0x%x (expected 0x%lx)\n",
len - sizeof(cfm_t) - 1, cfm->info.codesize);
len - sizeof(struct cycx_firmware) - 1,
cfm->info.codesize);
printk(KERN_ERR " chksum = 0x%x (expected 0x%x)\n",
cksum, cfm->checksum);
return -EINVAL;
......@@ -448,14 +449,15 @@ static int load_cyc2x(cycxhw_t *hw, cfm_t *cfm, u32 len)
/* If everything is ok, set reset, data and code pointers */
img_hdr = (cycx_header_t*)(((u8*)cfm) + sizeof(cfm_t) - 1);
img_hdr = (struct cycx_fw_header *)(((u8 *)cfm) +
sizeof(struct cycx_firmware) - 1);
#ifdef FIRMWARE_DEBUG
printk(KERN_INFO "%s:%s: image sizes\n", __FUNCTION__, modname);
printk(KERN_INFO " reset=%lu\n", img_hdr->reset_size);
printk(KERN_INFO " data=%lu\n", img_hdr->data_size);
printk(KERN_INFO " code=%lu\n", img_hdr->code_size);
#endif
reset_image = ((u8 *)img_hdr) + sizeof(cycx_header_t);
reset_image = ((u8 *)img_hdr) + sizeof(struct cycx_fw_header);
data_image = reset_image + img_hdr->reset_size;
code_image = data_image + img_hdr->data_size;
......
......@@ -87,7 +87,7 @@ static char fullname[] = "CYCLOM 2X(tm) Sync Card Driver";
static char copyright[] = "(c) 1998-2001 Arnaldo Carvalho de Melo "
"<acme@conectiva.com.br>";
static int ncards = CONFIG_CYCLOMX_CARDS;
static cycx_t *card_array; /* adapter data space */
static struct cycx_device *card_array; /* adapter data space */
/* Kernel Loadable Module Entry Points */
......@@ -113,15 +113,15 @@ int __init cyclomx_init (void)
/* Verify number of cards and allocate adapter data space */
ncards = min_t(int, ncards, MAX_CARDS);
ncards = max_t(int, ncards, 1);
card_array = kmalloc(sizeof(cycx_t) * ncards, GFP_KERNEL);
card_array = kmalloc(sizeof(struct cycx_device) * ncards, GFP_KERNEL);
if (!card_array)
goto out;
memset(card_array, 0, sizeof(cycx_t) * ncards);
memset(card_array, 0, sizeof(struct cycx_device) * ncards);
/* Register adapters with WAN router */
for (cnt = 0; cnt < ncards; ++cnt) {
cycx_t *card = &card_array[cnt];
struct cycx_device *card = &card_array[cnt];
struct wan_device *wandev = &card->wandev;
sprintf(card->devname, "%s%d", drvname, cnt + 1);
......@@ -161,7 +161,7 @@ static void __exit cyclomx_cleanup (void)
int i = 0;
for (; i < ncards; ++i) {
cycx_t *card = &card_array[i];
struct cycx_device *card = &card_array[i];
unregister_wan_device(card->devname);
}
......@@ -184,7 +184,7 @@ static void __exit cyclomx_cleanup (void)
static int setup(struct wan_device *wandev, wandev_conf_t *conf)
{
int err = -EFAULT;
cycx_t *card;
struct cycx_device *card;
int irq;
/* Sanity checks */
......@@ -276,7 +276,7 @@ out: return err;
static int shutdown(struct wan_device *wandev)
{
int ret = -EFAULT;
cycx_t *card;
struct cycx_device *card;
/* sanity checks */
if (!wandev || !wandev->private)
......@@ -318,7 +318,7 @@ static int ioctl(struct wan_device *wandev, unsigned cmd, unsigned long arg)
*/
static irqreturn_t cycx_isr (int irq, void *dev_id, struct pt_regs *regs)
{
cycx_t *card = (cycx_t *)dev_id;
struct cycx_device *card = (struct cycx_device *)dev_id;
if (!card || card->wandev.state == WAN_UNCONFIGURED)
goto out;
......@@ -341,7 +341,7 @@ out: return IRQ_NONE;
* have to call MOD_INC_USE_COUNT, but cannot include 'module.h' where it's
* defined more than once into the same kernel module.
*/
void cyclomx_mod_inc_use_count (cycx_t *card)
void cyclomx_mod_inc_use_count(struct cycx_device *card)
{
++card->open_cnt;
MOD_INC_USE_COUNT;
......@@ -353,14 +353,14 @@ void cyclomx_mod_inc_use_count (cycx_t *card)
* have to call MOD_DEC_USE_COUNT, but cannot include 'module.h' where it's
* defined more than once into the same kernel module.
*/
void cyclomx_mod_dec_use_count (cycx_t *card)
void cyclomx_mod_dec_use_count(struct cycx_device *card)
{
--card->open_cnt;
MOD_DEC_USE_COUNT;
}
/* Set WAN device state. */
void cyclomx_set_state (cycx_t *card, int state)
void cyclomx_set_state(struct cycx_device *card, int state)
{
unsigned long flags;
char *string_state = NULL;
......
This diff is collapsed.
......@@ -43,7 +43,7 @@
* This structure is needed because we handle multiple cards, otherwise
* static data would do it.
*/
typedef struct cycx {
struct cycx_device {
char devname[WAN_DRVNAME_SZ+1]; /* card name */
cycxhw_t hw; /* hardware configuration */
struct wan_device wandev; /* WAN device data space */
......@@ -54,8 +54,8 @@ typedef struct cycx {
char buff_int_mode_unbusy; /* flag for carrying out dev_tint */
wait_queue_head_t wait_stats; /* to wait for the STATS indication */
u32 mbox; /* -> mailbox */
void (*isr)(struct cycx* card); /* interrupt service routine */
int (*exec)(struct cycx* card, void* u_cmd, void* u_data);
void (*isr)(struct cycx_device* card); /* interrupt service routine */
int (*exec)(struct cycx_device* card, void* u_cmd, void* u_data);
union {
#ifdef CONFIG_CYCLOMX_X25
struct { /* X.25 specific data */
......@@ -69,15 +69,15 @@ typedef struct cycx {
} x;
#endif
} u;
} cycx_t;
};
/* Public Functions */
void cyclomx_mod_inc_use_count (cycx_t *card); /* cycx_main.c */
void cyclomx_mod_dec_use_count (cycx_t *card); /* cycx_main.c */
void cyclomx_set_state (cycx_t *card, int state); /* cycx_main.c */
void cyclomx_mod_inc_use_count(struct cycx_device *card);
void cyclomx_mod_dec_use_count(struct cycx_device *card);
void cyclomx_set_state(struct cycx_device *card, int state);
#ifdef CONFIG_CYCLOMX_X25
int cyx_init (cycx_t *card, wandev_conf_t *conf); /* cycx_x25.c */
int cyx_init(struct cycx_device *card, wandev_conf_t *conf);
#endif
#endif /* __KERNEL__ */
#endif /* _CYCLOMX_H */
......@@ -4,7 +4,7 @@
*
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* Copyright: (c) 1998-2000 Arnaldo Carvalho de Melo
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
*
* Based on sdlasfm.h by Gene Kozin <74604.152@compuserve.com>
*
......@@ -45,38 +45,57 @@
#define CFID_X25_2X 5200
/* Data Types */
/**
* struct cycx_fw_info - firmware module information.
* @codeid - firmware ID
* @version - firmware version number
* @adapter - compatible adapter types
* @memsize - minimum memory size
* @reserved - reserved
* @startoffs - entry point offset
* @winoffs - dual-port memory window offset
* @codeoffs - code load offset
* @codesize - code size
* @dataoffs - configuration data load offset
* @datasize - configuration data size
*/
struct cycx_fw_info {
unsigned short codeid;
unsigned short version;
unsigned short adapter[CFM_MAX_CYCX];
unsigned long memsize;
unsigned short reserved[2];
unsigned short startoffs;
unsigned short winoffs;
unsigned short codeoffs;
unsigned long codesize;
unsigned short dataoffs;
unsigned long datasize;
};
typedef struct cfm_info /* firmware module information */
{
unsigned short codeid; /* firmware ID */
unsigned short version; /* firmware version number */
unsigned short adapter[CFM_MAX_CYCX]; /* compatible adapter types */
unsigned long memsize; /* minimum memory size */
unsigned short reserved[2]; /* reserved */
unsigned short startoffs; /* entry point offset */
unsigned short winoffs; /* dual-port memory window offset */
unsigned short codeoffs; /* code load offset */
unsigned long codesize; /* code size */
unsigned short dataoffs; /* configuration data load offset */
unsigned long datasize; /* configuration data size */
} cfm_info_t;
/**
* struct cycx_firmware - CYCX firmware file structure
* @signature - CFM file signature
* @version - file format version
* @checksum - info + image
* @reserved - reserved
* @descr - description string
* @info - firmware module info
* @image - code image (variable size)
*/
struct cycx_firmware {
char signature[80];
unsigned short version;
unsigned short checksum;
unsigned short reserved[6];
char descr[CFM_DESCR_LEN];
struct cycx_fw_info info;
unsigned char image[1];
};
typedef struct cfm /* CYCX firmware file structure */
{
char signature[80]; /* CFM file signature */
unsigned short version; /* file format version */
unsigned short checksum; /* info + image */
unsigned short reserved[6]; /* reserved */
char descr[CFM_DESCR_LEN]; /* description string */
cfm_info_t info; /* firmware module info */
unsigned char image[1]; /* code image (variable size) */
} cfm_t;
typedef struct cycx_header_s {
struct cycx_fw_header {
unsigned long reset_size;
unsigned long data_size;
unsigned long code_size;
} cycx_header_t;
};
#endif /* _CYCX_CFM_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment