Add MODULE_FIRMWARE definitions. These definitions should IMO live next to the card descriptions, which should in turn live in the modules that actually drive the cards. Therefore, this patch moves all PCMCIA card descriptions & MODULE_FIRMWARE statements into softing_cs. Before this patch, the card description was looked up twice. The pc104 descriptions (which have not yet been tested) have no seperate module to go into, and live still in softing_fw.c
Signed-off-by: Kurt Van Dijck <[email protected]> --- kernel/2.6/drivers/net/can/softing/softing.h | 9 - kernel/2.6/drivers/net/can/softing/softing_cs.c | 115 +++++++++++++++++++++- kernel/2.6/drivers/net/can/softing/softing_fw.c | 110 --------------------- kernel/2.6/drivers/net/can/softing/softing_main.c | 16 ++- 4 files changed, 133 insertions(+), 117 deletions(-) Index: trunk/kernel/2.6/drivers/net/can/softing/softing_fw.c =================================================================== --- trunk.orig/kernel/2.6/drivers/net/can/softing/softing_fw.c 2009-11-09 10:20:29.000000000 +0100 +++ trunk/kernel/2.6/drivers/net/can/softing/softing_fw.c 2009-11-09 10:20:41.000000000 +0100 @@ -31,103 +31,7 @@ #include "softing.h" -#define fw_dir "softing-4.6/" - -const struct can_bittiming_const softing_btr_const = { - .tseg1_min = 1, - .tseg1_max = 16, - .tseg2_min = 1, - .tseg2_max = 8, - .sjw_max = 4, /* overruled */ - .brp_min = 1, - .brp_max = 32, /* overruled */ - .brp_inc = 1, -}; - static const struct softing_desc carddescs[] = { -{ - .name = "CANcard", - .manf = 0x0168, .prod = 0x001, - .generation = 1, - .freq = 16, .max_brp = 32, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, -}, { - .name = "CANcard-NEC", - .manf = 0x0168, .prod = 0x002, - .generation = 1, - .freq = 16, .max_brp = 32, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, -}, { - .name = "CANcard-SJA", - .manf = 0x0168, .prod = 0x004, - .generation = 1, - .freq = 20, .max_brp = 32, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cansja.bin",}, -}, { - .name = "CANcard-2", - .manf = 0x0168, .prod = 0x005, - .generation = 2, - .freq = 24, .max_brp = 64, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",}, -}, { - .name = "Vector-CANcard", - .manf = 0x0168, .prod = 0x081, - .generation = 1, - .freq = 16, .max_brp = 64, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, -}, { - .name = "Vector-CANcard-SJA", - .manf = 0x0168, .prod = 0x084, - .generation = 1, - .freq = 20, .max_brp = 32, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cansja.bin",}, -}, { - .name = "Vector-CANcard-2", - .manf = 0x0168, .prod = 0x085, - .generation = 2, - .freq = 24, .max_brp = 64, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",}, -}, { - .name = "EDICcard-NEC", - .manf = 0x0168, .prod = 0x102, - .generation = 1, - .freq = 16, .max_brp = 64, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, -}, { - .name = "EDICcard-2", - .manf = 0x0168, .prod = 0x105, - .generation = 2, - .freq = 24, .max_brp = 64, .max_sjw = 4, - .dpram_size = 0x0800, - .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",}, - .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",}, - .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",}, - }, - /* never tested, but taken from original softing */ { .name = "CAN-AC2-104", .manf = 0x0000, .prod = 0x009, @@ -141,17 +45,9 @@ {0, 0,}, }; -const struct softing_desc *softing_lookup_desc - (unsigned int manf, unsigned int prod) -{ - const struct softing_desc *lp = carddescs; - for (; lp->name; ++lp) { - if ((lp->manf == manf) && (lp->prod == prod)) - return lp; - } - return 0; -} -EXPORT_SYMBOL(softing_lookup_desc); +MODULE_FIRMWARE(fw_dir "boot104.bin"); +MODULE_FIRMWARE(fw_dir "ld104.bin"); +MODULE_FIRMWARE(fw_dir "canpc104.bin"); int softing_fct_cmd(struct softing *card, int cmd, int vector, const char *msg) { Index: trunk/kernel/2.6/drivers/net/can/softing/softing.h =================================================================== --- trunk.orig/kernel/2.6/drivers/net/can/softing/softing.h 2009-11-09 10:20:29.000000000 +0100 +++ trunk/kernel/2.6/drivers/net/can/softing/softing.h 2009-11-09 10:20:41.000000000 +0100 @@ -13,6 +13,9 @@ struct softing; struct sofing_desc; +/* softing firmware directory prefix */ +#define fw_dir "softing-4.6/" + /* special attribute, so we should not rely on the ->priv pointers * before knowing how to interpret these */ @@ -36,9 +39,6 @@ }; #define netdev2softing(netdev) ((struct softing_priv *)netdev_priv(netdev)) -/* the 'all cards have the same' fields definition */ -extern const struct can_bittiming_const softing_btr_const; - struct softing_desc { unsigned int manf; unsigned int prod; @@ -132,9 +132,6 @@ extern void rm_softing(struct softing *); /* usefull functions during operation */ -extern const struct softing_desc * - softing_lookup_desc(unsigned int manf, unsigned int prod); - extern int softing_default_output(struct softing *card , struct softing_priv *priv); extern ktime_t softing_raw2ktime(struct softing *card, u32 raw); Index: trunk/kernel/2.6/drivers/net/can/softing/softing_cs.c =================================================================== --- trunk.orig/kernel/2.6/drivers/net/can/softing/softing_cs.c 2009-11-09 10:20:29.000000000 +0100 +++ trunk/kernel/2.6/drivers/net/can/softing/softing_cs.c 2009-11-09 10:20:41.000000000 +0100 @@ -49,6 +49,114 @@ }; #define softing2cs(x) container_of((x), struct softing_cs, softing) +/* card descriptions */ +static const struct softing_desc carddescs[] = { +{ + .name = "CANcard", + .manf = 0x0168, .prod = 0x001, + .generation = 1, + .freq = 16, .max_brp = 32, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, +}, { + .name = "CANcard-NEC", + .manf = 0x0168, .prod = 0x002, + .generation = 1, + .freq = 16, .max_brp = 32, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, +}, { + .name = "CANcard-SJA", + .manf = 0x0168, .prod = 0x004, + .generation = 1, + .freq = 20, .max_brp = 32, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cansja.bin",}, +}, { + .name = "CANcard-2", + .manf = 0x0168, .prod = 0x005, + .generation = 2, + .freq = 24, .max_brp = 64, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",}, +}, { + .name = "Vector-CANcard", + .manf = 0x0168, .prod = 0x081, + .generation = 1, + .freq = 16, .max_brp = 64, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, +}, { + .name = "Vector-CANcard-SJA", + .manf = 0x0168, .prod = 0x084, + .generation = 1, + .freq = 20, .max_brp = 32, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cansja.bin",}, +}, { + .name = "Vector-CANcard-2", + .manf = 0x0168, .prod = 0x085, + .generation = 2, + .freq = 24, .max_brp = 64, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",}, +}, { + .name = "EDICcard-NEC", + .manf = 0x0168, .prod = 0x102, + .generation = 1, + .freq = 16, .max_brp = 64, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",}, +}, { + .name = "EDICcard-2", + .manf = 0x0168, .prod = 0x105, + .generation = 2, + .freq = 24, .max_brp = 64, .max_sjw = 4, + .dpram_size = 0x0800, + .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",}, + .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",}, + .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",}, + }, +{0, 0,}, +}; + +MODULE_FIRMWARE(fw_dir "bcard.bin"); +MODULE_FIRMWARE(fw_dir "ldcard.bin"); +MODULE_FIRMWARE(fw_dir "cancard.bin"); +MODULE_FIRMWARE(fw_dir "cansja.bin"); + +MODULE_FIRMWARE(fw_dir "bcard2.bin"); +MODULE_FIRMWARE(fw_dir "ldcard2.bin"); +MODULE_FIRMWARE(fw_dir "cancrd2.bin"); + +static const struct softing_desc *softing_cs_lookup_desc + (unsigned int manf, unsigned int prod) +{ + const struct softing_desc *lp = carddescs; + for (; lp->name; ++lp) { + if ((lp->manf == manf) && (lp->prod == prod)) + return lp; + } + return 0; +} + + struct lookup { int i; const char *a; @@ -312,7 +420,11 @@ /* properties */ card->id.manf = pcmcia->manf_id; card->id.prod = pcmcia->card_id; - card->desc = softing_lookup_desc(card->id.manf, card->id.prod); + card->desc = softing_cs_lookup_desc(card->id.manf, card->id.prod); + if (!card->desc) { + dev_alert(&pcmcia->dev, "unknown card\n"); + goto description_failed; + } if (card->desc->generation >= 2) { card->fn.reset = card_reset_via_dpram; } else { @@ -380,6 +492,7 @@ softing_failed: wrong_dpram: config_failed: +description_failed: kfree(cs); no_mem: pcmcia_disable_device(pcmcia); Index: trunk/kernel/2.6/drivers/net/can/softing/softing_main.c =================================================================== --- trunk.orig/kernel/2.6/drivers/net/can/softing/softing_main.c 2009-11-09 10:20:29.000000000 +0100 +++ trunk/kernel/2.6/drivers/net/can/softing/softing_main.c 2009-11-09 10:20:41.000000000 +0100 @@ -627,6 +627,18 @@ }; #endif +static const struct can_bittiming_const softing_btr_const = { + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_max = 4, /* overruled */ + .brp_min = 1, + .brp_max = 32, /* overruled */ + .brp_inc = 1, +}; + + static struct softing_priv *mk_netdev(struct softing *card, u16 chip_id) { struct net_device *ndev; @@ -715,10 +727,8 @@ spin_lock_init(&card->spin); tasklet_init(&card->irq.bh, softing_dev_svc, (unsigned long)card); - card->desc = softing_lookup_desc(card->id.manf, card->id.prod); if (!card->desc) { - dev_alert(card->dev, "0x%04x:0x%04x not supported\n", - card->id.manf, card->id.prod); + dev_alert(card->dev, "no card description\n"); goto lookup_failed; } card->id.name = card->desc->name; _______________________________________________ Socketcan-core mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-core
