diff mbox

[RFC,15/15] via-rhine: add helper (reduce type-unsafe void * assignments).

Message ID 1356967549-5056-16-git-send-email-andi@lisas.de
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Andreas Mohr Dec. 31, 2012, 3:25 p.m. UTC
From: Andreas Mohr <andim2@users.sf.net>

Signed-off-by: Andreas Mohr <andim2@users.sf.net>
---
 drivers/net/ethernet/via/via-rhine.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

Comments

David Miller Dec. 31, 2012, 10:21 p.m. UTC | #1
From: Andreas Mohr <andi@lisas.de>
Date: Mon, 31 Dec 2012 16:25:49 +0100

> From: Andreas Mohr <andim2@users.sf.net>
> 
> Signed-off-by: Andreas Mohr <andim2@users.sf.net>

This is of zero value.

It is just as likely one would forget to use the helper as it would be
to assign pci_get_drvdata() to a pointer of the wrong type.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 051bb95..dd4fd04 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -2411,10 +2411,17 @@  static int rhine_close(struct net_device *dev)
 	return 0;
 }
 
+/* Cast-only helper (try to minimize type-unsafe void * assignments). */
+/* TODO: could be doing the same thing for netdev_priv() use. */
+static inline struct net_device *
+rhine_to_net_device(struct pci_dev *pdev)
+{
+	return pci_get_drvdata(pdev);
+}
 
 static void rhine_remove_one(struct pci_dev *pdev)
 {
-	struct net_device *dev = pci_get_drvdata(pdev);
+	struct net_device *dev = rhine_to_net_device(pdev);
 	struct rhine_private *rp = netdev_priv(dev);
 
 	unregister_netdev(dev);
@@ -2430,7 +2437,7 @@  static void rhine_remove_one(struct pci_dev *pdev)
 static void
 rhine_shutdown_and_keep_wol(struct pci_dev *pdev)
 {
-	struct net_device *dev = pci_get_drvdata(pdev);
+	struct net_device *dev = rhine_to_net_device(pdev);
 	struct rhine_private *rp = netdev_priv(dev);
 	void __iomem *ioaddr = rp->base;
 
@@ -2489,7 +2496,7 @@  rhine_shutdown_and_keep_wol(struct pci_dev *pdev)
 static int rhine_suspend(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
-	struct net_device *dev = pci_get_drvdata(pdev);
+	struct net_device *dev = rhine_to_net_device(pdev);
 	struct rhine_private *rp = netdev_priv(dev);
 
 	if (!netif_running(dev))
@@ -2509,7 +2516,7 @@  static int rhine_suspend(struct device *device)
 static int rhine_resume(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
-	struct net_device *dev = pci_get_drvdata(pdev);
+	struct net_device *dev = rhine_to_net_device(pdev);
 	struct rhine_private *rp = netdev_priv(dev);
 
 	/*