Thread (6 messages) 6 messages, 3 authors, 2013-05-02

Re: [PATCHv3 3/3] net: velocity: Add platform device support to VIA velocity driver

From: Russell King - ARM Linux <hidden>
Date: 2013-05-02 17:20:27
Also in: linux-arm-kernel, lkml

On Tue, Apr 30, 2013 at 01:04:50AM +0200, Francois Romieu wrote:
Tony Prisk [off-list ref] :
[...]
quoted
+static int velocity_remove(void *pdev, enum velocity_bus_type bustype)
+{
+	struct net_device *netdev;
+	struct velocity_info *vptr;
+	int pci = (bustype == BUS_PCI) ? 1 : 0;
+
+	if (pci)
+		netdev = pci_get_drvdata(pdev);
+	else
+		netdev = platform_get_drvdata(pdev);
The caller knows how to retrieve the net_device pointer, whence
the struct velocity_info pointer, whence any bustype dependent
function pointer to alleviate the "if (pci)" and CONFIG stuff.

If you are not convinced, please consider turning the void *
into an union *.
The other thing here is that you can just pass a struct device into
these and retrieve the same driver data via:

	netdev = dev_get_drvdata(dev);

as:

static inline void *platform_get_drvdata(const struct platform_device *pdev)
{
        return dev_get_drvdata(&pdev->dev);
}

static inline void *pci_get_drvdata(struct pci_dev *pdev)
{
        return dev_get_drvdata(&pdev->dev);
}

So there's no need for void * or union nonsense.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help