dev->priv to netdev_priv(dev), drivers/net/tokenring/
Replacing accesses to dev->priv to netdev_priv(dev). The replacment is safe when netdev_priv is used to access a private structure that is right next to the net_device structure in memory. Cf http://groups.google.com/group/comp.os.linux.development.system/browse_thread/thread/de19321bcd94dbb8/0d74a4adcd6177bd This is the case when the net_device structure was allocated with a call to alloc_netdev or one of its derivative. Here is an excerpt of the semantic patch that performs the transformation @ rule1 @ type T; struct net_device *dev; @@ dev = ( alloc_netdev | alloc_etherdev | alloc_trdev ) (sizeof(T), ...) @ rule1bis @ struct net_device *dev; expression E; @@ dev->priv = E @ rule2 depends on rule1 && !rule1bis @ struct net_device *dev; type rule1.T; @@ - (T*) dev->priv + netdev_priv(dev) PS: I have performed the same transformation on the whole kernel and it affects around 70 files, most of them in drivers/net/. Should I split my patch for each subnet directories ? (wireless/, wan/, etc) Thanks to Thomas Surrel for helping me refining my semantic patch. Signed-off-by: Yoann Padioleau <padator@wanadoo.fr> 3c359.c | 58 +++++++++++++++++++++++++++++----------------------------- ibmtr.c | 38 +++++++++++++++++++------------------- lanstreamer.c | 32 ++++++++++++++++---------------- madgemc.c | 4 ++-- olympic.c | 36 ++++++++++++++++++------------------ tmspci.c | 4 ++-- 6 files changed, 86 insertions(+), 86 deletions(-) Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
committed by
David S. Miller
parent
af096046f6
commit
eda105317f
@ -690,7 +690,7 @@ static int madgemc_close(struct net_device *dev)
|
||||
static int madgemc_mcaproc(char *buf, int slot, void *d)
|
||||
{
|
||||
struct net_device *dev = (struct net_device *)d;
|
||||
struct net_local *tp = dev->priv;
|
||||
struct net_local *tp = netdev_priv(dev);
|
||||
struct card_info *curcard = tp->tmspriv;
|
||||
int len = 0;
|
||||
|
||||
@ -736,7 +736,7 @@ static int __devexit madgemc_remove(struct device *device)
|
||||
|
||||
BUG_ON(!dev);
|
||||
|
||||
tp = dev->priv;
|
||||
tp = netdev_priv(dev);
|
||||
card = tp->tmspriv;
|
||||
kfree(card);
|
||||
tp->tmspriv = NULL;
|
||||
|
Reference in New Issue
Block a user