All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff.org>
To: netdev@vger.kernel.org
Cc: jeff@garzik.org, Ben Dooks <ben-linux@fluff.org>
Subject: [patch v2 04/11] DM9000: Cleanup source code
Date: Sun, 22 Jun 2008 21:16:49 +0100	[thread overview]
Message-ID: <20080622201905.174147020@fluff.org.uk> (raw)
In-Reply-To: 20080622201645.041001353@fluff.org.uk

[-- Attachment #1: simtec/simtec-drivers-net-dm9000-cleanups1.patch --]
[-- Type: text/plain, Size: 6797 bytes --]

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>

Index: linux-2.6.26-rc6-quilt1/drivers/net/dm9000.c
===================================================================
--- linux-2.6.26-rc6-quilt1.orig/drivers/net/dm9000.c	2008-06-15 22:52:31.000000000 +0100
+++ linux-2.6.26-rc6-quilt1/drivers/net/dm9000.c	2008-06-15 23:14:39.000000000 +0100
@@ -44,9 +44,8 @@
 
 #define DM9000_PHY		0x40	/* PHY address 0x01 */
 
-#define CARDNAME "dm9000"
-#define PFX CARDNAME ": "
-#define DRV_VERSION	"1.30"
+#define CARDNAME	"dm9000"
+#define DRV_VERSION	"1.31"
 
 #ifdef CONFIG_BLACKFIN
 #define readsb	insb
@@ -98,22 +97,23 @@ enum dm9000_type {
 /* Structure/enum declaration ------------------------------- */
 typedef struct board_info {
 
-	void __iomem *io_addr;	/* Register I/O base address */
-	void __iomem *io_data;	/* Data I/O address */
-	u16 irq;		/* IRQ */
-
-	u16 tx_pkt_cnt;
-	u16 queue_pkt_len;
-	u16 queue_start_addr;
-	u16 dbug_cnt;
-	u8 io_mode;		/* 0:word, 2:byte */
-	u8 phy_addr;
-	u8 imr_all;
-	unsigned int flags;
-	unsigned int in_suspend :1;
+	void __iomem	*io_addr;	/* Register I/O base address */
+	void __iomem	*io_data;	/* Data I/O address */
+	u16		 irq;		/* IRQ */
+
+	u16		tx_pkt_cnt;
+	u16		queue_pkt_len;
+	u16		queue_start_addr;
+	u16		dbug_cnt;
+	u8		io_mode;		/* 0:word, 2:byte */
+	u8		phy_addr;
+	u8		imr_all;
+
+	unsigned int	flags;
+	unsigned int	in_suspend :1;
+	int		debug_level;
 
 	enum dm9000_type type;
-	int debug_level;
 
 	void (*inblk)(void __iomem *port, void *data, int length);
 	void (*outblk)(void __iomem *port, void *data, int length);
@@ -132,10 +132,10 @@ typedef struct board_info {
 	struct delayed_work phy_poll;
 	struct net_device  *ndev;
 
-	spinlock_t lock;
+	spinlock_t	lock;
 
 	struct mii_if_info mii;
-	u32 msg_enable;
+	u32		msg_enable;
 } board_info_t;
 
 /* debug code */
@@ -153,19 +153,16 @@ static inline board_info_t *to_dm9000_bo
 }
 
 /* function declaration ------------------------------------- */
-static int dm9000_probe(struct platform_device *);
 static int dm9000_open(struct net_device *);
 static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
 static int dm9000_stop(struct net_device *);
-static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
 
 static void dm9000_init_dm9000(struct net_device *);
 
 static irqreturn_t dm9000_interrupt(int, void *);
 
-static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int reg);
-static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg,
-			   int value);
+static int dm9000_phy_read(struct net_device *dev, int phy, int reg);
+static void dm9000_phy_write(struct net_device *dev, int phy, int reg, int v);
 
 static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
 static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
@@ -505,12 +502,6 @@ dm9000_poll_work(struct work_struct *w)
 static void
 dm9000_release_board(struct platform_device *pdev, struct board_info *db)
 {
-	if (db->data_res == NULL) {
-		if (db->addr_res != NULL)
-			release_mem_region((unsigned long)db->io_addr, 4);
-		return;
-	}
-
 	/* unmap our resources */
 
 	iounmap(db->io_addr);
@@ -518,15 +509,11 @@ dm9000_release_board(struct platform_dev
 
 	/* release the resources */
 
-	if (db->data_req != NULL) {
-		release_resource(db->data_req);
-		kfree(db->data_req);
-	}
+	release_resource(db->data_req);
+	kfree(db->data_req);
 
-	if (db->addr_req != NULL) {
-		release_resource(db->addr_req);
-		kfree(db->addr_req);
-	}
+	release_resource(db->addr_req);
+	kfree(db->addr_req);
 }
 
 static unsigned char dm9000_type_to_char(enum dm9000_type type)
@@ -580,12 +567,6 @@ dm9000_probe(struct platform_device *pde
 
 	INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
 
-
-	if (pdev->num_resources < 2) {
-		ret = -ENODEV;
-		goto out;
-	}
-
 	db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	db->irq_res  = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -671,7 +652,7 @@ dm9000_probe(struct platform_device *pde
 
 	dm9000_reset(db);
 
-	/* try two times, DM9000 sometimes gets the first read wrong */
+	/* try multiple times, DM9000 sometimes gets the read wrong */
 	for (i = 0; i < 8; i++) {
 		id_val  = ior(db, DM9000_VIDL);
 		id_val |= (u32)ior(db, DM9000_VIDH) << 8;
@@ -779,7 +760,7 @@ out:
 static int
 dm9000_open(struct net_device *dev)
 {
-	board_info_t *db = (board_info_t *) dev->priv;
+	board_info_t *db = dev->priv;
 	unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
 
 	if (netif_msg_ifup(db))
@@ -819,7 +800,7 @@ dm9000_open(struct net_device *dev)
 static void
 dm9000_init_dm9000(struct net_device *dev)
 {
-	board_info_t *db = (board_info_t *) dev->priv;
+	board_info_t *db = dev->priv;
 	unsigned int imr;
 
 	dm9000_dbg(db, 1, "entering %s\n", __func__);
@@ -870,7 +851,7 @@ static int
 dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	unsigned long flags;
-	board_info_t *db = (board_info_t *) dev->priv;
+	board_info_t *db = dev->priv;
 
 	dm9000_dbg(db, 3, "%s:\n", __func__);
 
@@ -913,7 +894,7 @@ dm9000_start_xmit(struct sk_buff *skb, s
 static void
 dm9000_shutdown(struct net_device *dev)
 {
-	board_info_t *db = (board_info_t *) dev->priv;
+	board_info_t *db = dev->priv;
 
 	/* RESET device */
 	dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET);	/* PHY RESET */
@@ -929,7 +910,7 @@ dm9000_shutdown(struct net_device *dev)
 static int
 dm9000_stop(struct net_device *ndev)
 {
-	board_info_t *db = (board_info_t *) ndev->priv;
+	board_info_t *db = ndev->priv;
 
 	if (netif_msg_ifdown(db))
 		dev_dbg(db->dev, "shutting down %s\n", ndev->name);
@@ -980,7 +961,7 @@ static irqreturn_t
 dm9000_interrupt(int irq, void *dev_id)
 {
 	struct net_device *dev = dev_id;
-	board_info_t *db = (board_info_t *) dev->priv;
+	board_info_t *db = dev->priv;
 	int int_status;
 	u8 reg_save;
 
@@ -1361,7 +1342,8 @@ dm9000_phy_read(struct net_device *dev, 
  *   Write a word to phyxcer
  */
 static void
-dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
+dm9000_phy_write(struct net_device *dev,
+		 int phyaddr_unused, int reg, int value)
 {
 	board_info_t *db = (board_info_t *) dev->priv;
 	unsigned long flags;
@@ -1470,7 +1452,7 @@ dm9000_init(void)
 {
 	printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
 
-	return platform_driver_register(&dm9000_driver);	/* search board and register */
+	return platform_driver_register(&dm9000_driver);
 }
 
 static void __exit

-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

  parent reply	other threads:[~2008-06-22 20:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-22 20:16 [patch v2 00/11] DM9000 patch series for next kernel Ben Dooks
2008-06-22 20:16 ` [patch v2 01/11] DM9000: Remove the 2 resources probe scheme Ben Dooks
2008-06-22 20:34   ` Ben Hutchings
2008-06-22 21:18     ` Ben Dooks
2008-06-23  7:40       ` Laurent Pinchart
2008-06-22 20:16 ` [patch v2 02/11] DM9000: Fixup blackfin after removing 2 resource usage Ben Dooks
2008-06-22 20:35   ` Ben Hutchings
2008-06-23  9:24     ` Ben Dooks
2008-06-23  9:56       ` Bryan Wu
2008-06-23 10:20         ` Ben Dooks
2008-06-24  2:00           ` Bryan Wu
2008-06-22 20:16 ` [patch v2 03/11] DM9000: Add support for DM9000A and DM9000B chips Ben Dooks
2008-06-22 20:16 ` Ben Dooks [this message]
2008-06-22 20:16 ` [patch v2 05/11] DM9000: Cleanup source code - remove forward declerations Ben Dooks
2008-06-22 20:16 ` [patch v2 06/11] DM9000: Use NSR to determine link-status on internal PHY Ben Dooks
2008-06-22 20:16 ` [patch v2 07/11] DM9000: Allow the use of the NSR register to get link status Ben Dooks
2008-06-22 20:16 ` [patch v2 08/11] DM9000: Add missing msleep() in EEPROM wait code Ben Dooks
2008-06-22 20:16 ` [patch v2 09/11] DM9000: Re-unit menuconfig entries for DM9000 driver Ben Dooks
2008-06-22 20:16 ` [patch v2 10/11] DM9000: Show Mbps on link change if using simple polling Ben Dooks
2008-06-22 20:16 ` [patch v2 11/11] DM9000: Remove DEFAULT_TRIGGER for request_irq() flags Ben Dooks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080622201905.174147020@fluff.org.uk \
    --to=ben-linux@fluff.org \
    --cc=jeff@garzik.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.