aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ibmlana.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ibmlana.c')
-rw-r--r--drivers/net/ibmlana.c119
1 files changed, 51 insertions, 68 deletions
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index 6969bf17588f..46e2c52c7862 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -83,7 +83,7 @@ History:
83#include <linux/interrupt.h> 83#include <linux/interrupt.h>
84#include <linux/delay.h> 84#include <linux/delay.h>
85#include <linux/time.h> 85#include <linux/time.h>
86#include <linux/mca-legacy.h> 86#include <linux/mca.h>
87#include <linux/module.h> 87#include <linux/module.h>
88#include <linux/netdevice.h> 88#include <linux/netdevice.h>
89#include <linux/etherdevice.h> 89#include <linux/etherdevice.h>
@@ -161,13 +161,13 @@ static void PrTime(void)
161 161
162/* deduce resources out of POS registers */ 162/* deduce resources out of POS registers */
163 163
164static void getaddrs(int slot, int *base, int *memlen, int *iobase, 164static void getaddrs(struct mca_device *mdev, int *base, int *memlen,
165 int *irq, ibmlana_medium * medium) 165 int *iobase, int *irq, ibmlana_medium *medium)
166{ 166{
167 u_char pos0, pos1; 167 u_char pos0, pos1;
168 168
169 pos0 = mca_read_stored_pos(slot, 2); 169 pos0 = mca_device_read_stored_pos(mdev, 2);
170 pos1 = mca_read_stored_pos(slot, 3); 170 pos1 = mca_device_read_stored_pos(mdev, 3);
171 171
172 *base = 0xc0000 + ((pos1 & 0xf0) << 9); 172 *base = 0xc0000 + ((pos1 & 0xf0) << 9);
173 *memlen = (pos1 & 0x01) ? 0x8000 : 0x4000; 173 *memlen = (pos1 & 0x01) ? 0x8000 : 0x4000;
@@ -744,6 +744,7 @@ static irqreturn_t irq_handler(int dummy, void *device)
744 744
745/* MCA info */ 745/* MCA info */
746 746
747#if 0 /* info available elsewhere, but this is kept for reference */
747static int ibmlana_getinfo(char *buf, int slot, void *d) 748static int ibmlana_getinfo(char *buf, int slot, void *d)
748{ 749{
749 int len = 0, i; 750 int len = 0, i;
@@ -771,6 +772,7 @@ static int ibmlana_getinfo(char *buf, int slot, void *d)
771 772
772 return len; 773 return len;
773} 774}
775#endif
774 776
775/* open driver. Means also initialization and start of LANCE */ 777/* open driver. Means also initialization and start of LANCE */
776 778
@@ -894,19 +896,26 @@ static int ibmlana_irq;
894static int ibmlana_io; 896static int ibmlana_io;
895static int startslot; /* counts through slots when probing multiple devices */ 897static int startslot; /* counts through slots when probing multiple devices */
896 898
897static int ibmlana_probe(struct net_device **dev_out) 899static short ibmlana_adapter_ids[] __initdata = {
900 IBM_LANA_ID,
901 0x0000
902};
903
904static char *ibmlana_adapter_names[] __initdata = {
905 "IBM LAN Adapter/A",
906 NULL
907};
908
909static int ibmlana_init_one(struct device *kdev)
898{ 910{
911 struct mca_device *mdev = to_mca_device(kdev);
899 struct net_device *dev; 912 struct net_device *dev;
900 int slot, z, rc; 913 int slot = mdev->slot, z, rc;
901 int base = 0, irq = 0, iobase = 0, memlen = 0; 914 int base = 0, irq = 0, iobase = 0, memlen = 0;
902 ibmlana_priv *priv; 915 ibmlana_priv *priv;
903 ibmlana_medium medium; 916 ibmlana_medium medium;
904 DECLARE_MAC_BUF(mac); 917 DECLARE_MAC_BUF(mac);
905 918
906 /* can't work without an MCA bus ;-) */
907 if (MCA_bus == 0)
908 return -ENODEV;
909
910 dev = alloc_etherdev(sizeof(ibmlana_priv)); 919 dev = alloc_etherdev(sizeof(ibmlana_priv));
911 if (!dev) 920 if (!dev)
912 return -ENOMEM; 921 return -ENOMEM;
@@ -917,25 +926,16 @@ static int ibmlana_probe(struct net_device **dev_out)
917 base = dev->mem_start; 926 base = dev->mem_start;
918 irq = dev->irq; 927 irq = dev->irq;
919 928
920 for (slot = startslot; (slot = mca_find_adapter(IBM_LANA_ID, slot)) != -1; slot++) { 929 /* deduce card addresses */
921 /* deduce card addresses */ 930 getaddrs(mdev, &base, &memlen, &iobase, &irq, &medium);
922 getaddrs(slot, &base, &memlen, &iobase, &irq, &medium);
923
924 /* slot already in use ? */
925 if (mca_is_adapter_used(slot))
926 continue;
927 /* were we looking for something different ? */
928 if (dev->irq && dev->irq != irq)
929 continue;
930 if (dev->mem_start && dev->mem_start != base)
931 continue;
932 /* found something that matches */
933 break;
934 }
935 931
936 /* nothing found ? */ 932 /* were we looking for something different ? */
937 if (slot == -1) { 933 if (dev->irq && dev->irq != irq) {
938 rc = (base != 0 || irq != 0) ? -ENXIO : -ENODEV; 934 rc = -ENODEV;
935 goto err_out;
936 }
937 if (dev->mem_start && dev->mem_start != base) {
938 rc = -ENODEV;
939 goto err_out; 939 goto err_out;
940 } 940 }
941 941
@@ -952,11 +952,10 @@ static int ibmlana_probe(struct net_device **dev_out)
952 952
953 priv = netdev_priv(dev); 953 priv = netdev_priv(dev);
954 priv->slot = slot; 954 priv->slot = slot;
955 priv->realirq = irq; 955 priv->realirq = mca_device_transform_irq(mdev, irq);
956 priv->medium = medium; 956 priv->medium = medium;
957 spin_lock_init(&priv->lock); 957 spin_lock_init(&priv->lock);
958 958
959
960 /* set base + irq for this device (irq not allocated so far) */ 959 /* set base + irq for this device (irq not allocated so far) */
961 960
962 dev->irq = 0; 961 dev->irq = 0;
@@ -972,18 +971,14 @@ static int ibmlana_probe(struct net_device **dev_out)
972 goto err_out_reg; 971 goto err_out_reg;
973 } 972 }
974 973
975 /* make procfs entries */ 974 mca_device_set_name(mdev, ibmlana_adapter_names[mdev->index]);
976 mca_set_adapter_name(slot, "IBM LAN Adapter/A"); 975 mca_device_set_claim(mdev, 1);
977 mca_set_adapter_procfn(slot, (MCA_ProcFn) ibmlana_getinfo, dev);
978
979 mca_mark_as_used(slot);
980 976
981 /* set methods */ 977 /* set methods */
982 978
983 dev->open = ibmlana_open; 979 dev->open = ibmlana_open;
984 dev->stop = ibmlana_close; 980 dev->stop = ibmlana_close;
985 dev->hard_start_xmit = ibmlana_tx; 981 dev->hard_start_xmit = ibmlana_tx;
986 dev->do_ioctl = NULL;
987 dev->set_multicast_list = ibmlana_set_multicast_list; 982 dev->set_multicast_list = ibmlana_set_multicast_list;
988 dev->flags |= IFF_MULTICAST; 983 dev->flags |= IFF_MULTICAST;
989 984
@@ -1013,13 +1008,11 @@ static int ibmlana_probe(struct net_device **dev_out)
1013 if (rc) 1008 if (rc)
1014 goto err_out_claimed; 1009 goto err_out_claimed;
1015 1010
1016 *dev_out = dev; 1011 dev_set_drvdata(kdev, dev);
1017 return 0; 1012 return 0;
1018 1013
1019err_out_claimed: 1014err_out_claimed:
1020 mca_mark_as_unused(priv->slot); 1015 mca_device_set_claim(mdev, 0);
1021 mca_set_adapter_name(priv->slot, "");
1022 mca_set_adapter_procfn(priv->slot, NULL, NULL);
1023 iounmap(priv->base); 1016 iounmap(priv->base);
1024err_out_reg: 1017err_out_reg:
1025 release_region(iobase, IBM_LANA_IORANGE); 1018 release_region(iobase, IBM_LANA_IORANGE);
@@ -1028,59 +1021,49 @@ err_out:
1028 return rc; 1021 return rc;
1029} 1022}
1030 1023
1031static void ibmlana_remove_one(struct net_device *_dev) 1024static int ibmlana_remove_one(struct device *kdev)
1032{ 1025{
1033 struct net_device *dev = _dev; 1026 struct mca_device *mdev = to_mca_device(kdev);
1027 struct net_device *dev = dev_get_drvdata(kdev);
1034 ibmlana_priv *priv = netdev_priv(dev); 1028 ibmlana_priv *priv = netdev_priv(dev);
1035 1029
1036 unregister_netdev(dev); 1030 unregister_netdev(dev);
1037 /*DeinitBoard(dev); */ 1031 /*DeinitBoard(dev); */
1038 release_region(dev->base_addr, IBM_LANA_IORANGE); 1032 release_region(dev->base_addr, IBM_LANA_IORANGE);
1039 mca_mark_as_unused(priv->slot); 1033 mca_device_set_claim(mdev, 0);
1040 mca_set_adapter_name(priv->slot, "");
1041 mca_set_adapter_procfn(priv->slot, NULL, NULL);
1042 iounmap(priv->base); 1034 iounmap(priv->base);
1043 free_netdev(dev); 1035 free_netdev(dev);
1036 return 0;
1044} 1037}
1045 1038
1046/* ------------------------------------------------------------------------ 1039/* ------------------------------------------------------------------------
1047 * modularization support 1040 * modularization support
1048 * ------------------------------------------------------------------------ */ 1041 * ------------------------------------------------------------------------ */
1049 1042
1050#define DEVMAX 5
1051
1052static struct net_device *moddevs[DEVMAX];
1053
1054module_param_named(irq, ibmlana_irq, int, 0); 1043module_param_named(irq, ibmlana_irq, int, 0);
1055module_param_named(io, ibmlana_io, int, 0); 1044module_param_named(io, ibmlana_io, int, 0);
1056MODULE_PARM_DESC(irq, "IBM LAN/A IRQ number"); 1045MODULE_PARM_DESC(irq, "IBM LAN/A IRQ number");
1057MODULE_PARM_DESC(io, "IBM LAN/A I/O base address"); 1046MODULE_PARM_DESC(io, "IBM LAN/A I/O base address");
1058MODULE_LICENSE("GPL"); 1047MODULE_LICENSE("GPL");
1059 1048
1049static struct mca_driver ibmlana_driver = {
1050 .id_table = ibmlana_adapter_ids,
1051 .driver = {
1052 .name = "ibmlana",
1053 .bus = &mca_bus_type,
1054 .probe = ibmlana_init_one,
1055 .remove = ibmlana_remove_one,
1056 },
1057};
1058
1060static int __init ibmlana_init_module(void) 1059static int __init ibmlana_init_module(void)
1061{ 1060{
1062 int z; 1061 return mca_register_driver(&ibmlana_driver);
1063
1064 startslot = 0;
1065 for (z = 0; z < DEVMAX; z++) {
1066 struct net_device *dev = NULL;
1067
1068 if (ibmlana_probe(&dev))
1069 break;
1070
1071 moddevs[z] = dev;
1072 }
1073 return (z > 0) ? 0 : -EIO;
1074} 1062}
1075 1063
1076static void __exit ibmlana_cleanup_module(void) 1064static void __exit ibmlana_cleanup_module(void)
1077{ 1065{
1078 int z; 1066 mca_unregister_driver(&ibmlana_driver);
1079 for (z = 0; z < DEVMAX; z++) {
1080 struct net_device *dev = moddevs[z];
1081 if (dev)
1082 ibmlana_remove_one(dev);
1083 }
1084} 1067}
1085 1068
1086module_init(ibmlana_init_module); 1069module_init(ibmlana_init_module);