diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-05-29 09:39:16 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-07-10 09:47:50 -0400 |
commit | 0f805b86c9492c294c710de8539a8be68b521a86 (patch) | |
tree | 84ab8143ed83daae5faf0ecb66bf9dda8a6a92ca /drivers/net/tokenring/smctr.c | |
parent | 18ee6dfae89d9c131e3c9952939633ba8fa86247 (diff) |
smctr: use request_firmware()
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/net/tokenring/smctr.c')
-rw-r--r-- | drivers/net/tokenring/smctr.c | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c index 5f1c5072b96f..fa73e6eed6be 100644 --- a/drivers/net/tokenring/smctr.c +++ b/drivers/net/tokenring/smctr.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/skbuff.h> | 48 | #include <linux/skbuff.h> |
49 | #include <linux/trdevice.h> | 49 | #include <linux/trdevice.h> |
50 | #include <linux/bitops.h> | 50 | #include <linux/bitops.h> |
51 | #include <linux/firmware.h> | ||
51 | 52 | ||
52 | #include <asm/system.h> | 53 | #include <asm/system.h> |
53 | #include <asm/io.h> | 54 | #include <asm/io.h> |
@@ -59,7 +60,6 @@ | |||
59 | #endif | 60 | #endif |
60 | 61 | ||
61 | #include "smctr.h" /* Our Stuff */ | 62 | #include "smctr.h" /* Our Stuff */ |
62 | #include "smctr_firmware.h" /* SMC adapter firmware */ | ||
63 | 63 | ||
64 | static char version[] __initdata = KERN_INFO "smctr.c: v1.4 7/12/00 by jschlst@samba.org\n"; | 64 | static char version[] __initdata = KERN_INFO "smctr.c: v1.4 7/12/00 by jschlst@samba.org\n"; |
65 | static const char cardname[] = "smctr"; | 65 | static const char cardname[] = "smctr"; |
@@ -103,7 +103,8 @@ static int smctr_clear_trc_reset(int ioaddr); | |||
103 | static int smctr_close(struct net_device *dev); | 103 | static int smctr_close(struct net_device *dev); |
104 | 104 | ||
105 | /* D */ | 105 | /* D */ |
106 | static int smctr_decode_firmware(struct net_device *dev); | 106 | static int smctr_decode_firmware(struct net_device *dev, |
107 | const struct firmware *fw); | ||
107 | static int smctr_disable_16bit(struct net_device *dev); | 108 | static int smctr_disable_16bit(struct net_device *dev); |
108 | static int smctr_disable_adapter_ctrl_store(struct net_device *dev); | 109 | static int smctr_disable_adapter_ctrl_store(struct net_device *dev); |
109 | static int smctr_disable_bic_int(struct net_device *dev); | 110 | static int smctr_disable_bic_int(struct net_device *dev); |
@@ -748,7 +749,8 @@ static int smctr_close(struct net_device *dev) | |||
748 | return (0); | 749 | return (0); |
749 | } | 750 | } |
750 | 751 | ||
751 | static int smctr_decode_firmware(struct net_device *dev) | 752 | static int smctr_decode_firmware(struct net_device *dev, |
753 | const struct firmware *fw) | ||
752 | { | 754 | { |
753 | struct net_local *tp = netdev_priv(dev); | 755 | struct net_local *tp = netdev_priv(dev); |
754 | short bit = 0x80, shift = 12; | 756 | short bit = 0x80, shift = 12; |
@@ -762,10 +764,10 @@ static int smctr_decode_firmware(struct net_device *dev) | |||
762 | if(smctr_debug > 10) | 764 | if(smctr_debug > 10) |
763 | printk(KERN_DEBUG "%s: smctr_decode_firmware\n", dev->name); | 765 | printk(KERN_DEBUG "%s: smctr_decode_firmware\n", dev->name); |
764 | 766 | ||
765 | weight = *(long *)(tp->ptr_ucode + WEIGHT_OFFSET); | 767 | weight = *(long *)(fw->data + WEIGHT_OFFSET); |
766 | tsize = *(__u8 *)(tp->ptr_ucode + TREE_SIZE_OFFSET); | 768 | tsize = *(__u8 *)(fw->data + TREE_SIZE_OFFSET); |
767 | tree = (DECODE_TREE_NODE *)(tp->ptr_ucode + TREE_OFFSET); | 769 | tree = (DECODE_TREE_NODE *)(fw->data + TREE_OFFSET); |
768 | ucode = (__u8 *)(tp->ptr_ucode + TREE_OFFSET | 770 | ucode = (__u8 *)(fw->data + TREE_OFFSET |
769 | + (tsize * sizeof(DECODE_TREE_NODE))); | 771 | + (tsize * sizeof(DECODE_TREE_NODE))); |
770 | mem = (__u16 *)(tp->ram_access); | 772 | mem = (__u16 *)(tp->ram_access); |
771 | 773 | ||
@@ -2963,34 +2965,44 @@ static int smctr_link_tx_fcbs_to_bdbs(struct net_device *dev) | |||
2963 | static int smctr_load_firmware(struct net_device *dev) | 2965 | static int smctr_load_firmware(struct net_device *dev) |
2964 | { | 2966 | { |
2965 | struct net_local *tp = netdev_priv(dev); | 2967 | struct net_local *tp = netdev_priv(dev); |
2968 | const struct firmware *fw; | ||
2966 | __u16 i, checksum = 0; | 2969 | __u16 i, checksum = 0; |
2967 | int err = 0; | 2970 | int err = 0; |
2968 | 2971 | ||
2969 | if(smctr_debug > 10) | 2972 | if(smctr_debug > 10) |
2970 | printk(KERN_DEBUG "%s: smctr_load_firmware\n", dev->name); | 2973 | printk(KERN_DEBUG "%s: smctr_load_firmware\n", dev->name); |
2971 | 2974 | ||
2972 | tp->ptr_ucode = smctr_code; | 2975 | if (request_firmware(&fw, "tr_smctr.bin", &dev->dev)) { |
2976 | printk(KERN_ERR "%s: firmware not found\n", dev->name); | ||
2977 | return (UCODE_NOT_PRESENT); | ||
2978 | } | ||
2979 | |||
2973 | tp->num_of_tx_buffs = 4; | 2980 | tp->num_of_tx_buffs = 4; |
2974 | tp->mode_bits |= UMAC; | 2981 | tp->mode_bits |= UMAC; |
2975 | tp->receive_mask = 0; | 2982 | tp->receive_mask = 0; |
2976 | tp->max_packet_size = 4177; | 2983 | tp->max_packet_size = 4177; |
2977 | 2984 | ||
2978 | /* Can only upload the firmware once per adapter reset. */ | 2985 | /* Can only upload the firmware once per adapter reset. */ |
2979 | if(tp->microcode_version != 0) | 2986 | if (tp->microcode_version != 0) { |
2980 | return (UCODE_PRESENT); | 2987 | err = (UCODE_PRESENT); |
2988 | goto out; | ||
2989 | } | ||
2981 | 2990 | ||
2982 | /* Verify the firmware exists and is there in the right amount. */ | 2991 | /* Verify the firmware exists and is there in the right amount. */ |
2983 | if (!tp->ptr_ucode | 2992 | if (!fw->data |
2984 | || (*(tp->ptr_ucode + UCODE_VERSION_OFFSET) < UCODE_VERSION)) | 2993 | || (*(fw->data + UCODE_VERSION_OFFSET) < UCODE_VERSION)) |
2985 | { | 2994 | { |
2986 | return (UCODE_NOT_PRESENT); | 2995 | err = (UCODE_NOT_PRESENT); |
2996 | goto out; | ||
2987 | } | 2997 | } |
2988 | 2998 | ||
2989 | /* UCODE_SIZE is not included in Checksum. */ | 2999 | /* UCODE_SIZE is not included in Checksum. */ |
2990 | for(i = 0; i < *((__u16 *)(tp->ptr_ucode + UCODE_SIZE_OFFSET)); i += 2) | 3000 | for(i = 0; i < *((__u16 *)(fw->data + UCODE_SIZE_OFFSET)); i += 2) |
2991 | checksum += *((__u16 *)(tp->ptr_ucode + 2 + i)); | 3001 | checksum += *((__u16 *)(fw->data + 2 + i)); |
2992 | if(checksum) | 3002 | if (checksum) { |
2993 | return (UCODE_NOT_PRESENT); | 3003 | err = (UCODE_NOT_PRESENT); |
3004 | goto out; | ||
3005 | } | ||
2994 | 3006 | ||
2995 | /* At this point we have a valid firmware image, lets kick it on up. */ | 3007 | /* At this point we have a valid firmware image, lets kick it on up. */ |
2996 | smctr_enable_adapter_ram(dev); | 3008 | smctr_enable_adapter_ram(dev); |
@@ -2998,7 +3010,7 @@ static int smctr_load_firmware(struct net_device *dev) | |||
2998 | smctr_set_page(dev, (__u8 *)tp->ram_access); | 3010 | smctr_set_page(dev, (__u8 *)tp->ram_access); |
2999 | 3011 | ||
3000 | if((smctr_checksum_firmware(dev)) | 3012 | if((smctr_checksum_firmware(dev)) |
3001 | || (*(tp->ptr_ucode + UCODE_VERSION_OFFSET) | 3013 | || (*(fw->data + UCODE_VERSION_OFFSET) |
3002 | > tp->microcode_version)) | 3014 | > tp->microcode_version)) |
3003 | { | 3015 | { |
3004 | smctr_enable_adapter_ctrl_store(dev); | 3016 | smctr_enable_adapter_ctrl_store(dev); |
@@ -3007,9 +3019,9 @@ static int smctr_load_firmware(struct net_device *dev) | |||
3007 | for(i = 0; i < CS_RAM_SIZE; i += 2) | 3019 | for(i = 0; i < CS_RAM_SIZE; i += 2) |
3008 | *((__u16 *)(tp->ram_access + i)) = 0; | 3020 | *((__u16 *)(tp->ram_access + i)) = 0; |
3009 | 3021 | ||
3010 | smctr_decode_firmware(dev); | 3022 | smctr_decode_firmware(dev, fw); |
3011 | 3023 | ||
3012 | tp->microcode_version = *(tp->ptr_ucode + UCODE_VERSION_OFFSET); *((__u16 *)(tp->ram_access + CS_RAM_VERSION_OFFSET)) | 3024 | tp->microcode_version = *(fw->data + UCODE_VERSION_OFFSET); *((__u16 *)(tp->ram_access + CS_RAM_VERSION_OFFSET)) |
3013 | = (tp->microcode_version << 8); | 3025 | = (tp->microcode_version << 8); |
3014 | *((__u16 *)(tp->ram_access + CS_RAM_CHECKSUM_OFFSET)) | 3026 | *((__u16 *)(tp->ram_access + CS_RAM_CHECKSUM_OFFSET)) |
3015 | = ~(tp->microcode_version << 8) + 1; | 3027 | = ~(tp->microcode_version << 8) + 1; |
@@ -3023,7 +3035,8 @@ static int smctr_load_firmware(struct net_device *dev) | |||
3023 | err = UCODE_PRESENT; | 3035 | err = UCODE_PRESENT; |
3024 | 3036 | ||
3025 | smctr_disable_16bit(dev); | 3037 | smctr_disable_16bit(dev); |
3026 | 3038 | out: | |
3039 | release_firmware(fw); | ||
3027 | return (err); | 3040 | return (err); |
3028 | } | 3041 | } |
3029 | 3042 | ||
@@ -5651,6 +5664,7 @@ static int io[SMCTR_MAX_ADAPTERS]; | |||
5651 | static int irq[SMCTR_MAX_ADAPTERS]; | 5664 | static int irq[SMCTR_MAX_ADAPTERS]; |
5652 | 5665 | ||
5653 | MODULE_LICENSE("GPL"); | 5666 | MODULE_LICENSE("GPL"); |
5667 | MODULE_FIRMWARE("tr_smctr.bin"); | ||
5654 | 5668 | ||
5655 | module_param_array(io, int, NULL, 0); | 5669 | module_param_array(io, int, NULL, 0); |
5656 | module_param_array(irq, int, NULL, 0); | 5670 | module_param_array(irq, int, NULL, 0); |