aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-06-24 17:16:01 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-06-24 22:57:42 -0400
commit59eae1fa3ba19be35f09b37e73d90ac5028996fe (patch)
treea88b648a0be2798cbc120700097cfde33101669b
parent9088fa4fa2f0b10bf4d9a17381a5ec3485751cb7 (diff)
DM9000: Cleanup source code
Cleanup bits of the DM9000 driver to make the code neater and easier to read. This is includes removing some old definitions, re-indenting areas, etc. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
-rw-r--r--drivers/net/dm9000.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 79bdd9e29a01..79538ab4ee60 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -44,9 +44,8 @@
44 44
45#define DM9000_PHY 0x40 /* PHY address 0x01 */ 45#define DM9000_PHY 0x40 /* PHY address 0x01 */
46 46
47#define CARDNAME "dm9000" 47#define CARDNAME "dm9000"
48#define PFX CARDNAME ": " 48#define DRV_VERSION "1.31"
49#define DRV_VERSION "1.30"
50 49
51#ifdef CONFIG_BLACKFIN 50#ifdef CONFIG_BLACKFIN
52#define readsb insb 51#define readsb insb
@@ -98,22 +97,23 @@ enum dm9000_type {
98/* Structure/enum declaration ------------------------------- */ 97/* Structure/enum declaration ------------------------------- */
99typedef struct board_info { 98typedef struct board_info {
100 99
101 void __iomem *io_addr; /* Register I/O base address */ 100 void __iomem *io_addr; /* Register I/O base address */
102 void __iomem *io_data; /* Data I/O address */ 101 void __iomem *io_data; /* Data I/O address */
103 u16 irq; /* IRQ */ 102 u16 irq; /* IRQ */
104 103
105 u16 tx_pkt_cnt; 104 u16 tx_pkt_cnt;
106 u16 queue_pkt_len; 105 u16 queue_pkt_len;
107 u16 queue_start_addr; 106 u16 queue_start_addr;
108 u16 dbug_cnt; 107 u16 dbug_cnt;
109 u8 io_mode; /* 0:word, 2:byte */ 108 u8 io_mode; /* 0:word, 2:byte */
110 u8 phy_addr; 109 u8 phy_addr;
111 u8 imr_all; 110 u8 imr_all;
112 unsigned int flags; 111
113 unsigned int in_suspend :1; 112 unsigned int flags;
113 unsigned int in_suspend :1;
114 int debug_level;
114 115
115 enum dm9000_type type; 116 enum dm9000_type type;
116 int debug_level;
117 117
118 void (*inblk)(void __iomem *port, void *data, int length); 118 void (*inblk)(void __iomem *port, void *data, int length);
119 void (*outblk)(void __iomem *port, void *data, int length); 119 void (*outblk)(void __iomem *port, void *data, int length);
@@ -132,10 +132,10 @@ typedef struct board_info {
132 struct delayed_work phy_poll; 132 struct delayed_work phy_poll;
133 struct net_device *ndev; 133 struct net_device *ndev;
134 134
135 spinlock_t lock; 135 spinlock_t lock;
136 136
137 struct mii_if_info mii; 137 struct mii_if_info mii;
138 u32 msg_enable; 138 u32 msg_enable;
139} board_info_t; 139} board_info_t;
140 140
141/* debug code */ 141/* debug code */
@@ -153,19 +153,16 @@ static inline board_info_t *to_dm9000_board(struct net_device *dev)
153} 153}
154 154
155/* function declaration ------------------------------------- */ 155/* function declaration ------------------------------------- */
156static int dm9000_probe(struct platform_device *);
157static int dm9000_open(struct net_device *); 156static int dm9000_open(struct net_device *);
158static int dm9000_start_xmit(struct sk_buff *, struct net_device *); 157static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
159static int dm9000_stop(struct net_device *); 158static int dm9000_stop(struct net_device *);
160static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
161 159
162static void dm9000_init_dm9000(struct net_device *); 160static void dm9000_init_dm9000(struct net_device *);
163 161
164static irqreturn_t dm9000_interrupt(int, void *); 162static irqreturn_t dm9000_interrupt(int, void *);
165 163
166static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int reg); 164static int dm9000_phy_read(struct net_device *dev, int phy, int reg);
167static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, 165static void dm9000_phy_write(struct net_device *dev, int phy, int reg, int v);
168 int value);
169 166
170static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to); 167static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
171static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp); 168static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
@@ -655,7 +652,7 @@ dm9000_probe(struct platform_device *pdev)
655 652
656 dm9000_reset(db); 653 dm9000_reset(db);
657 654
658 /* try two times, DM9000 sometimes gets the first read wrong */ 655 /* try multiple times, DM9000 sometimes gets the read wrong */
659 for (i = 0; i < 8; i++) { 656 for (i = 0; i < 8; i++) {
660 id_val = ior(db, DM9000_VIDL); 657 id_val = ior(db, DM9000_VIDL);
661 id_val |= (u32)ior(db, DM9000_VIDH) << 8; 658 id_val |= (u32)ior(db, DM9000_VIDH) << 8;
@@ -763,7 +760,7 @@ out:
763static int 760static int
764dm9000_open(struct net_device *dev) 761dm9000_open(struct net_device *dev)
765{ 762{
766 board_info_t *db = (board_info_t *) dev->priv; 763 board_info_t *db = dev->priv;
767 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK; 764 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
768 765
769 if (netif_msg_ifup(db)) 766 if (netif_msg_ifup(db))
@@ -803,7 +800,7 @@ dm9000_open(struct net_device *dev)
803static void 800static void
804dm9000_init_dm9000(struct net_device *dev) 801dm9000_init_dm9000(struct net_device *dev)
805{ 802{
806 board_info_t *db = (board_info_t *) dev->priv; 803 board_info_t *db = dev->priv;
807 unsigned int imr; 804 unsigned int imr;
808 805
809 dm9000_dbg(db, 1, "entering %s\n", __func__); 806 dm9000_dbg(db, 1, "entering %s\n", __func__);
@@ -854,7 +851,7 @@ static int
854dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) 851dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
855{ 852{
856 unsigned long flags; 853 unsigned long flags;
857 board_info_t *db = (board_info_t *) dev->priv; 854 board_info_t *db = dev->priv;
858 855
859 dm9000_dbg(db, 3, "%s:\n", __func__); 856 dm9000_dbg(db, 3, "%s:\n", __func__);
860 857
@@ -897,7 +894,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
897static void 894static void
898dm9000_shutdown(struct net_device *dev) 895dm9000_shutdown(struct net_device *dev)
899{ 896{
900 board_info_t *db = (board_info_t *) dev->priv; 897 board_info_t *db = dev->priv;
901 898
902 /* RESET device */ 899 /* RESET device */
903 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */ 900 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
@@ -913,7 +910,7 @@ dm9000_shutdown(struct net_device *dev)
913static int 910static int
914dm9000_stop(struct net_device *ndev) 911dm9000_stop(struct net_device *ndev)
915{ 912{
916 board_info_t *db = (board_info_t *) ndev->priv; 913 board_info_t *db = ndev->priv;
917 914
918 if (netif_msg_ifdown(db)) 915 if (netif_msg_ifdown(db))
919 dev_dbg(db->dev, "shutting down %s\n", ndev->name); 916 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
@@ -964,7 +961,7 @@ static irqreturn_t
964dm9000_interrupt(int irq, void *dev_id) 961dm9000_interrupt(int irq, void *dev_id)
965{ 962{
966 struct net_device *dev = dev_id; 963 struct net_device *dev = dev_id;
967 board_info_t *db = (board_info_t *) dev->priv; 964 board_info_t *db = dev->priv;
968 int int_status; 965 int int_status;
969 u8 reg_save; 966 u8 reg_save;
970 967
@@ -1345,7 +1342,8 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1345 * Write a word to phyxcer 1342 * Write a word to phyxcer
1346 */ 1343 */
1347static void 1344static void
1348dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) 1345dm9000_phy_write(struct net_device *dev,
1346 int phyaddr_unused, int reg, int value)
1349{ 1347{
1350 board_info_t *db = (board_info_t *) dev->priv; 1348 board_info_t *db = (board_info_t *) dev->priv;
1351 unsigned long flags; 1349 unsigned long flags;
@@ -1454,7 +1452,7 @@ dm9000_init(void)
1454{ 1452{
1455 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION); 1453 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
1456 1454
1457 return platform_driver_register(&dm9000_driver); /* search board and register */ 1455 return platform_driver_register(&dm9000_driver);
1458} 1456}
1459 1457
1460static void __exit 1458static void __exit