miss list_del(), bug ?

2007-08-28 Thread Yoann Padioleau

Shouldn't this code also do a list_del(e) ? 

in drivers/infiniband/core/iwcm.c:

static void dealloc_work_entries(struct iwcm_id_private *cm_id_priv)
{
struct list_head *e, *tmp;

list_for_each_safe(e, tmp, _id_priv->work_free_list)
kfree(list_entry(e, struct iwcm_work, free_list));
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


miss list_del(), bug ?

2007-08-28 Thread Yoann Padioleau

Shouldn't this code also do a list_del(e) ? 

in drivers/infiniband/core/iwcm.c:

static void dealloc_work_entries(struct iwcm_id_private *cm_id_priv)
{
struct list_head *e, *tmp;

list_for_each_safe(e, tmp, cm_id_priv-work_free_list)
kfree(list_entry(e, struct iwcm_work, free_list));
}

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 06/13] dev->priv to netdev_priv(dev), for drivers/net/ibm_emac

2007-08-03 Thread Yoann Padioleau
Eugene Surovegin <[EMAIL PROTECTED]> writes:

> On Fri, Aug 03, 2007 at 07:34:19PM +0200, Yoann Padioleau wrote:
>> 
>> 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.
>
> NAK.
>
> While that assumption is correct for the actual emac net device, it's 
> not for MAL poll one.

I forgot to add another condition in my semantic patch. 

I was looking only for xxx->priv = yyy; 
with this rule:

@ danger @
struct net_device *dev;
expression E;
@@
 dev->priv = E

whereas sometimes it's written xxx.priv = yyy; 
as in ibm_emac_mal ( mal->poll_dev.priv = mal; )

By adding the following rule in my semantic patch I correctly
_dont_ modify anything under drivers/net/ibm_emac

@ danger @
struct net_device dev;
expression E;
@@
 dev.priv = E


It's also the case for  drivers/net/e1000/e1000_main.c.


>
> You patch breaks a working driver.
>
> -- 
> Eugene

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


dev->priv to netdev_priv(dev)

2007-08-03 Thread Yoann Padioleau
Jeff Garzik <[EMAIL PROTECTED]> writes:

>> 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)
>
> applied.  splitting up by sub-directory would be helpful.

Done. I was not always able to find the maintainer for all the subdirectories
so for those cases I have considered you as the maintainer :)

I have run another semantic patch (more like a semantic grep in fact)
to find the places where our tool didn't transform the dev->priv to
netdev_priv. The reason is that our tool was not able to find the call
to alloc_dev_xxx(sizeof(T),...) in the driver or there was an
assignation to dev->priv which means that transforming to netdev_priv
would do something wrong. I have printed the list of "bad driver"
below.

In very few cases the driver was in fact "good" but because of the
way the code was written, our tool was not able to find the alloc_xxx
function.



drivers/net/82596.c 
drivers/net/chelsio/cxgb2.c 
drivers/net/chelsio/sge.c   
drivers/net/cxgb3/cxgb3_main.c  
drivers/net/cxgb3/sge.c 
drivers/net/e1000/e1000_main.c  
drivers/net/ehea/ehea_main.c
drivers/net/hamradio/dmascc.c   
drivers/net/hamradio/scc.c  
drivers/net/lance.c 
drivers/net/mace.c  

 for mace.c the code is written this way:

#define PRIV_BYTES  (sizeof(struct mace_data) \
   + (N_RX_RING + NCMDS_TX * N_TX_RING + 3) * sizeof(struct dbdma_cmd))

 dev = alloc_etherdev(PRIV_BYTES);
 
 So our semantic patch can't find a   alloc_etherdev(sizeof(T)).
 If I inline the definition of PRIV_BYTES, then our tool will be
 able to transform it.

 


drivers/net/ni65.c  
drivers/net/pcmcia/com20020_cs.c

   dev = alloc_arcdev("");
 

drivers/net/ppp_generic.c   
drivers/net/spider_net_ethtool.c 

 again, the code is written this way:

   alloc_size = sizeof(struct spider_net_card) +
  (tx_descriptors + rx_descriptors) * sizeof(struct spider_net_descr);
   netdev = alloc_etherdev(alloc_size);

 If I inline the definition of alloc_size, then we can transform
 the file.

drivers/net/tulip/xircom_cb.c   
drivers/net/wan/cosa.c  
drivers/net/wan/cycx_x25.c  
drivers/net/wan/hdlc_fr.c   
drivers/net/wan/hdlc_ppp.c  
drivers/net/wan/hostess_sv11.c  
drivers/net/wan/pc300_drv.c 
drivers/net/wan/sbni.c  
drivers/net/wireless/airo.c 
drivers/net/wireless/libertas/ethtool.c 
drivers/net/wireless/libertas/main.c
drivers/net/wireless/libertas/scan.c
drivers/net/wireless/libertas/wext.c
drivers/net/wireless/wavelan.c  
drivers/net/wireless/zd1201.c   

drivers/net/tokenring/tms380tr.c
   This file is both used as a single module and used by other module.
   The other modules have a call to a alloc_xxx but not tms380tr.c when
   used as a single module. 
  

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/13] dev->priv to netdev_priv(dev), for drivers/net/wireless

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/wireless/arlan-proc.c  |   14 +++---
 drivers/net/wireless/hostap/hostap_cs.c|2 
 drivers/net/wireless/hostap/hostap_hw.c|2 
 drivers/net/wireless/hostap/hostap_ioctl.c |   14 +++---
 drivers/net/wireless/orinoco_tmd.c |2 
 drivers/net/wireless/prism54/isl_ioctl.c   |6 +-
 drivers/net/wireless/ray_cs.c  |   66 ++---
 drivers/net/wireless/strip.c   |2 
 drivers/net/wireless/wl3501_cs.c   |   66 ++---
 9 files changed, 87 insertions(+), 87 deletions(-)

diff --git a/drivers/net/wireless/arlan-proc.c 
b/drivers/net/wireless/arlan-proc.c
index 015abd9..c6e70db 100644
--- a/drivers/net/wireless/arlan-proc.c
+++ b/drivers/net/wireless/arlan-proc.c
@@ -435,7 +435,7 @@ static int arlan_sysctl_info(ctl_table *
goto final;
}
else
-   priva = arlan_device[devnum]->priv;
+   priva = netdev_priv(arlan_device[devnum]);
 
if (priva == NULL)
{
@@ -654,7 +654,7 @@ static int arlan_sysctl_info161719(ctl_t
goto final;
}
else
-   priva = arlan_device[devnum]->priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING " Could not find the device private in 
arlan procsys, bad\n ");
@@ -688,7 +688,7 @@ static int arlan_sysctl_infotxRing(ctl_t
  goto final;
}
else
-   priva = arlan_device[devnum]->priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING " Could not find the device private in 
arlan procsys, bad\n ");
@@ -716,7 +716,7 @@ static int arlan_sysctl_inforxRing(ctl_t
  pos += sprintf(arlan_drive_info + pos, "No device found here 
\n");
  goto final;
} else
-   priva = arlan_device[devnum]->priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING " Could not find the device private in 
arlan procsys, bad\n ");
@@ -745,7 +745,7 @@ static int arlan_sysctl_info18(ctl_table
goto final;
}
else
-   priva = arlan_device[devnum]->priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING " Could not find the device private in 
arlan procsys, bad\n ");
@@ -780,7 +780,7 @@ static int arlan_configure(ctl_table * c
}
else if (arlan_device[devnum] != NULL)
{
- priv = arlan_device[devnum]->priv;
+ priv = netdev_priv(arlan_device[devnum]);
 
  arlan_command(arlan_device[devnum], 
ARLAN_COMMAND_CLEAN_AND_CONF);
}
@@ -805,7 +805,7 @@ static int arlan_sysctl_reset(ctl_table 
}
else if (arlan_device[devnum] != NULL)
{
-   priv = arlan_device[devnum]->priv;
+   priv = netdev_priv(arlan_device[devnum]);
arlan_command(arlan_device[devnum], 
ARLAN_COMMAND_CLEAN_AND_RESET);
 
} else
diff --git a/drivers/net/wireless/hostap/hostap_cs.c 
b/drivers/net/wireless/hostap/hostap_cs.c
index 30e723f..f9cf22b 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -272,7 +272,7 @@ static int sandisk_enable_wireless(struc
 {
int res, ret = 0;
conf_reg_t reg;
-   struct hostap_interface *iface = dev->priv;
+   struct hostap_interface *iface = netdev_priv(dev);
local_info_t *local = iface->local;
tuple_t tuple;
cisparse_t *parse = NULL;
diff --git a/drivers/net/wireless/hostap/hostap_hw.c 
b/drivers/net/wireless/hostap/hostap_hw.c
index 959887b..18023b5 100644
--

[PATCH 08/13] dev->priv to netdev_priv(dev), for drivers/net/netxen

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/netxen/netxen_nic_main.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 08a62ac..c14c178 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -329,7 +329,7 @@ netxen_nic_probe(struct pci_dev *pdev, c
SET_MODULE_OWNER(netdev);
SET_NETDEV_DEV(netdev, >dev);
 
-   adapter = netdev->priv;
+   adapter = netdev_priv(netdev);
memset(adapter, 0 , sizeof(struct netxen_adapter));
 
adapter->ahw.pdev = pdev;
@@ -850,7 +850,7 @@ static void __devexit netxen_nic_remove(
  */
 static int netxen_nic_open(struct net_device *netdev)
 {
-   struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv;
+   struct netxen_adapter *adapter = netdev_priv(netdev);
int err = 0;
int ctx, ring;
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/13] dev->priv to netdev_priv(dev), for drivers/net/wan

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/wan/dlci.c |   30 +-
 drivers/net/wan/lmc/lmc_main.c |   26 +++
 drivers/net/wan/sdla.c |   46 -
 drivers/net/wan/sealevel.c |   12 +-
 drivers/net/wan/x25_asy.c  |   28 
 5 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index 66be20c..d988161 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -74,7 +74,7 @@ static int dlci_header(struct sk_buff *s
unsigned inthlen;
char*dest;
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
hdr.control = FRAD_I_UI;
switch(type)
@@ -110,7 +110,7 @@ static void dlci_receive(struct sk_buff 
struct frhdr*hdr;
int process, header;
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
if (!pskb_may_pull(skb, sizeof(*hdr))) {
printk(KERN_NOTICE "%s: invalid data no header\n",
   dev->name);
@@ -197,7 +197,7 @@ static int dlci_transmit(struct sk_buff 
if (!skb || !dev)
return(0);
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
netif_stop_queue(dev);

@@ -235,7 +235,7 @@ static int dlci_config(struct net_device
struct frad_local   *flp;
int err;
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
flp = dlp->slave->priv;
 
@@ -269,7 +269,7 @@ static int dlci_dev_ioctl(struct net_dev
if (!capable(CAP_NET_ADMIN))
return(-EPERM);
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
switch(cmd)
{
@@ -298,7 +298,7 @@ static int dlci_change_mtu(struct net_de
 {
struct dlci_local *dlp;
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
return((*dlp->slave->change_mtu)(dlp->slave, new_mtu));
 }
@@ -309,7 +309,7 @@ static int dlci_open(struct net_device *
struct frad_local   *flp;
int err;
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
if (!*(short *)(dev->dev_addr))
return(-EINVAL);
@@ -335,7 +335,7 @@ static int dlci_close(struct net_device 
 
netif_stop_queue(dev);
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
flp = dlp->slave->priv;
err = (*flp->deactivate)(dlp->slave, dev);
@@ -347,7 +347,7 @@ static struct net_device_stats *dlci_get
 {
struct dlci_local *dlp;
 
-   dlp = dev->priv;
+   dlp = netdev_priv(dev);
 
return(>stats);
 }
@@ -365,7 +365,7 @@ static int dlci_add(struct dlci_add *dlc
if (!slave)
return -ENODEV;
 
-   if (slave->type != ARPHRD_FRAD || slave->priv == NULL)
+   if (slave->type != ARPHRD_FRAD || netdev_priv(slave) == NULL)
goto err1;
 
/* create device name */
@@ -391,11 +391,11 @@ static int dlci_add(struct dlci_add *dlc
 
*(short *)(master->dev_addr) = dlci->dlci;
 
-   dlp = (struct dlci_local *) master->priv;
+   dlp = netdev_priv(master);
dlp->slave = slave;
dlp->master = master;
 
-   flp = slave->priv;
+   flp = netdev_priv(slave);
err = (*flp->assoc)(slave, master);
if (err < 0)
goto err2;
@@ -435,9 +435,9 @@ static int dlci_del(struct dlci_add *dlc
return(-EBUSY);
}
 
-   dlp = master->priv;
+   dlp = netdev_priv(master);
slave = dlp->slave;
-   flp = slave->priv;
+   flp = netdev_priv(slave);
 
rtnl_lock();
err = (*flp->deassoc)(slave, master);
@@ -487,7 +487,7 @@ static int dlci_ioctl(unsigned int cmd, 
 
 static void dlci_setup(s

[PATCH 10/13] dev->priv to netdev_priv(dev), for drivers/net/tulip

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/tulip/de2104x.c |   44 ++--
 drivers/net/tulip/eeprom.c  |2 +-
 drivers/net/tulip/uli526x.c |2 +-
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index d380e0b..4ba3a7b 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -486,7 +486,7 @@ rx_next:
 static irqreturn_t de_interrupt (int irq, void *dev_instance)
 {
struct net_device *dev = dev_instance;
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
u32 status;
 
status = dr32(MacStatus);
@@ -592,7 +592,7 @@ next:
 
 static int de_start_xmit (struct sk_buff *skb, struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
unsigned int entry, tx_free;
u32 mapping, len, flags = FirstFrag | LastFrag;
struct de_desc *txd;
@@ -655,7 +655,7 @@ #define set_bit_le(i,p) do { ((char *)(p
 
 static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
u16 hash_table[32];
struct dev_mc_list *mclist;
int i;
@@ -686,7 +686,7 @@ static void build_setup_frame_hash(u16 *
 
 static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
struct dev_mc_list *mclist;
int i;
u16 *eaddrs;
@@ -714,7 +714,7 @@ static void build_setup_frame_perfect(u1
 
 static void __de_set_rx_mode (struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
u32 macmode;
unsigned int entry;
u32 mapping;
@@ -799,7 +799,7 @@ out:
 static void de_set_rx_mode (struct net_device *dev)
 {
unsigned long flags;
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
 
spin_lock_irqsave (>lock, flags);
__de_set_rx_mode(dev);
@@ -823,7 +823,7 @@ static void __de_get_stats(struct de_pri
 
 static struct net_device_stats *de_get_stats(struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
 
/* The chip only need report frame silently dropped. */
spin_lock_irq(>lock);
@@ -1352,7 +1352,7 @@ static void de_free_rings (struct de_pri
 
 static int de_open (struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
int rc;
 
if (netif_msg_ifup(de))
@@ -1397,7 +1397,7 @@ err_out_free:
 
 static int de_close (struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
unsigned long flags;
 
if (netif_msg_ifdown(de))
@@ -1421,7 +1421,7 @@ static int de_close (struct net_device *
 
 static void de_tx_timeout (struct net_device *dev)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
 
printk(KERN_DEBUG "%s: NIC status %08x mode %08x sia %08x desc 
%u/%u/%u\n",
   dev->name, dr32(MacStatus), dr32(MacMode), dr32(SIAStatus),
@@ -1572,7 +1572,7 @@ static int __de_set_settings(struct de_p
 
 static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo 
*info)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_priv(dev);
 
strcpy (info->driver, DRV_NAME);
strcpy (info->version, DRV_VERSION);
@@ -1587,7 +1587,7 @@ static int de_get_regs_len(struct net_de
 
 static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
-   struct de_private *de = dev->priv;
+   struct de_private *de = netdev_pri

[PATCH 11/13] dev->priv to netdev_priv(dev), for drivers/net/usb

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/usb/mcs7830.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 6240b97..37ad14b 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -341,14 +341,14 @@ out:
 static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
 int location)
 {
-   struct usbnet *dev = netdev->priv;
+   struct usbnet *dev = netdev_priv(netdev);
return mcs7830_read_phy(dev, location);
 }
 
 static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
int location, int val)
 {
-   struct usbnet *dev = netdev->priv;
+   struct usbnet *dev = netdev_priv(netdev);
mcs7830_write_phy(dev, location, val);
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/13] dev->priv to netdev_priv(dev), for drivers/net/tokenring

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/tokenring/3c359.c   |   58 ++--
 drivers/net/tokenring/ibmtr.c   |   38 +++
 drivers/net/tokenring/lanstreamer.c |   32 +--
 drivers/net/tokenring/madgemc.c |4 +-
 drivers/net/tokenring/olympic.c |   36 +++---
 drivers/net/tokenring/tmspci.c  |4 +-
 6 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 9f1b6ab..a8573da 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -156,7 +156,7 @@ static void print_rx_state(struct net_de
 static void print_tx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_tx_desc *txd ; 
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
int i ; 
@@ -179,7 +179,7 @@ static void print_tx_state(struct net_de
 static void print_rx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_rx_desc *rxd ; 
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
int i ; 
@@ -213,7 +213,7 @@ #endif
 
 static u16 xl_ee_read(struct net_device *dev, int ee_addr)
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -245,7 +245,7 @@ static u16 xl_ee_read(struct net_device 
 
 static void  xl_ee_write(struct net_device *dev, int ee_addr, u16 ee_value) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -305,11 +305,11 @@ static int __devinit xl_probe(struct pci
pci_release_regions(pdev) ; 
return -ENOMEM ; 
} 
-   xl_priv = dev->priv ; 
+   xl_priv = netdev_priv(dev) ; 
 
 #if XL_DEBUG  
printk("pci_device: %p, dev:%p, dev->priv: %p, ba[0]: %10x, 
ba[1]:%10x\n", 
-   pdev, dev, dev->priv, (unsigned int)pdev->resource[0].start, 
(unsigned int)pdev->resource[1].start) ;  
+   pdev, dev, netdev_priv(dev), (unsigned 
int)pdev->resource[0].start, (unsigned int)pdev->resource[1].start) ;  
 #endif 
 
dev->irq=pdev->irq;
@@ -365,7 +365,7 @@ #endif 
 
 static int __devinit xl_init(struct net_device *dev) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
 
printk(KERN_INFO "%s \n", version);
printk(KERN_INFO "%s: I/O at %hx, MMIO at %p, using irq %d\n",
@@ -385,7 +385,7 @@ static int __devinit xl_init(struct net_
 
 static int xl_hw_reset(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
unsigned long t ; 
u16 i ; 
@@ -568,7 +568,7 @@ #endif
 
 static int xl_open(struct net_device *dev) 
 {
-   struct xl_private *xl_priv=(struct xl_private *)dev->priv;
+   struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
u8 i ; 
u16 hwaddr[3] ; /* Should be u8[6] but we get word return values */
@@ -726,7 +726,7 @@ static int xl_open(struct net_device *de
 
 static int xl_open_hw(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv=(struct xl_private *)dev->priv;
+   struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
u16 vsoff

[PATCH 06/13] dev->priv to netdev_priv(dev), for drivers/net/ibm_emac

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/ibm_emac/ibm_emac_core.c |   42 +--
 drivers/net/ibm_emac/ibm_emac_mal.c  |2 -
 drivers/net/ibm_emac/ibm_emac_phy.c  |2 -
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ibm_emac/ibm_emac_core.c 
b/drivers/net/ibm_emac/ibm_emac_core.c
index f752e5f..cefadc1 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -531,7 +531,7 @@ static void emac_reinitialize(struct ocp
 /* BHs disabled */
 static void emac_full_tx_reset(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ocp_func_emac_data *emacdata = dev->def->additions;
 
DBG("%d: full_tx_reset" NL, dev->def->index);
@@ -639,7 +639,7 @@ static void __emac_mdio_write(struct ocp
 
 static int emac_mdio_read(struct net_device *ndev, int id, int reg)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
int res;
 
local_bh_disable();
@@ -651,7 +651,7 @@ static int emac_mdio_read(struct net_dev
 
 static void emac_mdio_write(struct net_device *ndev, int id, int reg, int val)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
 
local_bh_disable();
__emac_mdio_write(dev->mdio_dev ? dev->mdio_dev : dev, (u8) id,
@@ -662,7 +662,7 @@ static void emac_mdio_write(struct net_d
 /* BHs disabled */
 static void emac_set_multicast_list(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct emac_regs __iomem *p = dev->emacp;
u32 rmr = emac_iff2rmr(ndev);
 
@@ -764,7 +764,7 @@ static int emac_resize_rx_ring(struct oc
 /* Process ctx, rtnl_lock semaphore */
 static int emac_change_mtu(struct net_device *ndev, int new_mtu)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
int ret = 0;
 
if (new_mtu < EMAC_MIN_MTU || new_mtu > EMAC_MAX_MTU)
@@ -857,7 +857,7 @@ static void emac_print_link_status(struc
 /* Process ctx, rtnl_lock semaphore */
 static int emac_open(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ocp_func_emac_data *emacdata = dev->def->additions;
int err, i;
 
@@ -1005,7 +1005,7 @@ static void emac_force_link_update(struc
 /* Process ctx, rtnl_lock semaphore */
 static int emac_close(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ocp_func_emac_data *emacdata = dev->def->additions;
 
DBG("%d: close" NL, dev->def->index);
@@ -1065,7 +1065,7 @@ static inline int emac_xmit_finish(struc
 /* BHs disabled */
 static int emac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
unsigned int len = skb->len;
int slot;
 
@@ -1123,7 +1123,7 @@ static inline int emac_xmit_split(struct
 /* BHs disabled (SG version for TAH equipped EMACs) */
 static int emac_start_xmit_sg(struct sk_buff *skb, struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
int nr_frags = skb_shinfo(skb)->nr_frags;
int len = skb->len, chunk;
int slot, i;
@@ -1559,7 +1559,7 @@ static irqreturn_t emac_irq(int irq, voi
 
 static struct net_device_stats *emac_stats(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev->priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ibm_emac_stats *st = >stats

[PATCH 07/13] dev->priv to netdev_priv(dev), for drivers/net/irda

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/irda/ali-ircc.c|   16 
 drivers/net/irda/donauboe.c|8 
 drivers/net/irda/irda-usb.c|   14 +++---
 drivers/net/irda/irport.c  |   20 ++--
 drivers/net/irda/nsc-ircc.c|   16 
 drivers/net/irda/sa1100_ir.c   |   26 +-
 drivers/net/irda/sir_dev.c |   12 ++--
 drivers/net/irda/via-ircc.c|   16 
 drivers/net/irda/vlsi_ir.c |   36 ++--
 drivers/net/irda/w83977af_ir.c |   14 +++---
 10 files changed, 89 insertions(+), 89 deletions(-)

diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index f9c889c..0300aac 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -291,7 +291,7 @@ static int ali_ircc_open(int i, chipio_t
return -ENOMEM;
}
 
-   self = dev->priv;
+   self = netdev_priv(dev);
self->netdev = dev;
spin_lock_init(>lock);

@@ -668,7 +668,7 @@ static irqreturn_t ali_ircc_interrupt(in

IRDA_DEBUG(2, "%s(),  Start \n", 
__FUNCTION__);

-   self = dev->priv;
+   self = netdev_priv(dev);

spin_lock(>lock);

@@ -1336,7 +1336,7 @@ static int ali_ircc_net_open(struct net_

IRDA_ASSERT(dev != NULL, return -1;);

-   self = (struct ali_ircc_cb *) dev->priv;
+   self = netdev_priv(dev);

IRDA_ASSERT(self != NULL, return 0;);

@@ -1399,7 +1399,7 @@ static int ali_ircc_net_close(struct net

IRDA_ASSERT(dev != NULL, return -1;);
 
-   self = (struct ali_ircc_cb *) dev->priv;
+   self = netdev_priv(dev);
IRDA_ASSERT(self != NULL, return 0;);
 
/* Stop device */
@@ -1439,7 +1439,7 @@ static int ali_ircc_fir_hard_xmit(struct

IRDA_DEBUG(1, "%s(),  Start -\n", 
__FUNCTION__ );   

-   self = (struct ali_ircc_cb *) dev->priv;
+   self = netdev_priv(dev);
iobase = self->io.fir_base;
 
netif_stop_queue(dev);
@@ -1963,7 +1963,7 @@ static int ali_ircc_sir_hard_xmit(struct

IRDA_ASSERT(dev != NULL, return 0;);

-   self = (struct ali_ircc_cb *) dev->priv;
+   self = netdev_priv(dev);
IRDA_ASSERT(self != NULL, return 0;);
 
iobase = self->io.sir_base;
@@ -2031,7 +2031,7 @@ static int ali_ircc_net_ioctl(struct net

IRDA_ASSERT(dev != NULL, return -1;);
 
-   self = dev->priv;
+   self = netdev_priv(dev);
 
IRDA_ASSERT(self != NULL, return -1;);
 
@@ -2117,7 +2117,7 @@ static int ali_ircc_is_receiving(struct 
 
 static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev)
 {
-   struct ali_ircc_cb *self = (struct ali_ircc_cb *) dev->priv;
+   struct ali_ircc_cb *self = netdev_priv(dev);

IRDA_DEBUG(2, "%s(),  Start \n", 
__FUNCTION__ );

diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 3ca47bf..fd7602e 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -983,7 +983,7 @@ toshoboe_hard_xmit (struct sk_buff *skb,
   unsigned long flags;
   struct irda_skb_cb *cb = (struct irda_skb_cb *) skb->cb;
 
-  self = (struct toshoboe_cb *) dev->priv;
+  self = netdev_priv(dev);
 
   IRDA_ASSERT (self != NULL, return 0; );
 
@@ -1388,7 +1388,7 @@ toshoboe_net_close (struct net_device *d
   IRDA_DEBUG (4, "%s()\n", __FUNCTION__);
 
   IRDA_ASSERT (dev != NULL, return -1; );
-  self = (struct toshoboe_cb *) dev->priv;
+  self = netdev_priv(dev);
 
   /* Stop device */
   netif_stop_queue(dev);
@@ -1426,7 +1426,7 @@ toshoboe_net_ioctl (struct net_device *d
 
   IRDA_ASSERT (dev != NULL, return -1; );
 
-  s

[PATCH 04/13] dev->priv to netdev_priv(dev), for drivers/net/bonding

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/bonding/bond_3ad.c  |6 +--
 drivers/net/bonding/bond_alb.c  |6 +--
 drivers/net/bonding/bond_main.c |   62 
 3 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index f829e4a..9ad88d0 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2364,7 +2364,7 @@ int bond_3ad_get_active_agg_info(struct 
 int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
 {
struct slave *slave, *start_at;
-   struct bonding *bond = dev->priv;
+   struct bonding *bond = netdev_priv(dev);
int slave_agg_no;
int slaves_in_agg;
int agg_id;
@@ -2444,7 +2444,7 @@ out:
 
 int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct 
packet_type* ptype, struct net_device *orig_dev)
 {
-   struct bonding *bond = dev->priv;
+   struct bonding *bond = netdev_priv(dev);
struct slave *slave = NULL;
int ret = NET_RX_DROP;
 
@@ -2452,7 +2452,7 @@ int bond_3ad_lacpdu_recv(struct sk_buff 
goto out;
 
read_lock(>lock);
-   slave = bond_get_slave_by_dev((struct bonding *)dev->priv, orig_dev);
+   slave = bond_get_slave_by_dev(netdev_priv(dev), orig_dev);
if (!slave)
goto out_unlock;
 
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 92c3b6f..c90524b 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -341,7 +341,7 @@ static void rlb_update_entry_from_arp(st
 
 static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, 
struct packet_type *ptype, struct net_device *orig_dev)
 {
-   struct bonding *bond = bond_dev->priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct arp_pkt *arp = (struct arp_pkt *)skb->data;
int res = NET_RX_DROP;
 
@@ -1260,7 +1260,7 @@ void bond_alb_deinitialize(struct bondin
 
 int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 {
-   struct bonding *bond = bond_dev->priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct ethhdr *eth_data;
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
struct slave *tx_slave = NULL;
@@ -1621,7 +1621,7 @@ void bond_alb_handle_active_change(struc
 
 int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
 {
-   struct bonding *bond = bond_dev->priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct sockaddr *sa = addr;
struct slave *slave, *swap_slave;
int res;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 070b78d..08f5fcc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -425,7 +425,7 @@ int bond_dev_queue_xmit(struct bonding *
  */
 static void bond_vlan_rx_register(struct net_device *bond_dev, struct 
vlan_group *grp)
 {
-   struct bonding *bond = bond_dev->priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
int i;
 
@@ -448,7 +448,7 @@ static void bond_vlan_rx_register(struct
  */
 static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
 {
-   struct bonding *bond = bond_dev->priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
int i, res;
 
@@ -476,7 +476,7 @@ static void bond_vlan_rx_add_vid(struct 
  */
 static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
 {
-   struct bonding *bond = bond_dev->priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
struct net_device *vlan_dev;
int i, res;
@@ -900,7 +900,7 @@ static int bond_mc_list_copy(struct dev_
  */
 static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device 
*slave_dev)
 {
-

[PATCH 05/13] dev->priv to netdev_priv(dev), for drivers/net/cris

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/cris/eth_v10.c |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 5bdf5ca..39afed7 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -474,7 +474,7 @@ etrax_ethernet_init(void)
   "ETRAX 100LX 10/100MBit ethernet v2.0 (c) 2000-2003 Axis 
Communications AB\n");
 
dev = alloc_etherdev(sizeof(struct net_local));
-   np = dev->priv;
+   np = netdev_priv(dev);
 
if (!dev)
return -ENOMEM;
@@ -595,7 +595,7 @@ etrax_ethernet_init(void)
 static int
 e100_set_mac_address(struct net_device *dev, void *p)
 {
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netdev_priv(dev);
struct sockaddr *addr = p;
int i;
 
@@ -911,7 +911,7 @@ static void
 e100_check_duplex(unsigned long priv)
 {
struct net_device *dev = (struct net_device *)priv;
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netdev_priv(dev);
int old_duplex = full_duplex;
transceiver->check_duplex(dev);
if (old_duplex != full_duplex) {
@@ -1116,7 +1116,7 @@ e100_reset_transceiver(struct net_device
 static void
 e100_tx_timeout(struct net_device *dev)
 {
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netdev_priv(dev);
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
@@ -1165,7 +1165,7 @@ e100_tx_timeout(struct net_device *dev)
 static int
 e100_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netdev_priv(dev);
unsigned char *buf = skb->data;
unsigned long flags;
 
@@ -1201,7 +1201,7 @@ static irqreturn_t
 e100rxtx_interrupt(int irq, void *dev_id)
 {
struct net_device *dev = (struct net_device *)dev_id;
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netdev_priv(dev);
unsigned long irqbits = *R_IRQ_MASK2_RD;
 
/* Disable RX/TX IRQs to avoid reentrancy */
@@ -1223,7 +1223,7 @@ e100rxtx_interrupt(int irq, void *dev_id
 * allocate a new buffer to put a packet in.
 */
e100_rx(dev);
-   ((struct net_local *)dev->priv)->stats.rx_packets++;
+   ((struct net_local 
*)netdev_priv(dev))->stats.rx_packets++;
/* restart/continue on the channel, for safety */
*R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, restart);
/* clear dma channel 1 eop/descr irq bits */
@@ -1268,7 +1268,7 @@ static irqreturn_t
 e100nw_interrupt(int irq, void *dev_id)
 {
struct net_device *dev = (struct net_device *)dev_id;
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netdev_priv(dev);
unsigned long irqbits = *R_IRQ_MASK0_RD;
 
/* check for underrun irq */
@@ -1303,7 +1303,7 @@ e100_rx(struct net_device *dev)
 {
struct sk_buff *skb;
int length = 0;
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netdev_priv(dev);
unsigned char *skb_data_ptr;
 #ifdef ETHDEBUG
int i;
@@ -1320,7 +1320,7 @@ #endif
}
 
length = myNextRxDesc->descr.hw_len - 4;
-   ((struct net_local *)dev->priv)->stats.rx_bytes += length;
+   ((struct net_local *)netdev_priv(dev))->stats.rx_bytes += length;
 
 #ifdef ETHDEBUG
printk("Got a packet of length %d:\n", length);
@@ -1402,7 +1402,7 @@ #endif
 static int
 e100_close(struct net_device *dev)
 {
-   struct net_local *np = (struct net_local *)dev->priv;
+   struct net_local *np = netd

[PATCH 02/13] dev->priv to netdev_priv(dev), for drivers/net/appletalk

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/appletalk/ipddp.c |6 +++---
 drivers/net/appletalk/ltpc.c  |8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index f22e46d..61add0e 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -109,7 +109,7 @@ static struct net_device * __init ipddp_
  */
 static struct net_device_stats *ipddp_get_stats(struct net_device *dev)
 {
-return dev->priv;
+return netdev_priv(dev);
 }
 
 /*
@@ -171,8 +171,8 @@ static int ipddp_xmit(struct sk_buff *sk
 
 skb->protocol = htons(ETH_P_ATALK); /* Protocol has changed */
 
-   ((struct net_device_stats *) dev->priv)->tx_packets++;
-((struct net_device_stats *) dev->priv)->tx_bytes+=skb->len;
+   ((struct net_device_stats *)netdev_priv(dev))->tx_packets++;
+((struct net_device_stats *)netdev_priv(dev))->tx_bytes+=skb->len;
 
 if(aarp_send_ddp(rt->dev, skb, >at, NULL) < 0)
 dev_kfree_skb(skb);
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index 6a6cbd3..be12c6b 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -726,7 +726,7 @@ static int sendup_buffer (struct net_dev
int dnode, snode, llaptype, len; 
int sklen;
struct sk_buff *skb;
-   struct net_device_stats *stats = &((struct ltpc_private 
*)dev->priv)->stats;
+   struct net_device_stats *stats = &((struct ltpc_private 
*)netdev_priv(dev))->stats;
struct lt_rcvlap *ltc = (struct lt_rcvlap *) ltdmacbuf;
 
if (ltc->command != LT_RCVLAP) {
@@ -823,7 +823,7 @@ static int ltpc_ioctl(struct net_device 
 {
struct sockaddr_at *sa = (struct sockaddr_at *) >ifr_addr;
/* we'll keep the localtalk node address in dev->pa_addr */
-   struct atalk_addr *aa = &((struct ltpc_private *)dev->priv)->my_addr;
+   struct atalk_addr *aa = &((struct ltpc_private 
*)netdev_priv(dev))->my_addr;
struct lt_init c;
int ltflags;
 
@@ -913,7 +913,7 @@ static int ltpc_xmit(struct sk_buff *skb
 * and skb->len is the length of the ddp data + ddp header
 */
 
-   struct net_device_stats *stats = &((struct ltpc_private 
*)dev->priv)->stats;
+   struct net_device_stats *stats = &((struct ltpc_private 
*)netdev_priv(dev))->stats;
 
int i;
struct lt_sendlap cbuf;
@@ -952,7 +952,7 @@ static int ltpc_xmit(struct sk_buff *skb
 
 static struct net_device_stats *ltpc_get_stats(struct net_device *dev)
 {
-   struct net_device_stats *stats = &((struct ltpc_private *) 
dev->priv)->stats;
+   struct net_device_stats *stats = &((struct ltpc_private 
*)netdev_priv(dev))->stats;
return stats;
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/13] dev->priv to netdev_priv(dev), for drivers/net/arcnet

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/arcnet/arc-rawmode.c  |4 ++--
 drivers/net/arcnet/arc-rimi.c |   16 
 drivers/net/arcnet/arcnet.c   |   32 
 drivers/net/arcnet/capmode.c  |6 +++---
 drivers/net/arcnet/com20020-isa.c |4 ++--
 drivers/net/arcnet/com20020-pci.c |2 +-
 drivers/net/arcnet/com20020.c |   10 +-
 drivers/net/arcnet/com90io.c  |4 ++--
 drivers/net/arcnet/com90xx.c  |   10 +-
 drivers/net/arcnet/rfc1051.c  |8 
 drivers/net/arcnet/rfc1201.c  |   12 ++--
 11 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index e0a18e7..909ba77 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -87,7 +87,7 @@ MODULE_LICENSE("GPL");
 static void rx(struct net_device *dev, int bufnum,
   struct archdr *pkthdr, int length)
 {
-   struct arcnet_local *lp = dev->priv;
+   struct arcnet_local *lp = netdev_priv(dev);
struct sk_buff *skb;
struct archdr *pkt = pkthdr;
int ofs;
@@ -168,7 +168,7 @@ static int build_header(struct sk_buff *
 static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
  int bufnum)
 {
-   struct arcnet_local *lp = dev->priv;
+   struct arcnet_local *lp = netdev_priv(dev);
struct arc_hardware *hard = >hard;
int ofs;
 
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 8c8d6c4..e3082a9 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -194,7 +194,7 @@ static int __init arcrimi_found(struct n
 
/* initialize the rest of the device structure. */
 
-   lp = dev->priv;
+   lp = netdev_priv(dev);
lp->card_name = "RIM I";
lp->hw.command = arcrimi_command;
lp->hw.status = arcrimi_status;
@@ -260,7 +260,7 @@ err_free_irq:
  */
 static int arcrimi_reset(struct net_device *dev, int really_reset)
 {
-   struct arcnet_local *lp = dev->priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;
 
BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS());
@@ -281,7 +281,7 @@ static int arcrimi_reset(struct net_devi
 
 static void arcrimi_setmask(struct net_device *dev, int mask)
 {
-   struct arcnet_local *lp = dev->priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;
 
AINTMASK(mask);
@@ -289,7 +289,7 @@ static void arcrimi_setmask(struct net_d
 
 static int arcrimi_status(struct net_device *dev)
 {
-   struct arcnet_local *lp = dev->priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;
 
return ASTATUS();
@@ -297,7 +297,7 @@ static int arcrimi_status(struct net_dev
 
 static void arcrimi_command(struct net_device *dev, int cmd)
 {
-   struct arcnet_local *lp = dev->priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;
 
ACOMMAND(cmd);
@@ -306,7 +306,7 @@ static void arcrimi_command(struct net_d
 static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int 
offset,
 void *buf, int count)
 {
-   struct arcnet_local *lp = dev->priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
 }
@@ -315,7 +315,7 @@ static void arcrimi_copy_to_card(struct 
 static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int 
offset,
   void *buf, int count)
 {
-   struct arcnet_local *lp = dev->priv;

[PATCH 02/13] dev-priv to netdev_priv(dev), for drivers/net/appletalk

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/appletalk/ipddp.c |6 +++---
 drivers/net/appletalk/ltpc.c  |8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index f22e46d..61add0e 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -109,7 +109,7 @@ static struct net_device * __init ipddp_
  */
 static struct net_device_stats *ipddp_get_stats(struct net_device *dev)
 {
-return dev-priv;
+return netdev_priv(dev);
 }
 
 /*
@@ -171,8 +171,8 @@ static int ipddp_xmit(struct sk_buff *sk
 
 skb-protocol = htons(ETH_P_ATALK); /* Protocol has changed */
 
-   ((struct net_device_stats *) dev-priv)-tx_packets++;
-((struct net_device_stats *) dev-priv)-tx_bytes+=skb-len;
+   ((struct net_device_stats *)netdev_priv(dev))-tx_packets++;
+((struct net_device_stats *)netdev_priv(dev))-tx_bytes+=skb-len;
 
 if(aarp_send_ddp(rt-dev, skb, rt-at, NULL)  0)
 dev_kfree_skb(skb);
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index 6a6cbd3..be12c6b 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -726,7 +726,7 @@ static int sendup_buffer (struct net_dev
int dnode, snode, llaptype, len; 
int sklen;
struct sk_buff *skb;
-   struct net_device_stats *stats = ((struct ltpc_private 
*)dev-priv)-stats;
+   struct net_device_stats *stats = ((struct ltpc_private 
*)netdev_priv(dev))-stats;
struct lt_rcvlap *ltc = (struct lt_rcvlap *) ltdmacbuf;
 
if (ltc-command != LT_RCVLAP) {
@@ -823,7 +823,7 @@ static int ltpc_ioctl(struct net_device 
 {
struct sockaddr_at *sa = (struct sockaddr_at *) ifr-ifr_addr;
/* we'll keep the localtalk node address in dev-pa_addr */
-   struct atalk_addr *aa = ((struct ltpc_private *)dev-priv)-my_addr;
+   struct atalk_addr *aa = ((struct ltpc_private 
*)netdev_priv(dev))-my_addr;
struct lt_init c;
int ltflags;
 
@@ -913,7 +913,7 @@ static int ltpc_xmit(struct sk_buff *skb
 * and skb-len is the length of the ddp data + ddp header
 */
 
-   struct net_device_stats *stats = ((struct ltpc_private 
*)dev-priv)-stats;
+   struct net_device_stats *stats = ((struct ltpc_private 
*)netdev_priv(dev))-stats;
 
int i;
struct lt_sendlap cbuf;
@@ -952,7 +952,7 @@ static int ltpc_xmit(struct sk_buff *skb
 
 static struct net_device_stats *ltpc_get_stats(struct net_device *dev)
 {
-   struct net_device_stats *stats = ((struct ltpc_private *) 
dev-priv)-stats;
+   struct net_device_stats *stats = ((struct ltpc_private 
*)netdev_priv(dev))-stats;
return stats;
 }
 

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/13] dev-priv to netdev_priv(dev), for drivers/net/arcnet

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/arcnet/arc-rawmode.c  |4 ++--
 drivers/net/arcnet/arc-rimi.c |   16 
 drivers/net/arcnet/arcnet.c   |   32 
 drivers/net/arcnet/capmode.c  |6 +++---
 drivers/net/arcnet/com20020-isa.c |4 ++--
 drivers/net/arcnet/com20020-pci.c |2 +-
 drivers/net/arcnet/com20020.c |   10 +-
 drivers/net/arcnet/com90io.c  |4 ++--
 drivers/net/arcnet/com90xx.c  |   10 +-
 drivers/net/arcnet/rfc1051.c  |8 
 drivers/net/arcnet/rfc1201.c  |   12 ++--
 11 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index e0a18e7..909ba77 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -87,7 +87,7 @@ MODULE_LICENSE(GPL);
 static void rx(struct net_device *dev, int bufnum,
   struct archdr *pkthdr, int length)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
struct sk_buff *skb;
struct archdr *pkt = pkthdr;
int ofs;
@@ -168,7 +168,7 @@ static int build_header(struct sk_buff *
 static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
  int bufnum)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
struct arc_hardware *hard = pkt-hard;
int ofs;
 
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 8c8d6c4..e3082a9 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -194,7 +194,7 @@ static int __init arcrimi_found(struct n
 
/* initialize the rest of the device structure. */
 
-   lp = dev-priv;
+   lp = netdev_priv(dev);
lp-card_name = RIM I;
lp-hw.command = arcrimi_command;
lp-hw.status = arcrimi_status;
@@ -260,7 +260,7 @@ err_free_irq:
  */
 static int arcrimi_reset(struct net_device *dev, int really_reset)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp-mem_start + 0x800;
 
BUGMSG(D_INIT, Resetting %s (status=%02Xh)\n, dev-name, ASTATUS());
@@ -281,7 +281,7 @@ static int arcrimi_reset(struct net_devi
 
 static void arcrimi_setmask(struct net_device *dev, int mask)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp-mem_start + 0x800;
 
AINTMASK(mask);
@@ -289,7 +289,7 @@ static void arcrimi_setmask(struct net_d
 
 static int arcrimi_status(struct net_device *dev)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp-mem_start + 0x800;
 
return ASTATUS();
@@ -297,7 +297,7 @@ static int arcrimi_status(struct net_dev
 
 static void arcrimi_command(struct net_device *dev, int cmd)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp-mem_start + 0x800;
 
ACOMMAND(cmd);
@@ -306,7 +306,7 @@ static void arcrimi_command(struct net_d
 static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int 
offset,
 void *buf, int count)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *memaddr = lp-mem_start + 0x800 + bufnum * 512 + offset;
TIME(memcpy_toio, count, memcpy_toio(memaddr, buf, count));
 }
@@ -315,7 +315,7 @@ static void arcrimi_copy_to_card(struct 
 static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int 
offset,
   void *buf, int count)
 {
-   struct arcnet_local *lp = dev-priv;
+   struct arcnet_local *lp = netdev_priv(dev);
void __iomem *memaddr = lp-mem_start + 0x800 + bufnum * 512 + offset;
TIME

[PATCH 04/13] dev-priv to netdev_priv(dev), for drivers/net/bonding

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/bonding/bond_3ad.c  |6 +--
 drivers/net/bonding/bond_alb.c  |6 +--
 drivers/net/bonding/bond_main.c |   62 
 3 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index f829e4a..9ad88d0 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2364,7 +2364,7 @@ int bond_3ad_get_active_agg_info(struct 
 int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
 {
struct slave *slave, *start_at;
-   struct bonding *bond = dev-priv;
+   struct bonding *bond = netdev_priv(dev);
int slave_agg_no;
int slaves_in_agg;
int agg_id;
@@ -2444,7 +2444,7 @@ out:
 
 int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct 
packet_type* ptype, struct net_device *orig_dev)
 {
-   struct bonding *bond = dev-priv;
+   struct bonding *bond = netdev_priv(dev);
struct slave *slave = NULL;
int ret = NET_RX_DROP;
 
@@ -2452,7 +2452,7 @@ int bond_3ad_lacpdu_recv(struct sk_buff 
goto out;
 
read_lock(bond-lock);
-   slave = bond_get_slave_by_dev((struct bonding *)dev-priv, orig_dev);
+   slave = bond_get_slave_by_dev(netdev_priv(dev), orig_dev);
if (!slave)
goto out_unlock;
 
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 92c3b6f..c90524b 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -341,7 +341,7 @@ static void rlb_update_entry_from_arp(st
 
 static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, 
struct packet_type *ptype, struct net_device *orig_dev)
 {
-   struct bonding *bond = bond_dev-priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct arp_pkt *arp = (struct arp_pkt *)skb-data;
int res = NET_RX_DROP;
 
@@ -1260,7 +1260,7 @@ void bond_alb_deinitialize(struct bondin
 
 int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 {
-   struct bonding *bond = bond_dev-priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct ethhdr *eth_data;
struct alb_bond_info *bond_info = (BOND_ALB_INFO(bond));
struct slave *tx_slave = NULL;
@@ -1621,7 +1621,7 @@ void bond_alb_handle_active_change(struc
 
 int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
 {
-   struct bonding *bond = bond_dev-priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct sockaddr *sa = addr;
struct slave *slave, *swap_slave;
int res;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 070b78d..08f5fcc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -425,7 +425,7 @@ int bond_dev_queue_xmit(struct bonding *
  */
 static void bond_vlan_rx_register(struct net_device *bond_dev, struct 
vlan_group *grp)
 {
-   struct bonding *bond = bond_dev-priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
int i;
 
@@ -448,7 +448,7 @@ static void bond_vlan_rx_register(struct
  */
 static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
 {
-   struct bonding *bond = bond_dev-priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
int i, res;
 
@@ -476,7 +476,7 @@ static void bond_vlan_rx_add_vid(struct 
  */
 static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
 {
-   struct bonding *bond = bond_dev-priv;
+   struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
struct net_device *vlan_dev;
int i, res;
@@ -900,7 +900,7 @@ static int bond_mc_list_copy(struct dev_
  */
 static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device 
*slave_dev)
 {
-   struct bonding *bond = bond_dev-priv;
+   struct bonding *bond

[PATCH 05/13] dev-priv to netdev_priv(dev), for drivers/net/cris

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/cris/eth_v10.c |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 5bdf5ca..39afed7 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -474,7 +474,7 @@ etrax_ethernet_init(void)
   ETRAX 100LX 10/100MBit ethernet v2.0 (c) 2000-2003 Axis 
Communications AB\n);
 
dev = alloc_etherdev(sizeof(struct net_local));
-   np = dev-priv;
+   np = netdev_priv(dev);
 
if (!dev)
return -ENOMEM;
@@ -595,7 +595,7 @@ etrax_ethernet_init(void)
 static int
 e100_set_mac_address(struct net_device *dev, void *p)
 {
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
struct sockaddr *addr = p;
int i;
 
@@ -911,7 +911,7 @@ static void
 e100_check_duplex(unsigned long priv)
 {
struct net_device *dev = (struct net_device *)priv;
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
int old_duplex = full_duplex;
transceiver-check_duplex(dev);
if (old_duplex != full_duplex) {
@@ -1116,7 +1116,7 @@ e100_reset_transceiver(struct net_device
 static void
 e100_tx_timeout(struct net_device *dev)
 {
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
unsigned long flags;
 
spin_lock_irqsave(np-lock, flags);
@@ -1165,7 +1165,7 @@ e100_tx_timeout(struct net_device *dev)
 static int
 e100_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
unsigned char *buf = skb-data;
unsigned long flags;
 
@@ -1201,7 +1201,7 @@ static irqreturn_t
 e100rxtx_interrupt(int irq, void *dev_id)
 {
struct net_device *dev = (struct net_device *)dev_id;
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
unsigned long irqbits = *R_IRQ_MASK2_RD;
 
/* Disable RX/TX IRQs to avoid reentrancy */
@@ -1223,7 +1223,7 @@ e100rxtx_interrupt(int irq, void *dev_id
 * allocate a new buffer to put a packet in.
 */
e100_rx(dev);
-   ((struct net_local *)dev-priv)-stats.rx_packets++;
+   ((struct net_local 
*)netdev_priv(dev))-stats.rx_packets++;
/* restart/continue on the channel, for safety */
*R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, restart);
/* clear dma channel 1 eop/descr irq bits */
@@ -1268,7 +1268,7 @@ static irqreturn_t
 e100nw_interrupt(int irq, void *dev_id)
 {
struct net_device *dev = (struct net_device *)dev_id;
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
unsigned long irqbits = *R_IRQ_MASK0_RD;
 
/* check for underrun irq */
@@ -1303,7 +1303,7 @@ e100_rx(struct net_device *dev)
 {
struct sk_buff *skb;
int length = 0;
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
unsigned char *skb_data_ptr;
 #ifdef ETHDEBUG
int i;
@@ -1320,7 +1320,7 @@ #endif
}
 
length = myNextRxDesc-descr.hw_len - 4;
-   ((struct net_local *)dev-priv)-stats.rx_bytes += length;
+   ((struct net_local *)netdev_priv(dev))-stats.rx_bytes += length;
 
 #ifdef ETHDEBUG
printk(Got a packet of length %d:\n, length);
@@ -1402,7 +1402,7 @@ #endif
 static int
 e100_close(struct net_device *dev)
 {
-   struct net_local *np = (struct net_local *)dev-priv;
+   struct net_local *np = netdev_priv(dev);
 
printk(KERN_INFO Closing %s.\n, dev-name);
 
@@ -1564,7 +1564,7 @@ static const struct ethtool_ops e100_eth

[PATCH 06/13] dev-priv to netdev_priv(dev), for drivers/net/ibm_emac

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/ibm_emac/ibm_emac_core.c |   42 +--
 drivers/net/ibm_emac/ibm_emac_mal.c  |2 -
 drivers/net/ibm_emac/ibm_emac_phy.c  |2 -
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ibm_emac/ibm_emac_core.c 
b/drivers/net/ibm_emac/ibm_emac_core.c
index f752e5f..cefadc1 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -531,7 +531,7 @@ static void emac_reinitialize(struct ocp
 /* BHs disabled */
 static void emac_full_tx_reset(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ocp_func_emac_data *emacdata = dev-def-additions;
 
DBG(%d: full_tx_reset NL, dev-def-index);
@@ -639,7 +639,7 @@ static void __emac_mdio_write(struct ocp
 
 static int emac_mdio_read(struct net_device *ndev, int id, int reg)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
int res;
 
local_bh_disable();
@@ -651,7 +651,7 @@ static int emac_mdio_read(struct net_dev
 
 static void emac_mdio_write(struct net_device *ndev, int id, int reg, int val)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
 
local_bh_disable();
__emac_mdio_write(dev-mdio_dev ? dev-mdio_dev : dev, (u8) id,
@@ -662,7 +662,7 @@ static void emac_mdio_write(struct net_d
 /* BHs disabled */
 static void emac_set_multicast_list(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct emac_regs __iomem *p = dev-emacp;
u32 rmr = emac_iff2rmr(ndev);
 
@@ -764,7 +764,7 @@ static int emac_resize_rx_ring(struct oc
 /* Process ctx, rtnl_lock semaphore */
 static int emac_change_mtu(struct net_device *ndev, int new_mtu)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
int ret = 0;
 
if (new_mtu  EMAC_MIN_MTU || new_mtu  EMAC_MAX_MTU)
@@ -857,7 +857,7 @@ static void emac_print_link_status(struc
 /* Process ctx, rtnl_lock semaphore */
 static int emac_open(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ocp_func_emac_data *emacdata = dev-def-additions;
int err, i;
 
@@ -1005,7 +1005,7 @@ static void emac_force_link_update(struc
 /* Process ctx, rtnl_lock semaphore */
 static int emac_close(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ocp_func_emac_data *emacdata = dev-def-additions;
 
DBG(%d: close NL, dev-def-index);
@@ -1065,7 +1065,7 @@ static inline int emac_xmit_finish(struc
 /* BHs disabled */
 static int emac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
unsigned int len = skb-len;
int slot;
 
@@ -1123,7 +1123,7 @@ static inline int emac_xmit_split(struct
 /* BHs disabled (SG version for TAH equipped EMACs) */
 static int emac_start_xmit_sg(struct sk_buff *skb, struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
int nr_frags = skb_shinfo(skb)-nr_frags;
int len = skb-len, chunk;
int slot, i;
@@ -1559,7 +1559,7 @@ static irqreturn_t emac_irq(int irq, voi
 
 static struct net_device_stats *emac_stats(struct net_device *ndev)
 {
-   struct ocp_enet_private *dev = ndev-priv;
+   struct ocp_enet_private *dev = netdev_priv(ndev);
struct ibm_emac_stats *st = dev-stats;
struct ibm_emac_error_stats *est = dev-estats;
struct net_device_stats *nst = dev-nstats;
@@ -1647,7 +1647,7 @@ static struct mal_commac_ops

[PATCH 07/13] dev-priv to netdev_priv(dev), for drivers/net/irda

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/irda/ali-ircc.c|   16 
 drivers/net/irda/donauboe.c|8 
 drivers/net/irda/irda-usb.c|   14 +++---
 drivers/net/irda/irport.c  |   20 ++--
 drivers/net/irda/nsc-ircc.c|   16 
 drivers/net/irda/sa1100_ir.c   |   26 +-
 drivers/net/irda/sir_dev.c |   12 ++--
 drivers/net/irda/via-ircc.c|   16 
 drivers/net/irda/vlsi_ir.c |   36 ++--
 drivers/net/irda/w83977af_ir.c |   14 +++---
 10 files changed, 89 insertions(+), 89 deletions(-)

diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index f9c889c..0300aac 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -291,7 +291,7 @@ static int ali_ircc_open(int i, chipio_t
return -ENOMEM;
}
 
-   self = dev-priv;
+   self = netdev_priv(dev);
self-netdev = dev;
spin_lock_init(self-lock);

@@ -668,7 +668,7 @@ static irqreturn_t ali_ircc_interrupt(in

IRDA_DEBUG(2, %s(),  Start \n, 
__FUNCTION__);

-   self = dev-priv;
+   self = netdev_priv(dev);

spin_lock(self-lock);

@@ -1336,7 +1336,7 @@ static int ali_ircc_net_open(struct net_

IRDA_ASSERT(dev != NULL, return -1;);

-   self = (struct ali_ircc_cb *) dev-priv;
+   self = netdev_priv(dev);

IRDA_ASSERT(self != NULL, return 0;);

@@ -1399,7 +1399,7 @@ static int ali_ircc_net_close(struct net

IRDA_ASSERT(dev != NULL, return -1;);
 
-   self = (struct ali_ircc_cb *) dev-priv;
+   self = netdev_priv(dev);
IRDA_ASSERT(self != NULL, return 0;);
 
/* Stop device */
@@ -1439,7 +1439,7 @@ static int ali_ircc_fir_hard_xmit(struct

IRDA_DEBUG(1, %s(),  Start -\n, 
__FUNCTION__ );   

-   self = (struct ali_ircc_cb *) dev-priv;
+   self = netdev_priv(dev);
iobase = self-io.fir_base;
 
netif_stop_queue(dev);
@@ -1963,7 +1963,7 @@ static int ali_ircc_sir_hard_xmit(struct

IRDA_ASSERT(dev != NULL, return 0;);

-   self = (struct ali_ircc_cb *) dev-priv;
+   self = netdev_priv(dev);
IRDA_ASSERT(self != NULL, return 0;);
 
iobase = self-io.sir_base;
@@ -2031,7 +2031,7 @@ static int ali_ircc_net_ioctl(struct net

IRDA_ASSERT(dev != NULL, return -1;);
 
-   self = dev-priv;
+   self = netdev_priv(dev);
 
IRDA_ASSERT(self != NULL, return -1;);
 
@@ -2117,7 +2117,7 @@ static int ali_ircc_is_receiving(struct 
 
 static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev)
 {
-   struct ali_ircc_cb *self = (struct ali_ircc_cb *) dev-priv;
+   struct ali_ircc_cb *self = netdev_priv(dev);

IRDA_DEBUG(2, %s(),  Start \n, 
__FUNCTION__ );

diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 3ca47bf..fd7602e 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -983,7 +983,7 @@ toshoboe_hard_xmit (struct sk_buff *skb,
   unsigned long flags;
   struct irda_skb_cb *cb = (struct irda_skb_cb *) skb-cb;
 
-  self = (struct toshoboe_cb *) dev-priv;
+  self = netdev_priv(dev);
 
   IRDA_ASSERT (self != NULL, return 0; );
 
@@ -1388,7 +1388,7 @@ toshoboe_net_close (struct net_device *d
   IRDA_DEBUG (4, %s()\n, __FUNCTION__);
 
   IRDA_ASSERT (dev != NULL, return -1; );
-  self = (struct toshoboe_cb *) dev-priv;
+  self = netdev_priv(dev);
 
   /* Stop device */
   netif_stop_queue(dev);
@@ -1426,7 +1426,7 @@ toshoboe_net_ioctl (struct net_device *d
 
   IRDA_ASSERT (dev != NULL, return -1; );
 
-  self = dev-priv;
+  self = netdev_priv(dev);
 
   IRDA_ASSERT (self != NULL, return -1; );
 
@@ -1550,7 +1550,7 @@ toshoboe_open (struct

[PATCH 09/13] dev-priv to netdev_priv(dev), for drivers/net/tokenring

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/tokenring/3c359.c   |   58 ++--
 drivers/net/tokenring/ibmtr.c   |   38 +++
 drivers/net/tokenring/lanstreamer.c |   32 +--
 drivers/net/tokenring/madgemc.c |4 +-
 drivers/net/tokenring/olympic.c |   36 +++---
 drivers/net/tokenring/tmspci.c  |4 +-
 6 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 9f1b6ab..a8573da 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -156,7 +156,7 @@ static void print_rx_state(struct net_de
 static void print_tx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_tx_desc *txd ; 
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
int i ; 
@@ -179,7 +179,7 @@ static void print_tx_state(struct net_de
 static void print_rx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_rx_desc *rxd ; 
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
int i ; 
@@ -213,7 +213,7 @@ #endif
 
 static u16 xl_ee_read(struct net_device *dev, int ee_addr)
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -245,7 +245,7 @@ static u16 xl_ee_read(struct net_device 
 
 static void  xl_ee_write(struct net_device *dev, int ee_addr, u16 ee_value) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -305,11 +305,11 @@ static int __devinit xl_probe(struct pci
pci_release_regions(pdev) ; 
return -ENOMEM ; 
} 
-   xl_priv = dev-priv ; 
+   xl_priv = netdev_priv(dev) ; 
 
 #if XL_DEBUG  
printk(pci_device: %p, dev:%p, dev-priv: %p, ba[0]: %10x, 
ba[1]:%10x\n, 
-   pdev, dev, dev-priv, (unsigned int)pdev-resource[0].start, 
(unsigned int)pdev-resource[1].start) ;  
+   pdev, dev, netdev_priv(dev), (unsigned 
int)pdev-resource[0].start, (unsigned int)pdev-resource[1].start) ;  
 #endif 
 
dev-irq=pdev-irq;
@@ -365,7 +365,7 @@ #endif 
 
 static int __devinit xl_init(struct net_device *dev) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
 
printk(KERN_INFO %s \n, version);
printk(KERN_INFO %s: I/O at %hx, MMIO at %p, using irq %d\n,
@@ -385,7 +385,7 @@ static int __devinit xl_init(struct net_
 
 static int xl_hw_reset(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
unsigned long t ; 
u16 i ; 
@@ -568,7 +568,7 @@ #endif
 
 static int xl_open(struct net_device *dev) 
 {
-   struct xl_private *xl_priv=(struct xl_private *)dev-priv;
+   struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
u8 i ; 
u16 hwaddr[3] ; /* Should be u8[6] but we get word return values */
@@ -726,7 +726,7 @@ static int xl_open(struct net_device *de
 
 static int xl_open_hw(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv=(struct xl_private *)dev-priv;
+   struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
u16 vsoff ;
char ver_str[33];  
@@ -875,7 +875,7 @@ static int xl_open_hw(struct net_device 
 
 static void adv_rx_ring(struct net_device *dev) /* Advance rx_ring

[PATCH 10/13] dev-priv to netdev_priv(dev), for drivers/net/tulip

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/tulip/de2104x.c |   44 ++--
 drivers/net/tulip/eeprom.c  |2 +-
 drivers/net/tulip/uli526x.c |2 +-
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index d380e0b..4ba3a7b 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -486,7 +486,7 @@ rx_next:
 static irqreturn_t de_interrupt (int irq, void *dev_instance)
 {
struct net_device *dev = dev_instance;
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
u32 status;
 
status = dr32(MacStatus);
@@ -592,7 +592,7 @@ next:
 
 static int de_start_xmit (struct sk_buff *skb, struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
unsigned int entry, tx_free;
u32 mapping, len, flags = FirstFrag | LastFrag;
struct de_desc *txd;
@@ -655,7 +655,7 @@ #define set_bit_le(i,p) do { ((char *)(p
 
 static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
u16 hash_table[32];
struct dev_mc_list *mclist;
int i;
@@ -686,7 +686,7 @@ static void build_setup_frame_hash(u16 *
 
 static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
struct dev_mc_list *mclist;
int i;
u16 *eaddrs;
@@ -714,7 +714,7 @@ static void build_setup_frame_perfect(u1
 
 static void __de_set_rx_mode (struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
u32 macmode;
unsigned int entry;
u32 mapping;
@@ -799,7 +799,7 @@ out:
 static void de_set_rx_mode (struct net_device *dev)
 {
unsigned long flags;
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
 
spin_lock_irqsave (de-lock, flags);
__de_set_rx_mode(dev);
@@ -823,7 +823,7 @@ static void __de_get_stats(struct de_pri
 
 static struct net_device_stats *de_get_stats(struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
 
/* The chip only need report frame silently dropped. */
spin_lock_irq(de-lock);
@@ -1352,7 +1352,7 @@ static void de_free_rings (struct de_pri
 
 static int de_open (struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
int rc;
 
if (netif_msg_ifup(de))
@@ -1397,7 +1397,7 @@ err_out_free:
 
 static int de_close (struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
unsigned long flags;
 
if (netif_msg_ifdown(de))
@@ -1421,7 +1421,7 @@ static int de_close (struct net_device *
 
 static void de_tx_timeout (struct net_device *dev)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
 
printk(KERN_DEBUG %s: NIC status %08x mode %08x sia %08x desc 
%u/%u/%u\n,
   dev-name, dr32(MacStatus), dr32(MacMode), dr32(SIAStatus),
@@ -1572,7 +1572,7 @@ static int __de_set_settings(struct de_p
 
 static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo 
*info)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
 
strcpy (info-driver, DRV_NAME);
strcpy (info-version, DRV_VERSION);
@@ -1587,7 +1587,7 @@ static int de_get_regs_len(struct net_de
 
 static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
-   struct de_private *de = dev-priv;
+   struct de_private *de = netdev_priv(dev);
int rc;
 
spin_lock_irq(de-lock);
@@ -1599,7 +1599,7 @@ static int de_get_settings

[PATCH 11/13] dev-priv to netdev_priv(dev), for drivers/net/usb

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/usb/mcs7830.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 6240b97..37ad14b 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -341,14 +341,14 @@ out:
 static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
 int location)
 {
-   struct usbnet *dev = netdev-priv;
+   struct usbnet *dev = netdev_priv(netdev);
return mcs7830_read_phy(dev, location);
 }
 
 static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
int location, int val)
 {
-   struct usbnet *dev = netdev-priv;
+   struct usbnet *dev = netdev_priv(netdev);
mcs7830_write_phy(dev, location, val);
 }
 

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/13] dev-priv to netdev_priv(dev), for drivers/net/netxen

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/netxen/netxen_nic_main.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_main.c 
b/drivers/net/netxen/netxen_nic_main.c
index 08a62ac..c14c178 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -329,7 +329,7 @@ netxen_nic_probe(struct pci_dev *pdev, c
SET_MODULE_OWNER(netdev);
SET_NETDEV_DEV(netdev, pdev-dev);
 
-   adapter = netdev-priv;
+   adapter = netdev_priv(netdev);
memset(adapter, 0 , sizeof(struct netxen_adapter));
 
adapter-ahw.pdev = pdev;
@@ -850,7 +850,7 @@ static void __devexit netxen_nic_remove(
  */
 static int netxen_nic_open(struct net_device *netdev)
 {
-   struct netxen_adapter *adapter = (struct netxen_adapter *)netdev-priv;
+   struct netxen_adapter *adapter = netdev_priv(netdev);
int err = 0;
int ctx, ring;
 

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/13] dev-priv to netdev_priv(dev), for drivers/net/wan

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/wan/dlci.c |   30 +-
 drivers/net/wan/lmc/lmc_main.c |   26 +++
 drivers/net/wan/sdla.c |   46 -
 drivers/net/wan/sealevel.c |   12 +-
 drivers/net/wan/x25_asy.c  |   28 
 5 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index 66be20c..d988161 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -74,7 +74,7 @@ static int dlci_header(struct sk_buff *s
unsigned inthlen;
char*dest;
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
hdr.control = FRAD_I_UI;
switch(type)
@@ -110,7 +110,7 @@ static void dlci_receive(struct sk_buff 
struct frhdr*hdr;
int process, header;
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
if (!pskb_may_pull(skb, sizeof(*hdr))) {
printk(KERN_NOTICE %s: invalid data no header\n,
   dev-name);
@@ -197,7 +197,7 @@ static int dlci_transmit(struct sk_buff 
if (!skb || !dev)
return(0);
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
netif_stop_queue(dev);

@@ -235,7 +235,7 @@ static int dlci_config(struct net_device
struct frad_local   *flp;
int err;
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
flp = dlp-slave-priv;
 
@@ -269,7 +269,7 @@ static int dlci_dev_ioctl(struct net_dev
if (!capable(CAP_NET_ADMIN))
return(-EPERM);
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
switch(cmd)
{
@@ -298,7 +298,7 @@ static int dlci_change_mtu(struct net_de
 {
struct dlci_local *dlp;
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
return((*dlp-slave-change_mtu)(dlp-slave, new_mtu));
 }
@@ -309,7 +309,7 @@ static int dlci_open(struct net_device *
struct frad_local   *flp;
int err;
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
if (!*(short *)(dev-dev_addr))
return(-EINVAL);
@@ -335,7 +335,7 @@ static int dlci_close(struct net_device 
 
netif_stop_queue(dev);
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
flp = dlp-slave-priv;
err = (*flp-deactivate)(dlp-slave, dev);
@@ -347,7 +347,7 @@ static struct net_device_stats *dlci_get
 {
struct dlci_local *dlp;
 
-   dlp = dev-priv;
+   dlp = netdev_priv(dev);
 
return(dlp-stats);
 }
@@ -365,7 +365,7 @@ static int dlci_add(struct dlci_add *dlc
if (!slave)
return -ENODEV;
 
-   if (slave-type != ARPHRD_FRAD || slave-priv == NULL)
+   if (slave-type != ARPHRD_FRAD || netdev_priv(slave) == NULL)
goto err1;
 
/* create device name */
@@ -391,11 +391,11 @@ static int dlci_add(struct dlci_add *dlc
 
*(short *)(master-dev_addr) = dlci-dlci;
 
-   dlp = (struct dlci_local *) master-priv;
+   dlp = netdev_priv(master);
dlp-slave = slave;
dlp-master = master;
 
-   flp = slave-priv;
+   flp = netdev_priv(slave);
err = (*flp-assoc)(slave, master);
if (err  0)
goto err2;
@@ -435,9 +435,9 @@ static int dlci_del(struct dlci_add *dlc
return(-EBUSY);
}
 
-   dlp = master-priv;
+   dlp = netdev_priv(master);
slave = dlp-slave;
-   flp = slave-priv;
+   flp = netdev_priv(slave);
 
rtnl_lock();
err = (*flp-deassoc)(slave, master);
@@ -487,7 +487,7 @@ static int dlci_ioctl(unsigned int cmd, 
 
 static void dlci_setup(struct net_device *dev)
 {
-   struct dlci_local *dlp = dev-priv;
+   struct dlci_local *dlp = netdev_priv(dev);
 
dev-flags  = 0;
dev-open

[PATCH 13/13] dev-priv to netdev_priv(dev), for drivers/net/wireless

2007-08-03 Thread Yoann Padioleau

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)

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 drivers/net/wireless/arlan-proc.c  |   14 +++---
 drivers/net/wireless/hostap/hostap_cs.c|2 
 drivers/net/wireless/hostap/hostap_hw.c|2 
 drivers/net/wireless/hostap/hostap_ioctl.c |   14 +++---
 drivers/net/wireless/orinoco_tmd.c |2 
 drivers/net/wireless/prism54/isl_ioctl.c   |6 +-
 drivers/net/wireless/ray_cs.c  |   66 ++---
 drivers/net/wireless/strip.c   |2 
 drivers/net/wireless/wl3501_cs.c   |   66 ++---
 9 files changed, 87 insertions(+), 87 deletions(-)

diff --git a/drivers/net/wireless/arlan-proc.c 
b/drivers/net/wireless/arlan-proc.c
index 015abd9..c6e70db 100644
--- a/drivers/net/wireless/arlan-proc.c
+++ b/drivers/net/wireless/arlan-proc.c
@@ -435,7 +435,7 @@ static int arlan_sysctl_info(ctl_table *
goto final;
}
else
-   priva = arlan_device[devnum]-priv;
+   priva = netdev_priv(arlan_device[devnum]);
 
if (priva == NULL)
{
@@ -654,7 +654,7 @@ static int arlan_sysctl_info161719(ctl_t
goto final;
}
else
-   priva = arlan_device[devnum]-priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING  Could not find the device private in 
arlan procsys, bad\n );
@@ -688,7 +688,7 @@ static int arlan_sysctl_infotxRing(ctl_t
  goto final;
}
else
-   priva = arlan_device[devnum]-priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING  Could not find the device private in 
arlan procsys, bad\n );
@@ -716,7 +716,7 @@ static int arlan_sysctl_inforxRing(ctl_t
  pos += sprintf(arlan_drive_info + pos, No device found here 
\n);
  goto final;
} else
-   priva = arlan_device[devnum]-priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING  Could not find the device private in 
arlan procsys, bad\n );
@@ -745,7 +745,7 @@ static int arlan_sysctl_info18(ctl_table
goto final;
}
else
-   priva = arlan_device[devnum]-priv;
+   priva = netdev_priv(arlan_device[devnum]);
if (priva == NULL)
{
printk(KERN_WARNING  Could not find the device private in 
arlan procsys, bad\n );
@@ -780,7 +780,7 @@ static int arlan_configure(ctl_table * c
}
else if (arlan_device[devnum] != NULL)
{
- priv = arlan_device[devnum]-priv;
+ priv = netdev_priv(arlan_device[devnum]);
 
  arlan_command(arlan_device[devnum], 
ARLAN_COMMAND_CLEAN_AND_CONF);
}
@@ -805,7 +805,7 @@ static int arlan_sysctl_reset(ctl_table 
}
else if (arlan_device[devnum] != NULL)
{
-   priv = arlan_device[devnum]-priv;
+   priv = netdev_priv(arlan_device[devnum]);
arlan_command(arlan_device[devnum], 
ARLAN_COMMAND_CLEAN_AND_RESET);
 
} else
diff --git a/drivers/net/wireless/hostap/hostap_cs.c 
b/drivers/net/wireless/hostap/hostap_cs.c
index 30e723f..f9cf22b 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -272,7 +272,7 @@ static int sandisk_enable_wireless(struc
 {
int res, ret = 0;
conf_reg_t reg;
-   struct hostap_interface *iface = dev-priv;
+   struct hostap_interface *iface = netdev_priv(dev);
local_info_t *local = iface-local;
tuple_t tuple;
cisparse_t *parse = NULL;
diff --git a/drivers/net/wireless/hostap/hostap_hw.c 
b/drivers/net/wireless/hostap/hostap_hw.c
index 959887b..18023b5 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -3424,7 +3424,7 @@ static void

dev-priv to netdev_priv(dev)

2007-08-03 Thread Yoann Padioleau
Jeff Garzik [EMAIL PROTECTED] writes:

 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)

 applied.  splitting up by sub-directory would be helpful.

Done. I was not always able to find the maintainer for all the subdirectories
so for those cases I have considered you as the maintainer :)

I have run another semantic patch (more like a semantic grep in fact)
to find the places where our tool didn't transform the dev-priv to
netdev_priv. The reason is that our tool was not able to find the call
to alloc_dev_xxx(sizeof(T),...) in the driver or there was an
assignation to dev-priv which means that transforming to netdev_priv
would do something wrong. I have printed the list of bad driver
below.

In very few cases the driver was in fact good but because of the
way the code was written, our tool was not able to find the alloc_xxx
function.



drivers/net/82596.c 
drivers/net/chelsio/cxgb2.c 
drivers/net/chelsio/sge.c   
drivers/net/cxgb3/cxgb3_main.c  
drivers/net/cxgb3/sge.c 
drivers/net/e1000/e1000_main.c  
drivers/net/ehea/ehea_main.c
drivers/net/hamradio/dmascc.c   
drivers/net/hamradio/scc.c  
drivers/net/lance.c 
drivers/net/mace.c  

 for mace.c the code is written this way:

#define PRIV_BYTES  (sizeof(struct mace_data) \
   + (N_RX_RING + NCMDS_TX * N_TX_RING + 3) * sizeof(struct dbdma_cmd))

 dev = alloc_etherdev(PRIV_BYTES);
 
 So our semantic patch can't find a   alloc_etherdev(sizeof(T)).
 If I inline the definition of PRIV_BYTES, then our tool will be
 able to transform it.

 


drivers/net/ni65.c  
drivers/net/pcmcia/com20020_cs.c

   dev = alloc_arcdev();
 

drivers/net/ppp_generic.c   
drivers/net/spider_net_ethtool.c 

 again, the code is written this way:

   alloc_size = sizeof(struct spider_net_card) +
  (tx_descriptors + rx_descriptors) * sizeof(struct spider_net_descr);
   netdev = alloc_etherdev(alloc_size);

 If I inline the definition of alloc_size, then we can transform
 the file.

drivers/net/tulip/xircom_cb.c   
drivers/net/wan/cosa.c  
drivers/net/wan/cycx_x25.c  
drivers/net/wan/hdlc_fr.c   
drivers/net/wan/hdlc_ppp.c  
drivers/net/wan/hostess_sv11.c  
drivers/net/wan/pc300_drv.c 
drivers/net/wan/sbni.c  
drivers/net/wireless/airo.c 
drivers/net/wireless/libertas/ethtool.c 
drivers/net/wireless/libertas/main.c
drivers/net/wireless/libertas/scan.c
drivers/net/wireless/libertas/wext.c
drivers/net/wireless/wavelan.c  
drivers/net/wireless/zd1201.c   

drivers/net/tokenring/tms380tr.c
   This file is both used as a single module and used by other module.
   The other modules have a call to a alloc_xxx but not tms380tr.c when
   used as a single module. 
  

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 06/13] dev-priv to netdev_priv(dev), for drivers/net/ibm_emac

2007-08-03 Thread Yoann Padioleau
Eugene Surovegin [EMAIL PROTECTED] writes:

 On Fri, Aug 03, 2007 at 07:34:19PM +0200, Yoann Padioleau wrote:
 
 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.

 NAK.

 While that assumption is correct for the actual emac net device, it's 
 not for MAL poll one.

I forgot to add another condition in my semantic patch. 

I was looking only for xxx-priv = yyy; 
with this rule:

@ danger @
struct net_device *dev;
expression E;
@@
 dev-priv = E

whereas sometimes it's written xxx.priv = yyy; 
as in ibm_emac_mal ( mal-poll_dev.priv = mal; )

By adding the following rule in my semantic patch I correctly
_dont_ modify anything under drivers/net/ibm_emac

@ danger @
struct net_device dev;
expression E;
@@
 dev.priv = E


It's also the case for  drivers/net/e1000/e1000_main.c.



 You patch breaks a working driver.

 -- 
 Eugene

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 18/68] 0 -> NULL, for arch/um

2007-07-27 Thread Yoann Padioleau
Jeff Dike <[EMAIL PROTECTED]> writes:

> On Fri, Jul 27, 2007 at 11:45:56AM +0200, Yoann Padioleau wrote:
>> When comparing a pointer, it's clearer to compare it to NULL than to 0.
>
> ACK
>
>>  sys-i386/fault.c   |2 +-
>>  sys-x86_64/fault.c |2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> Except you should probably diff from the top of the kernel tree.

Sorry. I will use diffstat -p1  from now on.

>
>   Jeff
>
> -- 
> Work email - jdike at linux dot intel dot com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 06/68] 0 -> NULL, for arch/frv

2007-07-27 Thread Yoann Padioleau
Al Viro <[EMAIL PROTECTED]> writes:

> On Fri, Jul 27, 2007 at 11:44:35AM +0200, Yoann Padioleau wrote:
>>  pte = pte_alloc_kernel(pme, va);
>> -if (pte != 0) {
>> +if (pte != NULL) {
>>  err = 0;
>>  set_pte(pte, mk_pte_phys(pa & PAGE_MASK, prot));
>>  }
>> @@ -99,7 +99,7 @@ void *consistent_alloc(gfp_t gfp, size_t
>>  
>>  /* allocate some common virtual space to map the new pages */
>>  area = get_vm_area(size, VM_ALLOC);
>> -if (area == 0) {
>> +if (area == NULL) {
>>  free_pages(page, order);
>>  return NULL;
>
> Same comment about comparisons with NULL after allocation...

I don't understand. pte is a pointer right ? So why should we
keep the == 0 ? 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 06/68] 0 -> NULL, for arch/frv

2007-07-27 Thread Yoann Padioleau
David Howells <[EMAIL PROTECTED]> writes:

> Yoann Padioleau <[EMAIL PROTECTED]> wrote:
>
>> When comparing a pointer, it's clearer to compare it to NULL than to 0.
>
> Can you make them of style:
>
>   if (!x)

Yes I can. I can make another semantic patch later to do that
transformation. But some people may prefer (x == NULL) to (!x)
so I don't know. I think that transformation 
some 0 to NULL is less controversial.


>
> instead?
>
> Thanks,
> David

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 18/68] 0 -> NULL, for arch/um

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 sys-i386/fault.c   |2 +-
 sys-x86_64/fault.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/sys-i386/fault.c b/arch/um/sys-i386/fault.c
index 745b4fd..8004023 100644
--- a/arch/um/sys-i386/fault.c
+++ b/arch/um/sys-i386/fault.c
@@ -20,7 +20,7 @@ int arch_fixup(unsigned long address, un
const struct exception_table_entry *fixup;
 
fixup = search_exception_tables(address);
-   if(fixup != 0){
+   if(fixup != NULL){
UPT_IP(regs) = fixup->fixup;
return(1);
}
diff --git a/arch/um/sys-x86_64/fault.c b/arch/um/sys-x86_64/fault.c
index 4636b14..67d4a19 100644
--- a/arch/um/sys-x86_64/fault.c
+++ b/arch/um/sys-x86_64/fault.c
@@ -19,7 +19,7 @@ int arch_fixup(unsigned long address, un
const struct exception_table_entry *fixup;
 
fixup = search_exception_tables(address);
-   if(fixup != 0){
+   if(fixup != NULL){
UPT_IP(regs) = fixup->fixup;
return(1);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/68] 0 -> NULL, for arch/sparc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/ioport.c |6 +++---
 kernel/pcic.c   |2 +-
 kernel/prom.c   |2 +-
 prom/bootstr.c  |2 +-
 prom/tree.c |2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 62182d2..3f1a8e2 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -181,7 +181,7 @@ static void __iomem *_sparc_alloc_io(uns
 
if (name == NULL) name = "???";
 
-   if ((xres = xres_alloc()) != 0) {
+   if ((xres = xres_alloc()) != NULL) {
tack = xres->xname;
res = >xres;
} else {
@@ -835,7 +835,7 @@ _sparc_io_get_info(char *buf, char **sta
for (r = ((struct resource *)data)->child; r != NULL; r = r->sibling) {
if (p + 32 >= e)/* Better than nothing */
break;
-   if ((nm = r->name) == 0) nm = "???";
+   if ((nm = r->name) == NULL) nm = "???";
p += sprintf(p, "%016llx-%016llx: %s\n",
(unsigned long long)r->start,
(unsigned long long)r->end, nm);
@@ -858,7 +858,7 @@ _sparc_find_resource(struct resource *ro
 {
 struct resource *tmp;
 
-   for (tmp = root->child; tmp != 0; tmp = tmp->sibling) {
+   for (tmp = root->child; tmp != NULL; tmp = tmp->sibling) {
if (tmp->start <= hit && tmp->end >= hit)
return tmp;
}
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index f2eae45..eace6e5 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -540,7 +540,7 @@ pcic_fill_irq(struct linux_pcic *pcic, s
prom_getstring(node, "name", namebuf, sizeof(namebuf));
}
 
-   if ((p = pcic->pcic_imap) == 0) {
+   if ((p = pcic->pcic_imap) == NULL) {
dev->irq = 0;
return;
}
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index e3a5376..b5ab1a6 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -33,7 +33,7 @@ struct device_node *of_find_node_by_phan
 {
struct device_node *np;
 
-   for (np = allnodes; np != 0; np = np->allnext)
+   for (np = allnodes; np != NULL; np = np->allnext)
if (np->node == handle)
break;
 
diff --git a/arch/sparc/prom/bootstr.c b/arch/sparc/prom/bootstr.c
index cfdeac2..1f850b9 100644
--- a/arch/sparc/prom/bootstr.c
+++ b/arch/sparc/prom/bootstr.c
@@ -33,7 +33,7 @@ prom_getbootargs(void)
/* Start from 1 and go over fd(0,0,0)kernel */
for(iter = 1; iter < 8; iter++) {
arg = (*(romvec->pv_v0bootargs))->argv[iter];
-   if(arg == 0) break;
+   if(arg == NULL) break;
while(*arg != 0) {
/* Leave place for space and null. */
if(cp >= barg_buf + BARG_LEN-2){
diff --git a/arch/sparc/prom/tree.c b/arch/sparc/prom/tree.c
index 5ec2465..782be75 100644
--- a/arch/sparc/prom/tree.c
+++ b/arch/sparc/prom/tree.c
@@ -309,7 +309,7 @@ int prom_setprop(int node, char *pname, 
int ret;
 
if(size == 0) return 0;
-   if((pname == 0) || (value == 0)) return 0;
+   if((pname == NULL) || (value == NULL)) return 0;
spin_lock_irqsave(_lock, flags);
ret = prom_nodeops->no_setprop(node, pname, value, size);
restore_current();

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 17/68] 0 -> NULL, for arch/sparc64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/prom.c |2 +-
 prom/tree.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index f4e0a9a..35d4eb5 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -38,7 +38,7 @@ struct device_node *of_find_node_by_phan
 {
struct device_node *np;
 
-   for (np = allnodes; np != 0; np = np->allnext)
+   for (np = allnodes; np != NULL; np = np->allnext)
if (np->node == handle)
break;
 
diff --git a/arch/sparc64/prom/tree.c b/arch/sparc64/prom/tree.c
index b2c5b12..33eacd0 100644
--- a/arch/sparc64/prom/tree.c
+++ b/arch/sparc64/prom/tree.c
@@ -264,7 +264,7 @@ prom_setprop(int node, const char *pname
 {
if (size == 0)
return 0;
-   if ((pname == 0) || (value == 0))
+   if ((pname == NULL) || (value == NULL))
return 0;

 #ifdef CONFIG_SUN_LDOMS

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19/68] 0 -> NULL, for arch/x86_64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 numa.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 6da2355..97e8ac7 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -166,7 +166,7 @@ early_node_mem(int nodeid, unsigned long
return __va(mem);
ptr = __alloc_bootmem_nopanic(size,
SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS));
-   if (ptr == 0) {
+   if (ptr == NULL) {
printk(KERN_ERR "Cannot find %lu bytes in node %d\n",
size, nodeid);
return NULL;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 20/68] 0 -> NULL, for arch/xtensa

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/pci.c   |2 +-
 kernel/traps.c |2 +-
 platform-iss/console.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 77deae5..1102816 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -306,7 +306,7 @@ __pci_mmap_make_offset(struct pci_dev *d
unsigned long io_offset = 0;
int i, res_bit;
 
-   if (pci_ctrl == 0)
+   if (pci_ctrl == NULL)
return -EINVAL; /* should never happen */
 
/* If memory, add on the PCI bridge address offset */
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index c5e62f9..eb21c7c 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -419,7 +419,7 @@ void show_stack(struct task_struct *task
int i = 0;
unsigned long *stack;
 
-   if (sp == 0)
+   if (sp == NULL)
__asm__ __volatile__ ("mov %0, a1\n" : "=a"(sp));
 
stack = sp;
diff --git a/arch/xtensa/platform-iss/console.c 
b/arch/xtensa/platform-iss/console.c
index 2f4f20f..ad8d65e 100644
--- a/arch/xtensa/platform-iss/console.c
+++ b/arch/xtensa/platform-iss/console.c
@@ -265,7 +265,7 @@ static void iss_console_write(struct con
 {
int len = strlen(s);
 
-   if (s != 0 && *s != 0)
+   if (s != NULL && *s != 0)
__simc (SYS_write, 1, (unsigned long)s,
count < len ? count : len,0,0);
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/68] 0 -> NULL, for arch/sh

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 cchips/hd6446x/hd64461.c   |2 +-
 cchips/hd6446x/hd64465/gpio.c  |4 ++--
 cchips/hd6446x/hd64465/setup.c |2 +-
 cchips/voyagergx/irq.c |2 +-
 kernel/sh_bios.c   |2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/sh/cchips/hd6446x/hd64461.c b/arch/sh/cchips/hd6446x/hd64461.c
index 97f6512..6117fd7 100644
--- a/arch/sh/cchips/hd6446x/hd64461.c
+++ b/arch/sh/cchips/hd6446x/hd64461.c
@@ -116,7 +116,7 @@ int hd64461_irq_demux(int irq)
irq = CONFIG_HD64461_IRQ;
else {
irq = HD64461_IRQBASE + i;
-   if (hd64461_demux[i].func != 0) {
+   if (hd64461_demux[i].func != NULL) {
irq = hd64461_demux[i].func(irq, 
hd64461_demux[i].dev);
}
}
diff --git a/arch/sh/cchips/hd6446x/hd64465/gpio.c 
b/arch/sh/cchips/hd6446x/hd64465/gpio.c
index 4343185..8ed39e2 100644
--- a/arch/sh/cchips/hd6446x/hd64465/gpio.c
+++ b/arch/sh/cchips/hd6446x/hd64465/gpio.c
@@ -96,7 +96,7 @@ static irqreturn_t hd64465_gpio_interrup
mask = 1<http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/68] 0 -> NULL, for arch/ppc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 8xx_io/commproc.c  |2 +-
 kernel/pci.c   |6 +++---
 mm/init.c  |4 ++--
 mm/mmu_decl.h  |2 +-
 mm/pgtable.c   |4 ++--
 mm/tlb.c   |   12 ++--
 syslib/btext.c |4 ++--
 syslib/open_pic.c  |   14 +++---
 syslib/open_pic2.c |   14 +++---
 xmon/xmon.c|4 ++--
 10 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
index 7088428..e1e0084 100644
--- a/arch/ppc/8xx_io/commproc.c
+++ b/arch/ppc/8xx_io/commproc.c
@@ -293,7 +293,7 @@ cpm_install_handler(int cpm_vec, void (*
return;
}
 
-   if (cpm_vecs[cpm_vec].handler != 0)
+   if (cpm_vecs[cpm_vec].handler != NULL)
printk(KERN_INFO "CPM interrupt %x replacing %x\n",
(uint)handler, (uint)cpm_vecs[cpm_vec].handler);
cpm_vecs[cpm_vec].handler = handler;
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index c2ec13b..124b0a2 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -880,7 +880,7 @@ static struct resource *__pci_mmap_make_
unsigned long io_offset = 0;
int i, res_bit;
 
-   if (hose == 0)
+   if (hose == NULL)
return NULL;/* should never happen */
 
/* If memory, add on the PCI bridge address offset */
@@ -1261,9 +1261,9 @@ fake_pci_bus(struct pci_controller *hose
 {
static struct pci_bus bus;
 
-   if (hose == 0) {
+   if (hose == NULL) {
hose = pci_bus_to_hose(busnr);
-   if (hose == 0)
+   if (hose == NULL)
printk(KERN_ERR "Can't find hose for PCI bus %d!\n", 
busnr);
}
bus.number = busnr;
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
index 390dd19..a805f94 100644
--- a/arch/ppc/mm/init.c
+++ b/arch/ppc/mm/init.c
@@ -197,7 +197,7 @@ void MMU_setup(void)
char *p, *q;
unsigned long maxmem = 0;
 
-   for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
+   for (q = cmd_line; (p = strstr(q, "mem=")) != NULL; ) {
q = p + 4;
if (p > cmd_line && p[-1] != ' ')
continue;
@@ -575,7 +575,7 @@ #endif
 
 #ifdef CONFIG_PPC_STD_MMU
/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */
-   if (Hash != 0 && pte_young(pte)) {
+   if (Hash != NULL && pte_young(pte)) {
struct mm_struct *mm;
pmd_t *pmd;
 
diff --git a/arch/ppc/mm/mmu_decl.h b/arch/ppc/mm/mmu_decl.h
index 540f329..0ff8967 100644
--- a/arch/ppc/mm/mmu_decl.h
+++ b/arch/ppc/mm/mmu_decl.h
@@ -76,7 +76,7 @@ extern unsigned long mmu_mapin_ram(void)
 static inline void flush_HPTE(unsigned context, unsigned long va,
  unsigned long pdval)
 {
-   if ((Hash != 0) &&
+   if ((Hash != NULL) &&
cpu_has_feature(CPU_FTR_HPTE_TABLE))
flush_hash_pages(0, va, pdval, 1);
else
diff --git a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
index 35ebb63..1ce8c56 100644
--- a/arch/ppc/mm/pgtable.c
+++ b/arch/ppc/mm/pgtable.c
@@ -219,7 +219,7 @@ __ioremap(phys_addr_t addr, unsigned lon
if (mem_init_done) {
struct vm_struct *area;
area = get_vm_area(size, VM_IOREMAP);
-   if (area == 0)
+   if (area == NULL)
return NULL;
v = (unsigned long) area->addr;
} else {
@@ -283,7 +283,7 @@ map_page(unsigned long va, phys_addr_t p
pd = pmd_offset(pgd_offset_k(va), va);
/* Use middle 10 bits of VA to index the second-level map */
pg = pte_alloc_kernel(pd, va);
-   if (pg != 0) {
+   if (pg != NULL) {
err = 0;
set_pte_at(_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT, 
__pgprot(flags)));
if (mem_init_done)
diff --git a/arch/ppc/mm/tlb.c b/arch/ppc/mm/tlb.c
index 4ff260b..d4b68bd 100644
--- a/arch/ppc/mm/tlb.c
+++ b/arch/ppc/mm/tlb.c
@@ -40,7 +40,7 @@ void flush_hash_entry(struct mm_struct *
 {
unsigned long ptephys;
 
-   if (Hash != 0) {
+   if (Hash != NULL) {
ptephys = __pa(ptep) & PAGE_MASK;
flush_hash_pages(mm->context.id, addr, ptephys, 1);
}
@@ -52,7 +52,7 @@ void flush_hash_entry(struct mm_struct *
  */
 void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr)
 {
-   if (Hash != 0)
+   if (Hash != N

[PATCH 15/68] 0 -> NULL, for arch/sh64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 ioremap.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sh64/mm/ioremap.c b/arch/sh64/mm/ioremap.c
index 9908577..b335849 100644
--- a/arch/sh64/mm/ioremap.c
+++ b/arch/sh64/mm/ioremap.c
@@ -167,7 +167,7 @@ static unsigned long shmedia_alloc_io(un
 
 if (name == NULL) name = "???";
 
-if ((xres = xres_alloc()) != 0) {
+if ((xres = xres_alloc()) != NULL) {
 tack = xres->xname;
 res = >xres;
 } else {
@@ -364,7 +364,7 @@ ioremap_proc_info(char *buf, char **star
for (r = ((struct resource *)data)->child; r != NULL; r = r->sibling) {
if (p + 32 >= e)/* Better than nothing */
break;
-   if ((nm = r->name) == 0) nm = "???";
+   if ((nm = r->name) == NULL) nm = "???";
p += sprintf(p, "%08lx-%08lx: %s\n",
 (unsigned long)r->start,
 (unsigned long)r->end, nm);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/68] 0 -> NULL, for arch/powerpc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 boot/prpmc2800.c|2 +-
 kernel/btext.c  |8 
 kernel/legacy_serial.c  |2 +-
 kernel/pci-common.c |2 +-
 kernel/pci_32.c |8 
 kernel/prom.c   |4 ++--
 kernel/setup_64.c   |4 ++--
 kernel/signal_64.c  |4 ++--
 mm/mmu_decl.h   |2 +-
 mm/pgtable_32.c |4 ++--
 mm/ppc_mmu_32.c |2 +-
 mm/tlb_32.c |   12 ++--
 platforms/52xx/lite5200.c   |2 +-
 platforms/83xx/mpc832x_mds.c|2 +-
 platforms/83xx/mpc836x_mds.c|2 +-
 platforms/85xx/mpc85xx_ads.c|4 ++--
 platforms/85xx/mpc85xx_cds.c|4 ++--
 platforms/86xx/mpc86xx_hpcn.c   |4 ++--
 platforms/8xx/mpc86xads_setup.c |4 ++--
 platforms/8xx/mpc885ads_setup.c |4 ++--
 platforms/maple/pci.c   |2 +-
 platforms/maple/setup.c |2 +-
 platforms/powermac/pci.c|2 +-
 platforms/powermac/pfunc_core.c |2 +-
 platforms/powermac/setup.c  |6 +++---
 platforms/powermac/time.c   |6 +++---
 platforms/pseries/setup.c   |2 +-
 sysdev/qe_lib/qe_io.c   |2 +-
 xmon/spu-dis.c  |   18 +-
 xmon/xmon.c |4 ++--
 30 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/arch/powerpc/boot/prpmc2800.c b/arch/powerpc/boot/prpmc2800.c
index f428bac..b130e5b 100644
--- a/arch/powerpc/boot/prpmc2800.c
+++ b/arch/powerpc/boot/prpmc2800.c
@@ -480,7 +480,7 @@ static void prpmc2800_reset(void)
 
udelay(500);
 
-   if (bridge_base != 0) {
+   if (bridge_base != NULL) {
temp = in_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_0));
temp &= 0x0FFF;
out_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_0), temp);
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index e7b6846..6d9b68b 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -142,14 +142,14 @@ static void map_boot_text(void)
 
/* By default, we are no longer mapped */
boot_text_mapped = 0;
-   if (dispDeviceBase == 0)
+   if (dispDeviceBase == NULL)
return;
base = ((unsigned long) dispDeviceBase) & 0xF000UL;
offset = ((unsigned long) dispDeviceBase) - base;
size = dispDeviceRowBytes * dispDeviceRect[3] + offset
+ dispDeviceRect[0];
vbase = __ioremap(base, size, _PAGE_NO_CACHE);
-   if (vbase == 0)
+   if (vbase == NULL)
return;
logicalDisplayBase = vbase + offset;
boot_text_mapped = 1;
@@ -253,7 +253,7 @@ static unsigned char * calc_base(int x, 
unsigned char *base;
 
base = logicalDisplayBase;
-   if (base == 0)
+   if (base == NULL)
base = dispDeviceBase;
base += (x + dispDeviceRect[0]) * (dispDeviceDepth >> 3);
base += (y + dispDeviceRect[1]) * dispDeviceRowBytes;
@@ -264,7 +264,7 @@ static unsigned char * calc_base(int x, 
 void btext_update_display(unsigned long phys, int width, int height,
  int depth, int pitch)
 {
-   if (dispDeviceBase == 0)
+   if (dispDeviceBase == NULL)
return;
 
/* check it's the same frame buffer (within 256MB) */
diff --git a/arch/powerpc/kernel/legacy_serial.c 
b/arch/powerpc/kernel/legacy_serial.c
index cea8045..330bd21 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -67,7 +67,7 @@ static int __init add_legacy_port(struct
legacy_serial_count = index + 1;
 
/* Check if there is a port who already claimed our slot */
-   if (legacy_serial_infos[index].np != 0) {
+   if (legacy_serial_infos[index].np != NULL) {
/* if we still have some room, move it, else override */
if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) {
printk(KERN_DEBUG "Moved legacy port %d -> %d\n",
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fe7d125..5fa0be3 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -256,7 +256,7 @@ static struct resource *__pci_mmap_make_
unsigned long io_offset = 0;
int i, res_bit;
 
-   if (hose == 0)
+   if (hose == NULL)
return NULL;/* should never happen */
 
/* If memory, add on the PCI bridge address offset

[PATCH 11/68] 0 -> NULL, for arch/parisc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 smp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 04c7e1d..16fccbe 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -333,7 +333,7 @@ smp_call_function (void (*func) (void *i
 
if (retry) {
spin_lock ();
-   while (smp_call_function_data != 0)
+   while (smp_call_function_data != NULL)
barrier();
}
else {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/68] 0 -> NULL, for arch/mips

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 ops-emma2rh.c |2 +-
 ops-pnx8550.c |   12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/mips/pci/ops-emma2rh.c b/arch/mips/pci/ops-emma2rh.c
index 38f1816..d31bfc6 100644
--- a/arch/mips/pci/ops-emma2rh.c
+++ b/arch/mips/pci/ops-emma2rh.c
@@ -45,7 +45,7 @@ static int check_args(struct pci_bus *bu
/* check if the bus is top-level */
if (bus->parent != NULL) {
*bus_num = bus->number;
-   db_assert(bus_num != 0);
+   db_assert(bus_num != NULL);
} else
*bus_num = 0;
 
diff --git a/arch/mips/pci/ops-pnx8550.c b/arch/mips/pci/ops-pnx8550.c
index f556b7a..d610646 100644
--- a/arch/mips/pci/ops-pnx8550.c
+++ b/arch/mips/pci/ops-pnx8550.c
@@ -117,7 +117,7 @@ read_config_byte(struct pci_bus *bus, un
unsigned int data = 0;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
err = config_access(PCI_CMD_CONFIG_READ, bus, devfn, where, ~(1 << 
(where & 3)), );
@@ -145,7 +145,7 @@ read_config_word(struct pci_bus *bus, un
unsigned int data = 0;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where & 0x01)
@@ -168,7 +168,7 @@ static int
 read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 * 
val)
 {
int err;
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where & 0x03)
@@ -185,7 +185,7 @@ write_config_byte(struct pci_bus *bus, u
unsigned int data = (unsigned int)val;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
switch (where & 0x03) {
@@ -213,7 +213,7 @@ write_config_word(struct pci_bus *bus, u
unsigned int data = (unsigned int)val;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where & 0x01)
@@ -235,7 +235,7 @@ static int
 write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val)
 {
int err;
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where & 0x03)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/68] 0 -> NULL, for arch/m68k

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 stram.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/atari/stram.c b/arch/m68k/atari/stram.c
index bf4588c..a37b985 100644
--- a/arch/m68k/atari/stram.c
+++ b/arch/m68k/atari/stram.c
@@ -130,7 +130,7 @@ void __init atari_stram_init(void)
/* determine whether kernel code resides in ST-RAM (then ST-RAM is the
 * first memory block at virtual 0x0) */
stram_start = phys_to_virt(0);
-   kernel_in_stram = (stram_start == 0);
+   kernel_in_stram = (stram_start == NULL);
 
for( i = 0; i < m68k_num_memory; ++i ) {
if (m68k_memory[i].addr == 0) {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/68] 0 -> NULL, for arch/m68knommu

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 comempci.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68knommu/kernel/comempci.c b/arch/m68knommu/kernel/comempci.c
index 6ee00ef..528517e 100644
--- a/arch/m68knommu/kernel/comempci.c
+++ b/arch/m68knommu/kernel/comempci.c
@@ -736,7 +736,7 @@ #endif
 
/* Find a free spot to put this handler */
for (i = 0; (i < COMEM_MAXPCI); i++) {
-   if (pci_irqlist[i].handler == 0) {
+   if (pci_irqlist[i].handler == NULL) {
pci_irqlist[i].handler = handler;
pci_irqlist[i].device = device;
pci_irqlist[i].dev_id = dev_id;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/68] 0 -> NULL, for arch/ia64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 simscsi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c
index bb87682..64248b5 100644
--- a/arch/ia64/hp/sim/simscsi.c
+++ b/arch/ia64/hp/sim/simscsi.c
@@ -101,7 +101,7 @@ simscsi_interrupt (unsigned long val)
 {
struct scsi_cmnd *sc;
 
-   while ((sc = queue[rd].sc) != 0) {
+   while ((sc = queue[rd].sc) != NULL) {
atomic_dec(_reqs);
queue[rd].sc = NULL;
if (DBG)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/68] 0 -> NULL, for arch/frv

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 dma-alloc.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/frv/mm/dma-alloc.c b/arch/frv/mm/dma-alloc.c
index dc6522c..eb67cef 100644
--- a/arch/frv/mm/dma-alloc.c
+++ b/arch/frv/mm/dma-alloc.c
@@ -61,7 +61,7 @@ static int map_page(unsigned long va, un
 
/* Use middle 10 bits of VA to index the second-level map */
pte = pte_alloc_kernel(pme, va);
-   if (pte != 0) {
+   if (pte != NULL) {
err = 0;
set_pte(pte, mk_pte_phys(pa & PAGE_MASK, prot));
}
@@ -99,7 +99,7 @@ void *consistent_alloc(gfp_t gfp, size_t
 
/* allocate some common virtual space to map the new pages */
area = get_vm_area(size, VM_ALLOC);
-   if (area == 0) {
+   if (area == NULL) {
free_pages(page, order);
return NULL;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/68] 0 -> NULL, for arch/arm26

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 udivdi3.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm26/lib/udivdi3.c b/arch/arm26/lib/udivdi3.c
index d25195f..0f8e702 100644
--- a/arch/arm26/lib/udivdi3.c
+++ b/arch/arm26/lib/udivdi3.c
@@ -127,7 +127,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
   /* Remainder in n0 >> bm.  */
 }
 
-  if (rp != 0)
+  if (rp != NULL)
 {
   rr.s.low = n0 >> bm;
   rr.s.high = 0;
@@ -144,7 +144,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
   q1 = 0;
 
   /* Remainder in n1n0.  */
-  if (rp != 0)
+  if (rp != NULL)
 {
   rr.s.low = n0;
   rr.s.high = n1;
@@ -176,7 +176,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
 
   q1 = 0;
 
-  if (rp != 0)
+  if (rp != NULL)
 {
   rr.s.low = n0;
   rr.s.high = n1;
@@ -208,7 +208,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
   q1 = 0;
 
   /* Remainder in (n1n0 - m1m0) >> bm.  */
-  if (rp != 0)
+  if (rp != NULL)
 {
   sub_ddmmss (n1, n0, n1, n0, m1, m0);
   rr.s.low = (n1 << b) | (n0 >> bm);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/68] 0 -> NULL, for arch/blackfin

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 traps.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index 3909f5b..691c66d 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -546,7 +546,7 @@ void dump_bfin_regs(struct pt_regs *fp, 
}
 
printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr);
-   if (retaddr != 0 && retaddr <= (void *)physical_mem_end
+   if (retaddr != NULL && retaddr <= (void *)physical_mem_end
 #if L1_CODE_LENGTH != 0
/* FIXME: Copy the code out of L1 Instruction SRAM through dma
   memcpy.  */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/68] 0 -> NULL, for arch/cris

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 fault.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
index 8672ab7..d5b1e3d 100644
--- a/arch/cris/mm/fault.c
+++ b/arch/cris/mm/fault.c
@@ -448,7 +448,7 @@ find_fixup_code(struct pt_regs *regs)
 {
const struct exception_table_entry *fixup;
 
-   if ((fixup = search_exception_tables(instruction_pointer(regs))) != 0) {
+   if ((fixup = search_exception_tables(instruction_pointer(regs))) != 
NULL) {
/* Adjust the instruction pointer in the stackframe. */
instruction_pointer(regs) = fixup->fixup;
arch_fixup(regs);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/68] 0 -> NULL, for arch/arm

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 common/dmabounce.c |2 +-
 mach-omap1/clock.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index b36b1e8..74ff750 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -238,7 +238,7 @@ map_single(struct device *dev, void *ptr
struct safe_buffer *buf;
 
buf = alloc_safe_buffer(device_info, ptr, size, dir);
-   if (buf == 0) {
+   if (buf == NULL) {
dev_err(dev, "%s: unable to map unsafe buffer %p!\n",
   __func__, ptr);
return 0;
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index f625f6d..b7e1b22 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -193,7 +193,7 @@ static int calc_dsor_exp(struct clk *clk
return -EINVAL;
 
parent = clk->parent;
-   if (unlikely(parent == 0))
+   if (unlikely(parent == NULL))
return -EIO;
 
realrate = parent->rate;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/68] 0 -> NULL, for arch/alpha

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/smp.c   |4 ++--
 kernel/traps.c |2 +-
 mm/fault.c |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index b287314..4317a7c 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -270,7 +270,7 @@ recv_secondary_console_msg(void)
cp2 = buf;
strcpy(cp2, cp1);

-   while ((cp2 = strchr(cp2, '\r')) != 0) {
+   while ((cp2 = strchr(cp2, '\r')) != NULL) {
*cp2 = ' ';
if (cp2[1] == '\n')
cp2[1] = ' ';
@@ -597,7 +597,7 @@ pointer_lock (void *lock, void *data, in
: "r"(data)
: "memory");
 
-   if (old == 0)
+   if (old == NULL)
return 0;
if (! retry)
return -EBUSY;
diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index ec0f05e..48b4015 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -628,7 +628,7 @@ do_entUna(void * va, unsigned long opcod
 got_exception:
/* Ok, we caught the exception, but we don't want it.  Is there
   someone to pass it along to?  */
-   if ((fixup = search_exception_tables(pc)) != 0) {
+   if ((fixup = search_exception_tables(pc)) != NULL) {
unsigned long newpc;
newpc = fixup_exception(una_reg, fixup, pc);
 
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index a0e18da..dffca85 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -171,7 +171,7 @@ #endif
 
  no_context:
/* Are we prepared to handle this fault as an exception?  */
-   if ((fixup = search_exception_tables(regs->pc)) != 0) {
+   if ((fixup = search_exception_tables(regs->pc)) != NULL) {
unsigned long newpc;
newpc = fixup_exception(dpf_reg, fixup, regs->pc);
regs->pc = newpc;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 06/68] 0 - NULL, for arch/frv

2007-07-27 Thread Yoann Padioleau
Al Viro [EMAIL PROTECTED] writes:

 On Fri, Jul 27, 2007 at 11:44:35AM +0200, Yoann Padioleau wrote:
  pte = pte_alloc_kernel(pme, va);
 -if (pte != 0) {
 +if (pte != NULL) {
  err = 0;
  set_pte(pte, mk_pte_phys(pa  PAGE_MASK, prot));
  }
 @@ -99,7 +99,7 @@ void *consistent_alloc(gfp_t gfp, size_t
  
  /* allocate some common virtual space to map the new pages */
  area = get_vm_area(size, VM_ALLOC);
 -if (area == 0) {
 +if (area == NULL) {
  free_pages(page, order);
  return NULL;

 Same comment about comparisons with NULL after allocation...

I don't understand. pte is a pointer right ? So why should we
keep the == 0 ? 

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/68] 0 - NULL, for arch/sparc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/ioport.c |6 +++---
 kernel/pcic.c   |2 +-
 kernel/prom.c   |2 +-
 prom/bootstr.c  |2 +-
 prom/tree.c |2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 62182d2..3f1a8e2 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -181,7 +181,7 @@ static void __iomem *_sparc_alloc_io(uns
 
if (name == NULL) name = ???;
 
-   if ((xres = xres_alloc()) != 0) {
+   if ((xres = xres_alloc()) != NULL) {
tack = xres-xname;
res = xres-xres;
} else {
@@ -835,7 +835,7 @@ _sparc_io_get_info(char *buf, char **sta
for (r = ((struct resource *)data)-child; r != NULL; r = r-sibling) {
if (p + 32 = e)/* Better than nothing */
break;
-   if ((nm = r-name) == 0) nm = ???;
+   if ((nm = r-name) == NULL) nm = ???;
p += sprintf(p, %016llx-%016llx: %s\n,
(unsigned long long)r-start,
(unsigned long long)r-end, nm);
@@ -858,7 +858,7 @@ _sparc_find_resource(struct resource *ro
 {
 struct resource *tmp;
 
-   for (tmp = root-child; tmp != 0; tmp = tmp-sibling) {
+   for (tmp = root-child; tmp != NULL; tmp = tmp-sibling) {
if (tmp-start = hit  tmp-end = hit)
return tmp;
}
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index f2eae45..eace6e5 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -540,7 +540,7 @@ pcic_fill_irq(struct linux_pcic *pcic, s
prom_getstring(node, name, namebuf, sizeof(namebuf));
}
 
-   if ((p = pcic-pcic_imap) == 0) {
+   if ((p = pcic-pcic_imap) == NULL) {
dev-irq = 0;
return;
}
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index e3a5376..b5ab1a6 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -33,7 +33,7 @@ struct device_node *of_find_node_by_phan
 {
struct device_node *np;
 
-   for (np = allnodes; np != 0; np = np-allnext)
+   for (np = allnodes; np != NULL; np = np-allnext)
if (np-node == handle)
break;
 
diff --git a/arch/sparc/prom/bootstr.c b/arch/sparc/prom/bootstr.c
index cfdeac2..1f850b9 100644
--- a/arch/sparc/prom/bootstr.c
+++ b/arch/sparc/prom/bootstr.c
@@ -33,7 +33,7 @@ prom_getbootargs(void)
/* Start from 1 and go over fd(0,0,0)kernel */
for(iter = 1; iter  8; iter++) {
arg = (*(romvec-pv_v0bootargs))-argv[iter];
-   if(arg == 0) break;
+   if(arg == NULL) break;
while(*arg != 0) {
/* Leave place for space and null. */
if(cp = barg_buf + BARG_LEN-2){
diff --git a/arch/sparc/prom/tree.c b/arch/sparc/prom/tree.c
index 5ec2465..782be75 100644
--- a/arch/sparc/prom/tree.c
+++ b/arch/sparc/prom/tree.c
@@ -309,7 +309,7 @@ int prom_setprop(int node, char *pname, 
int ret;
 
if(size == 0) return 0;
-   if((pname == 0) || (value == 0)) return 0;
+   if((pname == NULL) || (value == NULL)) return 0;
spin_lock_irqsave(prom_lock, flags);
ret = prom_nodeops-no_setprop(node, pname, value, size);
restore_current();

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/68] 0 - NULL, for arch/sh

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 cchips/hd6446x/hd64461.c   |2 +-
 cchips/hd6446x/hd64465/gpio.c  |4 ++--
 cchips/hd6446x/hd64465/setup.c |2 +-
 cchips/voyagergx/irq.c |2 +-
 kernel/sh_bios.c   |2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/sh/cchips/hd6446x/hd64461.c b/arch/sh/cchips/hd6446x/hd64461.c
index 97f6512..6117fd7 100644
--- a/arch/sh/cchips/hd6446x/hd64461.c
+++ b/arch/sh/cchips/hd6446x/hd64461.c
@@ -116,7 +116,7 @@ int hd64461_irq_demux(int irq)
irq = CONFIG_HD64461_IRQ;
else {
irq = HD64461_IRQBASE + i;
-   if (hd64461_demux[i].func != 0) {
+   if (hd64461_demux[i].func != NULL) {
irq = hd64461_demux[i].func(irq, 
hd64461_demux[i].dev);
}
}
diff --git a/arch/sh/cchips/hd6446x/hd64465/gpio.c 
b/arch/sh/cchips/hd6446x/hd64465/gpio.c
index 4343185..8ed39e2 100644
--- a/arch/sh/cchips/hd6446x/hd64465/gpio.c
+++ b/arch/sh/cchips/hd6446x/hd64465/gpio.c
@@ -96,7 +96,7 @@ static irqreturn_t hd64465_gpio_interrup
mask = 1pin;
if (isr  mask) {
portpin = (port3)|pin;
-   if (handlers[portpin].func != 0)
+   if (handlers[portpin].func != NULL)
handlers[portpin].func(portpin, handlers[portpin].dev);
else
printk(KERN_NOTICE unexpected GPIO interrupt, pin 
%c%d\n,
@@ -117,7 +117,7 @@ void hd64465_gpio_register_irq(int portp
unsigned long flags;
unsigned short icr, mask;
 
-   if (handler == 0)
+   if (handler == NULL)
return;

local_irq_save(flags);
diff --git a/arch/sh/cchips/hd6446x/hd64465/setup.c 
b/arch/sh/cchips/hd6446x/hd64465/setup.c
index d126e1f..f6c4139 100644
--- a/arch/sh/cchips/hd6446x/hd64465/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64465/setup.c
@@ -140,7 +140,7 @@ int hd64465_irq_demux(int irq)
 
if (i  HD64465_IRQ_NUM) {
irq = HD64465_IRQ_BASE + i;
-   if (hd64465_demux[i].func != 0)
+   if (hd64465_demux[i].func != NULL)
irq = hd64465_demux[i].func(irq, hd64465_demux[i].dev);
}
}
diff --git a/arch/sh/cchips/voyagergx/irq.c b/arch/sh/cchips/voyagergx/irq.c
index d70e5c8..9631e9a 100644
--- a/arch/sh/cchips/voyagergx/irq.c
+++ b/arch/sh/cchips/voyagergx/irq.c
@@ -128,7 +128,7 @@ int voyagergx_irq_demux(int irq)
pr_debug(voyagergx_irq_demux %ld \n, i);
if (i  VOYAGER_IRQ_NUM) {
irq = VOYAGER_IRQ_BASE + i;
-   if (voyagergx_demux[i].func != 0)
+   if (voyagergx_demux[i].func != NULL)
irq = voyagergx_demux[i].func(irq,
voyagergx_demux[i].dev);
}
diff --git a/arch/sh/kernel/sh_bios.c b/arch/sh/kernel/sh_bios.c
index d1bcac4..c91585c 100644
--- a/arch/sh/kernel/sh_bios.c
+++ b/arch/sh/kernel/sh_bios.c
@@ -56,7 +56,7 @@ int sh_bios_in_gdb_mode(void)
gdb_mode_p = (char *)r;
queried = 1;
 }
-return (gdb_mode_p != 0 ? *gdb_mode_p : 0);
+return (gdb_mode_p != NULL ? *gdb_mode_p : 0);
 }
 
 void sh_bios_gdb_detach(void)

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/68] 0 - NULL, for arch/powerpc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 boot/prpmc2800.c|2 +-
 kernel/btext.c  |8 
 kernel/legacy_serial.c  |2 +-
 kernel/pci-common.c |2 +-
 kernel/pci_32.c |8 
 kernel/prom.c   |4 ++--
 kernel/setup_64.c   |4 ++--
 kernel/signal_64.c  |4 ++--
 mm/mmu_decl.h   |2 +-
 mm/pgtable_32.c |4 ++--
 mm/ppc_mmu_32.c |2 +-
 mm/tlb_32.c |   12 ++--
 platforms/52xx/lite5200.c   |2 +-
 platforms/83xx/mpc832x_mds.c|2 +-
 platforms/83xx/mpc836x_mds.c|2 +-
 platforms/85xx/mpc85xx_ads.c|4 ++--
 platforms/85xx/mpc85xx_cds.c|4 ++--
 platforms/86xx/mpc86xx_hpcn.c   |4 ++--
 platforms/8xx/mpc86xads_setup.c |4 ++--
 platforms/8xx/mpc885ads_setup.c |4 ++--
 platforms/maple/pci.c   |2 +-
 platforms/maple/setup.c |2 +-
 platforms/powermac/pci.c|2 +-
 platforms/powermac/pfunc_core.c |2 +-
 platforms/powermac/setup.c  |6 +++---
 platforms/powermac/time.c   |6 +++---
 platforms/pseries/setup.c   |2 +-
 sysdev/qe_lib/qe_io.c   |2 +-
 xmon/spu-dis.c  |   18 +-
 xmon/xmon.c |4 ++--
 30 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/arch/powerpc/boot/prpmc2800.c b/arch/powerpc/boot/prpmc2800.c
index f428bac..b130e5b 100644
--- a/arch/powerpc/boot/prpmc2800.c
+++ b/arch/powerpc/boot/prpmc2800.c
@@ -480,7 +480,7 @@ static void prpmc2800_reset(void)
 
udelay(500);
 
-   if (bridge_base != 0) {
+   if (bridge_base != NULL) {
temp = in_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_0));
temp = 0x0FFF;
out_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_0), temp);
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index e7b6846..6d9b68b 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -142,14 +142,14 @@ static void map_boot_text(void)
 
/* By default, we are no longer mapped */
boot_text_mapped = 0;
-   if (dispDeviceBase == 0)
+   if (dispDeviceBase == NULL)
return;
base = ((unsigned long) dispDeviceBase)  0xF000UL;
offset = ((unsigned long) dispDeviceBase) - base;
size = dispDeviceRowBytes * dispDeviceRect[3] + offset
+ dispDeviceRect[0];
vbase = __ioremap(base, size, _PAGE_NO_CACHE);
-   if (vbase == 0)
+   if (vbase == NULL)
return;
logicalDisplayBase = vbase + offset;
boot_text_mapped = 1;
@@ -253,7 +253,7 @@ static unsigned char * calc_base(int x, 
unsigned char *base;
 
base = logicalDisplayBase;
-   if (base == 0)
+   if (base == NULL)
base = dispDeviceBase;
base += (x + dispDeviceRect[0]) * (dispDeviceDepth  3);
base += (y + dispDeviceRect[1]) * dispDeviceRowBytes;
@@ -264,7 +264,7 @@ static unsigned char * calc_base(int x, 
 void btext_update_display(unsigned long phys, int width, int height,
  int depth, int pitch)
 {
-   if (dispDeviceBase == 0)
+   if (dispDeviceBase == NULL)
return;
 
/* check it's the same frame buffer (within 256MB) */
diff --git a/arch/powerpc/kernel/legacy_serial.c 
b/arch/powerpc/kernel/legacy_serial.c
index cea8045..330bd21 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -67,7 +67,7 @@ static int __init add_legacy_port(struct
legacy_serial_count = index + 1;
 
/* Check if there is a port who already claimed our slot */
-   if (legacy_serial_infos[index].np != 0) {
+   if (legacy_serial_infos[index].np != NULL) {
/* if we still have some room, move it, else override */
if (legacy_serial_count  MAX_LEGACY_SERIAL_PORTS) {
printk(KERN_DEBUG Moved legacy port %d - %d\n,
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fe7d125..5fa0be3 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -256,7 +256,7 @@ static struct resource *__pci_mmap_make_
unsigned long io_offset = 0;
int i, res_bit;
 
-   if (hose == 0)
+   if (hose == NULL)
return NULL;/* should never happen */
 
/* If memory, add on the PCI bridge address offset */
diff --git a/arch/powerpc/kernel/pci_32.c b

[PATCH 08/68] 0 - NULL, for arch/m68k

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 stram.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/atari/stram.c b/arch/m68k/atari/stram.c
index bf4588c..a37b985 100644
--- a/arch/m68k/atari/stram.c
+++ b/arch/m68k/atari/stram.c
@@ -130,7 +130,7 @@ void __init atari_stram_init(void)
/* determine whether kernel code resides in ST-RAM (then ST-RAM is the
 * first memory block at virtual 0x0) */
stram_start = phys_to_virt(0);
-   kernel_in_stram = (stram_start == 0);
+   kernel_in_stram = (stram_start == NULL);
 
for( i = 0; i  m68k_num_memory; ++i ) {
if (m68k_memory[i].addr == 0) {

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/68] 0 - NULL, for arch/ia64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 simscsi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c
index bb87682..64248b5 100644
--- a/arch/ia64/hp/sim/simscsi.c
+++ b/arch/ia64/hp/sim/simscsi.c
@@ -101,7 +101,7 @@ simscsi_interrupt (unsigned long val)
 {
struct scsi_cmnd *sc;
 
-   while ((sc = queue[rd].sc) != 0) {
+   while ((sc = queue[rd].sc) != NULL) {
atomic_dec(num_reqs);
queue[rd].sc = NULL;
if (DBG)

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/68] 0 - NULL, for arch/arm26

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 udivdi3.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm26/lib/udivdi3.c b/arch/arm26/lib/udivdi3.c
index d25195f..0f8e702 100644
--- a/arch/arm26/lib/udivdi3.c
+++ b/arch/arm26/lib/udivdi3.c
@@ -127,7 +127,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
   /* Remainder in n0  bm.  */
 }
 
-  if (rp != 0)
+  if (rp != NULL)
 {
   rr.s.low = n0  bm;
   rr.s.high = 0;
@@ -144,7 +144,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
   q1 = 0;
 
   /* Remainder in n1n0.  */
-  if (rp != 0)
+  if (rp != NULL)
 {
   rr.s.low = n0;
   rr.s.high = n1;
@@ -176,7 +176,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
 
   q1 = 0;
 
-  if (rp != 0)
+  if (rp != NULL)
 {
   rr.s.low = n0;
   rr.s.high = n1;
@@ -208,7 +208,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDIt
   q1 = 0;
 
   /* Remainder in (n1n0 - m1m0)  bm.  */
-  if (rp != 0)
+  if (rp != NULL)
 {
   sub_ddmmss (n1, n0, n1, n0, m1, m0);
   rr.s.low = (n1  b) | (n0  bm);

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/68] 0 - NULL, for arch/alpha

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/smp.c   |4 ++--
 kernel/traps.c |2 +-
 mm/fault.c |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index b287314..4317a7c 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -270,7 +270,7 @@ recv_secondary_console_msg(void)
cp2 = buf;
strcpy(cp2, cp1);

-   while ((cp2 = strchr(cp2, '\r')) != 0) {
+   while ((cp2 = strchr(cp2, '\r')) != NULL) {
*cp2 = ' ';
if (cp2[1] == '\n')
cp2[1] = ' ';
@@ -597,7 +597,7 @@ pointer_lock (void *lock, void *data, in
: r(data)
: memory);
 
-   if (old == 0)
+   if (old == NULL)
return 0;
if (! retry)
return -EBUSY;
diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index ec0f05e..48b4015 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -628,7 +628,7 @@ do_entUna(void * va, unsigned long opcod
 got_exception:
/* Ok, we caught the exception, but we don't want it.  Is there
   someone to pass it along to?  */
-   if ((fixup = search_exception_tables(pc)) != 0) {
+   if ((fixup = search_exception_tables(pc)) != NULL) {
unsigned long newpc;
newpc = fixup_exception(una_reg, fixup, pc);
 
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index a0e18da..dffca85 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -171,7 +171,7 @@ #endif
 
  no_context:
/* Are we prepared to handle this fault as an exception?  */
-   if ((fixup = search_exception_tables(regs-pc)) != 0) {
+   if ((fixup = search_exception_tables(regs-pc)) != NULL) {
unsigned long newpc;
newpc = fixup_exception(dpf_reg, fixup, regs-pc);
regs-pc = newpc;

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/68] 0 - NULL, for arch/arm

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 common/dmabounce.c |2 +-
 mach-omap1/clock.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index b36b1e8..74ff750 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -238,7 +238,7 @@ map_single(struct device *dev, void *ptr
struct safe_buffer *buf;
 
buf = alloc_safe_buffer(device_info, ptr, size, dir);
-   if (buf == 0) {
+   if (buf == NULL) {
dev_err(dev, %s: unable to map unsafe buffer %p!\n,
   __func__, ptr);
return 0;
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index f625f6d..b7e1b22 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -193,7 +193,7 @@ static int calc_dsor_exp(struct clk *clk
return -EINVAL;
 
parent = clk-parent;
-   if (unlikely(parent == 0))
+   if (unlikely(parent == NULL))
return -EIO;
 
realrate = parent-rate;

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/68] 0 - NULL, for arch/blackfin

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 traps.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index 3909f5b..691c66d 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -546,7 +546,7 @@ void dump_bfin_regs(struct pt_regs *fp, 
}
 
printk(KERN_EMERG return address: [0x%p]; contents of:, retaddr);
-   if (retaddr != 0  retaddr = (void *)physical_mem_end
+   if (retaddr != NULL  retaddr = (void *)physical_mem_end
 #if L1_CODE_LENGTH != 0
/* FIXME: Copy the code out of L1 Instruction SRAM through dma
   memcpy.  */

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/68] 0 - NULL, for arch/cris

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 fault.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
index 8672ab7..d5b1e3d 100644
--- a/arch/cris/mm/fault.c
+++ b/arch/cris/mm/fault.c
@@ -448,7 +448,7 @@ find_fixup_code(struct pt_regs *regs)
 {
const struct exception_table_entry *fixup;
 
-   if ((fixup = search_exception_tables(instruction_pointer(regs))) != 0) {
+   if ((fixup = search_exception_tables(instruction_pointer(regs))) != 
NULL) {
/* Adjust the instruction pointer in the stackframe. */
instruction_pointer(regs) = fixup-fixup;
arch_fixup(regs);

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/68] 0 - NULL, for arch/frv

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 dma-alloc.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/frv/mm/dma-alloc.c b/arch/frv/mm/dma-alloc.c
index dc6522c..eb67cef 100644
--- a/arch/frv/mm/dma-alloc.c
+++ b/arch/frv/mm/dma-alloc.c
@@ -61,7 +61,7 @@ static int map_page(unsigned long va, un
 
/* Use middle 10 bits of VA to index the second-level map */
pte = pte_alloc_kernel(pme, va);
-   if (pte != 0) {
+   if (pte != NULL) {
err = 0;
set_pte(pte, mk_pte_phys(pa  PAGE_MASK, prot));
}
@@ -99,7 +99,7 @@ void *consistent_alloc(gfp_t gfp, size_t
 
/* allocate some common virtual space to map the new pages */
area = get_vm_area(size, VM_ALLOC);
-   if (area == 0) {
+   if (area == NULL) {
free_pages(page, order);
return NULL;
}

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/68] 0 - NULL, for arch/m68knommu

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 comempci.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68knommu/kernel/comempci.c b/arch/m68knommu/kernel/comempci.c
index 6ee00ef..528517e 100644
--- a/arch/m68knommu/kernel/comempci.c
+++ b/arch/m68knommu/kernel/comempci.c
@@ -736,7 +736,7 @@ #endif
 
/* Find a free spot to put this handler */
for (i = 0; (i  COMEM_MAXPCI); i++) {
-   if (pci_irqlist[i].handler == 0) {
+   if (pci_irqlist[i].handler == NULL) {
pci_irqlist[i].handler = handler;
pci_irqlist[i].device = device;
pci_irqlist[i].dev_id = dev_id;

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/68] 0 - NULL, for arch/mips

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 ops-emma2rh.c |2 +-
 ops-pnx8550.c |   12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/mips/pci/ops-emma2rh.c b/arch/mips/pci/ops-emma2rh.c
index 38f1816..d31bfc6 100644
--- a/arch/mips/pci/ops-emma2rh.c
+++ b/arch/mips/pci/ops-emma2rh.c
@@ -45,7 +45,7 @@ static int check_args(struct pci_bus *bu
/* check if the bus is top-level */
if (bus-parent != NULL) {
*bus_num = bus-number;
-   db_assert(bus_num != 0);
+   db_assert(bus_num != NULL);
} else
*bus_num = 0;
 
diff --git a/arch/mips/pci/ops-pnx8550.c b/arch/mips/pci/ops-pnx8550.c
index f556b7a..d610646 100644
--- a/arch/mips/pci/ops-pnx8550.c
+++ b/arch/mips/pci/ops-pnx8550.c
@@ -117,7 +117,7 @@ read_config_byte(struct pci_bus *bus, un
unsigned int data = 0;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
err = config_access(PCI_CMD_CONFIG_READ, bus, devfn, where, ~(1  
(where  3)), data);
@@ -145,7 +145,7 @@ read_config_word(struct pci_bus *bus, un
unsigned int data = 0;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where  0x01)
@@ -168,7 +168,7 @@ static int
 read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 * 
val)
 {
int err;
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where  0x03)
@@ -185,7 +185,7 @@ write_config_byte(struct pci_bus *bus, u
unsigned int data = (unsigned int)val;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
switch (where  0x03) {
@@ -213,7 +213,7 @@ write_config_word(struct pci_bus *bus, u
unsigned int data = (unsigned int)val;
int err;
 
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where  0x01)
@@ -235,7 +235,7 @@ static int
 write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val)
 {
int err;
-   if (bus == 0)
+   if (bus == NULL)
return -1;
 
if (where  0x03)

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/68] 0 - NULL, for arch/parisc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 smp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 04c7e1d..16fccbe 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -333,7 +333,7 @@ smp_call_function (void (*func) (void *i
 
if (retry) {
spin_lock (lock);
-   while (smp_call_function_data != 0)
+   while (smp_call_function_data != NULL)
barrier();
}
else {

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/68] 0 - NULL, for arch/ppc

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 8xx_io/commproc.c  |2 +-
 kernel/pci.c   |6 +++---
 mm/init.c  |4 ++--
 mm/mmu_decl.h  |2 +-
 mm/pgtable.c   |4 ++--
 mm/tlb.c   |   12 ++--
 syslib/btext.c |4 ++--
 syslib/open_pic.c  |   14 +++---
 syslib/open_pic2.c |   14 +++---
 xmon/xmon.c|4 ++--
 10 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
index 7088428..e1e0084 100644
--- a/arch/ppc/8xx_io/commproc.c
+++ b/arch/ppc/8xx_io/commproc.c
@@ -293,7 +293,7 @@ cpm_install_handler(int cpm_vec, void (*
return;
}
 
-   if (cpm_vecs[cpm_vec].handler != 0)
+   if (cpm_vecs[cpm_vec].handler != NULL)
printk(KERN_INFO CPM interrupt %x replacing %x\n,
(uint)handler, (uint)cpm_vecs[cpm_vec].handler);
cpm_vecs[cpm_vec].handler = handler;
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index c2ec13b..124b0a2 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -880,7 +880,7 @@ static struct resource *__pci_mmap_make_
unsigned long io_offset = 0;
int i, res_bit;
 
-   if (hose == 0)
+   if (hose == NULL)
return NULL;/* should never happen */
 
/* If memory, add on the PCI bridge address offset */
@@ -1261,9 +1261,9 @@ fake_pci_bus(struct pci_controller *hose
 {
static struct pci_bus bus;
 
-   if (hose == 0) {
+   if (hose == NULL) {
hose = pci_bus_to_hose(busnr);
-   if (hose == 0)
+   if (hose == NULL)
printk(KERN_ERR Can't find hose for PCI bus %d!\n, 
busnr);
}
bus.number = busnr;
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
index 390dd19..a805f94 100644
--- a/arch/ppc/mm/init.c
+++ b/arch/ppc/mm/init.c
@@ -197,7 +197,7 @@ void MMU_setup(void)
char *p, *q;
unsigned long maxmem = 0;
 
-   for (q = cmd_line; (p = strstr(q, mem=)) != 0; ) {
+   for (q = cmd_line; (p = strstr(q, mem=)) != NULL; ) {
q = p + 4;
if (p  cmd_line  p[-1] != ' ')
continue;
@@ -575,7 +575,7 @@ #endif
 
 #ifdef CONFIG_PPC_STD_MMU
/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */
-   if (Hash != 0  pte_young(pte)) {
+   if (Hash != NULL  pte_young(pte)) {
struct mm_struct *mm;
pmd_t *pmd;
 
diff --git a/arch/ppc/mm/mmu_decl.h b/arch/ppc/mm/mmu_decl.h
index 540f329..0ff8967 100644
--- a/arch/ppc/mm/mmu_decl.h
+++ b/arch/ppc/mm/mmu_decl.h
@@ -76,7 +76,7 @@ extern unsigned long mmu_mapin_ram(void)
 static inline void flush_HPTE(unsigned context, unsigned long va,
  unsigned long pdval)
 {
-   if ((Hash != 0) 
+   if ((Hash != NULL) 
cpu_has_feature(CPU_FTR_HPTE_TABLE))
flush_hash_pages(0, va, pdval, 1);
else
diff --git a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
index 35ebb63..1ce8c56 100644
--- a/arch/ppc/mm/pgtable.c
+++ b/arch/ppc/mm/pgtable.c
@@ -219,7 +219,7 @@ __ioremap(phys_addr_t addr, unsigned lon
if (mem_init_done) {
struct vm_struct *area;
area = get_vm_area(size, VM_IOREMAP);
-   if (area == 0)
+   if (area == NULL)
return NULL;
v = (unsigned long) area-addr;
} else {
@@ -283,7 +283,7 @@ map_page(unsigned long va, phys_addr_t p
pd = pmd_offset(pgd_offset_k(va), va);
/* Use middle 10 bits of VA to index the second-level map */
pg = pte_alloc_kernel(pd, va);
-   if (pg != 0) {
+   if (pg != NULL) {
err = 0;
set_pte_at(init_mm, va, pg, pfn_pte(pa  PAGE_SHIFT, 
__pgprot(flags)));
if (mem_init_done)
diff --git a/arch/ppc/mm/tlb.c b/arch/ppc/mm/tlb.c
index 4ff260b..d4b68bd 100644
--- a/arch/ppc/mm/tlb.c
+++ b/arch/ppc/mm/tlb.c
@@ -40,7 +40,7 @@ void flush_hash_entry(struct mm_struct *
 {
unsigned long ptephys;
 
-   if (Hash != 0) {
+   if (Hash != NULL) {
ptephys = __pa(ptep)  PAGE_MASK;
flush_hash_pages(mm-context.id, addr, ptephys, 1);
}
@@ -52,7 +52,7 @@ void flush_hash_entry(struct mm_struct *
  */
 void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr)
 {
-   if (Hash != 0)
+   if (Hash != NULL)
return;
_tlbie(addr);
 }
@@ -63,7 +63,7 @@ void flush_tlb_page_nohash(struct vm_are
  */
 void

[PATCH 15/68] 0 - NULL, for arch/sh64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 ioremap.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sh64/mm/ioremap.c b/arch/sh64/mm/ioremap.c
index 9908577..b335849 100644
--- a/arch/sh64/mm/ioremap.c
+++ b/arch/sh64/mm/ioremap.c
@@ -167,7 +167,7 @@ static unsigned long shmedia_alloc_io(un
 
 if (name == NULL) name = ???;
 
-if ((xres = xres_alloc()) != 0) {
+if ((xres = xres_alloc()) != NULL) {
 tack = xres-xname;
 res = xres-xres;
 } else {
@@ -364,7 +364,7 @@ ioremap_proc_info(char *buf, char **star
for (r = ((struct resource *)data)-child; r != NULL; r = r-sibling) {
if (p + 32 = e)/* Better than nothing */
break;
-   if ((nm = r-name) == 0) nm = ???;
+   if ((nm = r-name) == NULL) nm = ???;
p += sprintf(p, %08lx-%08lx: %s\n,
 (unsigned long)r-start,
 (unsigned long)r-end, nm);

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 17/68] 0 - NULL, for arch/sparc64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/prom.c |2 +-
 prom/tree.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index f4e0a9a..35d4eb5 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -38,7 +38,7 @@ struct device_node *of_find_node_by_phan
 {
struct device_node *np;
 
-   for (np = allnodes; np != 0; np = np-allnext)
+   for (np = allnodes; np != NULL; np = np-allnext)
if (np-node == handle)
break;
 
diff --git a/arch/sparc64/prom/tree.c b/arch/sparc64/prom/tree.c
index b2c5b12..33eacd0 100644
--- a/arch/sparc64/prom/tree.c
+++ b/arch/sparc64/prom/tree.c
@@ -264,7 +264,7 @@ prom_setprop(int node, const char *pname
 {
if (size == 0)
return 0;
-   if ((pname == 0) || (value == 0))
+   if ((pname == NULL) || (value == NULL))
return 0;

 #ifdef CONFIG_SUN_LDOMS

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19/68] 0 - NULL, for arch/x86_64

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 numa.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 6da2355..97e8ac7 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -166,7 +166,7 @@ early_node_mem(int nodeid, unsigned long
return __va(mem);
ptr = __alloc_bootmem_nopanic(size,
SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS));
-   if (ptr == 0) {
+   if (ptr == NULL) {
printk(KERN_ERR Cannot find %lu bytes in node %d\n,
size, nodeid);
return NULL;

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 20/68] 0 - NULL, for arch/xtensa

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 kernel/pci.c   |2 +-
 kernel/traps.c |2 +-
 platform-iss/console.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 77deae5..1102816 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -306,7 +306,7 @@ __pci_mmap_make_offset(struct pci_dev *d
unsigned long io_offset = 0;
int i, res_bit;
 
-   if (pci_ctrl == 0)
+   if (pci_ctrl == NULL)
return -EINVAL; /* should never happen */
 
/* If memory, add on the PCI bridge address offset */
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index c5e62f9..eb21c7c 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -419,7 +419,7 @@ void show_stack(struct task_struct *task
int i = 0;
unsigned long *stack;
 
-   if (sp == 0)
+   if (sp == NULL)
__asm__ __volatile__ (mov %0, a1\n : =a(sp));
 
stack = sp;
diff --git a/arch/xtensa/platform-iss/console.c 
b/arch/xtensa/platform-iss/console.c
index 2f4f20f..ad8d65e 100644
--- a/arch/xtensa/platform-iss/console.c
+++ b/arch/xtensa/platform-iss/console.c
@@ -265,7 +265,7 @@ static void iss_console_write(struct con
 {
int len = strlen(s);
 
-   if (s != 0  *s != 0)
+   if (s != NULL  *s != 0)
__simc (SYS_write, 1, (unsigned long)s,
count  len ? count : len,0,0);
 }

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 18/68] 0 - NULL, for arch/um

2007-07-27 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

  E !=
- 0
+ NULL

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---

 sys-i386/fault.c   |2 +-
 sys-x86_64/fault.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/sys-i386/fault.c b/arch/um/sys-i386/fault.c
index 745b4fd..8004023 100644
--- a/arch/um/sys-i386/fault.c
+++ b/arch/um/sys-i386/fault.c
@@ -20,7 +20,7 @@ int arch_fixup(unsigned long address, un
const struct exception_table_entry *fixup;
 
fixup = search_exception_tables(address);
-   if(fixup != 0){
+   if(fixup != NULL){
UPT_IP(regs) = fixup-fixup;
return(1);
}
diff --git a/arch/um/sys-x86_64/fault.c b/arch/um/sys-x86_64/fault.c
index 4636b14..67d4a19 100644
--- a/arch/um/sys-x86_64/fault.c
+++ b/arch/um/sys-x86_64/fault.c
@@ -19,7 +19,7 @@ int arch_fixup(unsigned long address, un
const struct exception_table_entry *fixup;
 
fixup = search_exception_tables(address);
-   if(fixup != 0){
+   if(fixup != NULL){
UPT_IP(regs) = fixup-fixup;
return(1);
}

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 06/68] 0 - NULL, for arch/frv

2007-07-27 Thread Yoann Padioleau
David Howells [EMAIL PROTECTED] writes:

 Yoann Padioleau [EMAIL PROTECTED] wrote:

 When comparing a pointer, it's clearer to compare it to NULL than to 0.

 Can you make them of style:

   if (!x)

Yes I can. I can make another semantic patch later to do that
transformation. But some people may prefer (x == NULL) to (!x)
so I don't know. I think that transformation 
some 0 to NULL is less controversial.



 instead?

 Thanks,
 David

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 18/68] 0 - NULL, for arch/um

2007-07-27 Thread Yoann Padioleau
Jeff Dike [EMAIL PROTECTED] writes:

 On Fri, Jul 27, 2007 at 11:45:56AM +0200, Yoann Padioleau wrote:
 When comparing a pointer, it's clearer to compare it to NULL than to 0.

 ACK

  sys-i386/fault.c   |2 +-
  sys-x86_64/fault.c |2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

 Except you should probably diff from the top of the kernel tree.

Sorry. I will use diffstat -p1  from now on.


   Jeff

 -- 
 Work email - jdike at linux dot intel dot com

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] 0 -> NULL, drivers/usb/gadget/

2007-07-23 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

- 0
+ NULL
  == E

@@
expression *E;
@@

  E !=
- 0
+ NULL

@@
expression *E;
@@

- 0
+ NULL
  != E


PS: I have performed the same transformation on the whole kernel
and it affects around 300 files. I will send the remaining patches
if you are interested in.


Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]> 

 config.c  |2 +-
 ether.c   |2 +-
 goku_udc.c|2 +-
 inode.c   |2 +-
 lh7a40x_udc.c |2 +-
 m66592-udc.c  |2 +-
 net2280.c |8 
 pxa2xx_udc.c  |4 ++--
 pxa2xx_udc.h  |2 +-
 s3c2410_udc.c |2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index d18901b..c6760ae 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -50,7 +50,7 @@ usb_descriptor_fillbuf(void *buf, unsign
return -EINVAL;
 
/* fill buffer from src[] until null descriptor ptr */
-   for (; 0 != *src; src++) {
+   for (; NULL != *src; src++) {
unsignedlen = (*src)->bLength;
 
if (len > buflen)
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index dbaf867..2005b74 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1719,7 +1719,7 @@ rx_submit (struct eth_dev *dev, struct u
size += sizeof (struct rndis_packet_msg_type);
size -= size % dev->out_ep->maxpacket;
 
-   if ((skb = alloc_skb (size + NET_IP_ALIGN, gfp_flags)) == 0) {
+   if ((skb = alloc_skb (size + NET_IP_ALIGN, gfp_flags)) == NULL) {
DEBUG (dev, "no rx skb\n");
goto enomem;
}
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 349b816..55fb650 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -776,7 +776,7 @@ #endif
 
} /* else pio or dma irq handler advances the queue. */
 
-   if (likely(req != 0))
+   if (likely(req != NULL))
list_add_tail(>queue, >queue);
 
if (likely(!list_empty(>queue))
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index e60745f..dcad83b 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1394,7 +1394,7 @@ gadgetfs_setup (struct usb_gadget *gadge
dev->setup_abort = 0;
if (dev->state == STATE_DEV_UNCONNECTED) {
 #ifdef CONFIG_USB_GADGET_DUALSPEED
-   if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == 0) {
+   if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == NULL) {
spin_unlock(>lock);
ERROR (dev, "no high speed config??\n");
return -EINVAL;
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index e78c2dd..49ceb1b 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -1202,7 +1202,7 @@ static int lh7a40x_queue(struct usb_ep *
}
 
/* pio or dma irq handler advances the queue. */
-   if (likely(req != 0))
+   if (likely(req != NULL))
list_add_tail(>queue, >queue);
 
spin_unlock_irqrestore(>lock, flags);
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 0174a32..6e8d5d9 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1278,7 +1278,7 @@ static int m66592_queue(struct usb_ep *_
req->req.actual = 0;
req->req.status = -EINPROGRESS;
 
-   if (ep->desc == 0)  /* control */
+   if (ep->desc == NULL)   /* control */
start_ep0(ep, req);
else {
if (request && !ep->busy)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index c3d364e..aa53a50 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2120,7 +2120,7 @@ #endif
return;
 
/* manual DMA queue advance after short OUT */
-   if (likely (ep->dma != 0)) {
+   if (likely (ep->dma != NULL)) {
if (t & (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)) {
u32 count;
int stopped = ep->stopped;
@@ -2380,7 +2380,7 @@ #define   w_lengthle16_to_cpu(u.r.wLength
/* hw handles device and interface status */
if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT))
goto delegate;
-   if ((e = get_ep_by_addr (dev, w_index)) == 0
+   if ((e = get_ep_by_addr (dev, w_index)) == NULL
   

Re: [PATCH] dev->priv to netdev_priv(dev), drivers/net/tokenring/

2007-07-23 Thread Yoann Padioleau
Jan Engelhardt <[EMAIL PROTECTED]> writes:

> On Jul 23 2007 15:18, Yoann Padioleau wrote:
>>
>>Here is an excerpt of the semantic patch that performs the transformation
>>
>>@@
>>
>>- (T*) dev->priv
>>+ netdev_priv(dev)
>
> Note that dev->priv is a void*, and hence does not need casting.
> So dev->priv may also appear without one.

Yes you are right. I have shown only an excerpt of the semantic patch.
Sorry. There is another rule:

@ rule3 depends on rule1 && !rule1bis @
struct net_device *dev;
@@

- dev->priv
+ netdev_priv(dev)


If you look at my patch there is one such case

-   struct tok_info *ti = dev->priv;
+   struct tok_info *ti = netdev_priv(dev);



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dev->priv to netdev_priv(dev), drivers/net/tokenring/

2007-07-23 Thread Yoann Padioleau

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 <[EMAIL PROTECTED]> 


 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(-)

diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 9f1b6ab..a8573da 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -156,7 +156,7 @@ static void print_rx_state(struct net_de
 static void print_tx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_tx_desc *txd ; 
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
int i ; 
@@ -179,7 +179,7 @@ static void print_tx_state(struct net_de
 static void print_rx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_rx_desc *rxd ; 
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
int i ; 
@@ -213,7 +213,7 @@ #endif
 
 static u16 xl_ee_read(struct net_device *dev, int ee_addr)
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -245,7 +245,7 @@ static u16 xl_ee_read(struct net_device 
 
 static void  xl_ee_write(struct net_device *dev, int ee_addr, u16 ee_value) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -305,11 +305,11 @@ static int __devinit xl_probe(struct pci
pci_release_regions(pdev) ; 
return -ENOMEM ; 
} 
-   xl_priv = dev->priv ; 
+   xl_priv = netdev_priv(dev) ; 
 
 #if XL_DEBUG  
printk("pci_device: %p, dev:%p, dev->priv: %p, ba[0]: %10x, 
ba[1]:%10x\n", 
-   pdev, dev, dev->priv, (unsigned int)pdev->resource[0].start, 
(unsigned int)pdev->resource[1].start) ;  
+   pdev, dev, netdev_priv(dev), (unsigned 
int)pdev->resource[0].start, (unsigned int)pdev->resource[1].start) ;  
 #endif 
 
dev->irq=pdev->irq;
@@ -365,7 +365,7 @@ #endif 
 
 static int __devinit xl_init(struct net_device *dev) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
 
printk(KERN_INFO "%s \n", version);
printk(KERN_INFO "%s: I/O at %hx, MMIO at %p, using irq %d\n",
@@ -385,7 +385,7 @@ static int __devinit xl_init(struct net_
 
 static int xl_hw_reset(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev->priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
unsigned long t ; 
u16 i ; 
@@ -568,7 +568,7 @@ #endif
 
 static int xl_open(struct net_device *dev) 
 {
-   struct xl_private *xl_priv=(struct xl_private *)dev->priv;
+   struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 
u8 i ; 
u16 hwaddr[3] ; /* Should be u8[6] but we get word return values */
@@ -726,7 +726,7 @@ static int xl_open(struct net_device *de
 
 static int xl_open_hw(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv=(struct xl_p

[PATCH] dev-priv to netdev_priv(dev), drivers/net/tokenring/

2007-07-23 Thread Yoann Padioleau

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 [EMAIL PROTECTED] 


 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(-)

diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 9f1b6ab..a8573da 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -156,7 +156,7 @@ static void print_rx_state(struct net_de
 static void print_tx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_tx_desc *txd ; 
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
int i ; 
@@ -179,7 +179,7 @@ static void print_tx_state(struct net_de
 static void print_rx_state(struct net_device *dev)
 {
 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ; 
+   struct xl_private *xl_priv = netdev_priv(dev) ; 
struct xl_rx_desc *rxd ; 
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
int i ; 
@@ -213,7 +213,7 @@ #endif
 
 static u16 xl_ee_read(struct net_device *dev, int ee_addr)
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -245,7 +245,7 @@ static u16 xl_ee_read(struct net_device 
 
 static void  xl_ee_write(struct net_device *dev, int ee_addr, u16 ee_value) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
 
/* Wait for EEProm to not be busy */
@@ -305,11 +305,11 @@ static int __devinit xl_probe(struct pci
pci_release_regions(pdev) ; 
return -ENOMEM ; 
} 
-   xl_priv = dev-priv ; 
+   xl_priv = netdev_priv(dev) ; 
 
 #if XL_DEBUG  
printk(pci_device: %p, dev:%p, dev-priv: %p, ba[0]: %10x, 
ba[1]:%10x\n, 
-   pdev, dev, dev-priv, (unsigned int)pdev-resource[0].start, 
(unsigned int)pdev-resource[1].start) ;  
+   pdev, dev, netdev_priv(dev), (unsigned 
int)pdev-resource[0].start, (unsigned int)pdev-resource[1].start) ;  
 #endif 
 
dev-irq=pdev-irq;
@@ -365,7 +365,7 @@ #endif 
 
 static int __devinit xl_init(struct net_device *dev) 
 {
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
 
printk(KERN_INFO %s \n, version);
printk(KERN_INFO %s: I/O at %hx, MMIO at %p, using irq %d\n,
@@ -385,7 +385,7 @@ static int __devinit xl_init(struct net_
 
 static int xl_hw_reset(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv = (struct xl_private *)dev-priv ;
+   struct xl_private *xl_priv = netdev_priv(dev) ;
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
unsigned long t ; 
u16 i ; 
@@ -568,7 +568,7 @@ #endif
 
 static int xl_open(struct net_device *dev) 
 {
-   struct xl_private *xl_priv=(struct xl_private *)dev-priv;
+   struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
u8 i ; 
u16 hwaddr[3] ; /* Should be u8[6] but we get word return values */
@@ -726,7 +726,7 @@ static int xl_open(struct net_device *de
 
 static int xl_open_hw(struct net_device *dev) 
 { 
-   struct xl_private *xl_priv=(struct xl_private *)dev-priv;
+   struct xl_private *xl_priv=netdev_priv(dev);
u8 __iomem *xl_mmio = xl_priv-xl_mmio ; 
u16 vsoff ;
char ver_str[33

Re: [PATCH] dev-priv to netdev_priv(dev), drivers/net/tokenring/

2007-07-23 Thread Yoann Padioleau
Jan Engelhardt [EMAIL PROTECTED] writes:

 On Jul 23 2007 15:18, Yoann Padioleau wrote:

Here is an excerpt of the semantic patch that performs the transformation

@@

- (T*) dev-priv
+ netdev_priv(dev)

 Note that dev-priv is a void*, and hence does not need casting.
 So dev-priv may also appear without one.

Yes you are right. I have shown only an excerpt of the semantic patch.
Sorry. There is another rule:

@ rule3 depends on rule1  !rule1bis @
struct net_device *dev;
@@

- dev-priv
+ netdev_priv(dev)


If you look at my patch there is one such case

-   struct tok_info *ti = dev-priv;
+   struct tok_info *ti = netdev_priv(dev);



-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] 0 - NULL, drivers/usb/gadget/

2007-07-23 Thread Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is the semantic patch: 

@@
expression *E;
@@

  E ==
- 0
+ NULL

@@
expression *E;
@@

- 0
+ NULL
  == E

@@
expression *E;
@@

  E !=
- 0
+ NULL

@@
expression *E;
@@

- 0
+ NULL
  != E


PS: I have performed the same transformation on the whole kernel
and it affects around 300 files. I will send the remaining patches
if you are interested in.


Signed-off-by: Yoann Padioleau [EMAIL PROTECTED] 

 config.c  |2 +-
 ether.c   |2 +-
 goku_udc.c|2 +-
 inode.c   |2 +-
 lh7a40x_udc.c |2 +-
 m66592-udc.c  |2 +-
 net2280.c |8 
 pxa2xx_udc.c  |4 ++--
 pxa2xx_udc.h  |2 +-
 s3c2410_udc.c |2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index d18901b..c6760ae 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -50,7 +50,7 @@ usb_descriptor_fillbuf(void *buf, unsign
return -EINVAL;
 
/* fill buffer from src[] until null descriptor ptr */
-   for (; 0 != *src; src++) {
+   for (; NULL != *src; src++) {
unsignedlen = (*src)-bLength;
 
if (len  buflen)
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index dbaf867..2005b74 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1719,7 +1719,7 @@ rx_submit (struct eth_dev *dev, struct u
size += sizeof (struct rndis_packet_msg_type);
size -= size % dev-out_ep-maxpacket;
 
-   if ((skb = alloc_skb (size + NET_IP_ALIGN, gfp_flags)) == 0) {
+   if ((skb = alloc_skb (size + NET_IP_ALIGN, gfp_flags)) == NULL) {
DEBUG (dev, no rx skb\n);
goto enomem;
}
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 349b816..55fb650 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -776,7 +776,7 @@ #endif
 
} /* else pio or dma irq handler advances the queue. */
 
-   if (likely(req != 0))
+   if (likely(req != NULL))
list_add_tail(req-queue, ep-queue);
 
if (likely(!list_empty(ep-queue))
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index e60745f..dcad83b 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1394,7 +1394,7 @@ gadgetfs_setup (struct usb_gadget *gadge
dev-setup_abort = 0;
if (dev-state == STATE_DEV_UNCONNECTED) {
 #ifdef CONFIG_USB_GADGET_DUALSPEED
-   if (gadget-speed == USB_SPEED_HIGH  dev-hs_config == 0) {
+   if (gadget-speed == USB_SPEED_HIGH  dev-hs_config == NULL) {
spin_unlock(dev-lock);
ERROR (dev, no high speed config??\n);
return -EINVAL;
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index e78c2dd..49ceb1b 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -1202,7 +1202,7 @@ static int lh7a40x_queue(struct usb_ep *
}
 
/* pio or dma irq handler advances the queue. */
-   if (likely(req != 0))
+   if (likely(req != NULL))
list_add_tail(req-queue, ep-queue);
 
spin_unlock_irqrestore(dev-lock, flags);
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 0174a32..6e8d5d9 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1278,7 +1278,7 @@ static int m66592_queue(struct usb_ep *_
req-req.actual = 0;
req-req.status = -EINPROGRESS;
 
-   if (ep-desc == 0)  /* control */
+   if (ep-desc == NULL)   /* control */
start_ep0(ep, req);
else {
if (request  !ep-busy)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index c3d364e..aa53a50 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2120,7 +2120,7 @@ #endif
return;
 
/* manual DMA queue advance after short OUT */
-   if (likely (ep-dma != 0)) {
+   if (likely (ep-dma != NULL)) {
if (t  (1  SHORT_PACKET_TRANSFERRED_INTERRUPT)) {
u32 count;
int stopped = ep-stopped;
@@ -2380,7 +2380,7 @@ #define   w_lengthle16_to_cpu(u.r.wLength
/* hw handles device and interface status */
if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT))
goto delegate;
-   if ((e = get_ep_by_addr (dev, w_index)) == 0
+   if ((e = get_ep_by_addr (dev, w_index)) == NULL
|| w_length  2)
goto do_stall;
 
@@ -2408,7 +2408,7 @@ #define   w_length

[PATCH] potential parse error, drivers/serial/dz.h

2007-07-16 Thread Yoann Padioleau

potential parse error in declaration under a #ifdef.

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]> 


diff --git a/drivers/serial/dz.h b/drivers/serial/dz.h
index 9674d4e..9141c37 100644
--- a/drivers/serial/dz.h
+++ b/drivers/serial/dz.h
@@ -125,8 +125,8 @@ #define DZ_XMIT_SIZE   4096 
 #define DZ_WAKEUP_CHARS   DZ_XMIT_SIZE/4
 
 #ifdef MODULE
-int init_module (void)
-void cleanup_module (void)
+int init_module (void);
+void cleanup_module (void);
 #endif
 
 #endif /* DZ_SERIAL_H */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential parse error, drivers/i2c/busses/i2c-pmcmsp.c

2007-07-16 Thread Yoann Padioleau

potential parse error in initializer.


Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]> 

diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index 03188d2..17cecf1 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -630,7 +630,7 @@ static struct i2c_adapter pmcmsptwi_adap
 static struct platform_driver pmcmsptwi_driver = {
.probe  = pmcmsptwi_probe,
.remove = __devexit_p(pmcmsptwi_remove),
-   .driver {
+   .driver = {
.name   = DRV_NAME,
.owner  = THIS_MODULE,
},

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential parse error, drivers/i2c/busses/i2c-pmcmsp.c

2007-07-16 Thread Yoann Padioleau

potential parse error in initializer.


Signed-off-by: Yoann Padioleau [EMAIL PROTECTED] 

diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index 03188d2..17cecf1 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -630,7 +630,7 @@ static struct i2c_adapter pmcmsptwi_adap
 static struct platform_driver pmcmsptwi_driver = {
.probe  = pmcmsptwi_probe,
.remove = __devexit_p(pmcmsptwi_remove),
-   .driver {
+   .driver = {
.name   = DRV_NAME,
.owner  = THIS_MODULE,
},

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential parse error, drivers/serial/dz.h

2007-07-16 Thread Yoann Padioleau

potential parse error in declaration under a #ifdef.

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED] 


diff --git a/drivers/serial/dz.h b/drivers/serial/dz.h
index 9674d4e..9141c37 100644
--- a/drivers/serial/dz.h
+++ b/drivers/serial/dz.h
@@ -125,8 +125,8 @@ #define DZ_XMIT_SIZE   4096 
 #define DZ_WAKEUP_CHARS   DZ_XMIT_SIZE/4
 
 #ifdef MODULE
-int init_module (void)
-void cleanup_module (void)
+int init_module (void);
+void cleanup_module (void);
 #endif
 
 #endif /* DZ_SERIAL_H */

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential parse error

2007-07-13 Thread Yoann Padioleau

parse error in ifdef or bad use of macro.


Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]> 

 drivers/media/dvb/ttpci/av7110.c  |2 +-
 sound/aoa/codecs/snd-aoa-codec-onyx.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index ef1108c..0b4c6d6 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -2258,7 +2258,7 @@ static int frontend_init(struct av7110 *
FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_master_cmd, 
av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_burst, 
av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
FE_FUNC_OVERRIDE(av7110->fe->ops.set_tone, av7110->fe_set_tone, 
av7110_fe_set_tone);
-   FE_FUNC_OVERRIDE(av7110->fe->ops.set_voltage, 
av7110->fe_set_voltage, av7110_fe_set_voltage;)
+   FE_FUNC_OVERRIDE(av7110->fe->ops.set_voltage, 
av7110->fe_set_voltage, av7110_fe_set_voltage);

FE_FUNC_OVERRIDE(av7110->fe->ops.dishnetwork_send_legacy_command, 
av7110->fe_dishnetwork_send_legacy_command, 
av7110_fe_dishnetwork_send_legacy_command);
FE_FUNC_OVERRIDE(av7110->fe->ops.set_frontend, 
av7110->fe_set_frontend, av7110_fe_set_frontend);
 
diff --git a/sound/aoa/codecs/snd-aoa-codec-onyx.c 
b/sound/aoa/codecs/snd-aoa-codec-onyx.c
index ded5167..2a909a6 100644
--- a/sound/aoa/codecs/snd-aoa-codec-onyx.c
+++ b/sound/aoa/codecs/snd-aoa-codec-onyx.c
@@ -713,7 +713,7 @@ #ifdef SNDRV_PCM_FMTBIT_COMPRESSED_16BE
if (substream->runtime->format == SNDRV_PCM_FMTBIT_COMPRESSED_16BE) {
/* mute and lock analog output */
onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, );
-   if (onyx_write_register(onyx
+   if (onyx_write_register(onyx,
ONYX_REG_DAC_CONTROL,
v | ONYX_MUTE_RIGHT | ONYX_MUTE_LEFT))
goto out_unlock;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential parse error

2007-07-13 Thread Yoann Padioleau

parse error in ifdef or bad use of macro.


Signed-off-by: Yoann Padioleau [EMAIL PROTECTED] 

 drivers/media/dvb/ttpci/av7110.c  |2 +-
 sound/aoa/codecs/snd-aoa-codec-onyx.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index ef1108c..0b4c6d6 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -2258,7 +2258,7 @@ static int frontend_init(struct av7110 *
FE_FUNC_OVERRIDE(av7110-fe-ops.diseqc_send_master_cmd, 
av7110-fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
FE_FUNC_OVERRIDE(av7110-fe-ops.diseqc_send_burst, 
av7110-fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
FE_FUNC_OVERRIDE(av7110-fe-ops.set_tone, av7110-fe_set_tone, 
av7110_fe_set_tone);
-   FE_FUNC_OVERRIDE(av7110-fe-ops.set_voltage, 
av7110-fe_set_voltage, av7110_fe_set_voltage;)
+   FE_FUNC_OVERRIDE(av7110-fe-ops.set_voltage, 
av7110-fe_set_voltage, av7110_fe_set_voltage);

FE_FUNC_OVERRIDE(av7110-fe-ops.dishnetwork_send_legacy_command, 
av7110-fe_dishnetwork_send_legacy_command, 
av7110_fe_dishnetwork_send_legacy_command);
FE_FUNC_OVERRIDE(av7110-fe-ops.set_frontend, 
av7110-fe_set_frontend, av7110_fe_set_frontend);
 
diff --git a/sound/aoa/codecs/snd-aoa-codec-onyx.c 
b/sound/aoa/codecs/snd-aoa-codec-onyx.c
index ded5167..2a909a6 100644
--- a/sound/aoa/codecs/snd-aoa-codec-onyx.c
+++ b/sound/aoa/codecs/snd-aoa-codec-onyx.c
@@ -713,7 +713,7 @@ #ifdef SNDRV_PCM_FMTBIT_COMPRESSED_16BE
if (substream-runtime-format == SNDRV_PCM_FMTBIT_COMPRESSED_16BE) {
/* mute and lock analog output */
onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, v);
-   if (onyx_write_register(onyx
+   if (onyx_write_register(onyx,
ONYX_REG_DAC_CONTROL,
v | ONYX_MUTE_RIGHT | ONYX_MUTE_LEFT))
goto out_unlock;

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] some kmalloc/memset ->kzalloc (tree wide)

2007-07-07 Thread yoann padioleau


On 7 juil. 07, at 15:07, Tilman Schmidt wrote:


Am 06.07.2007 18:51 schrieb Yoann Padioleau:

@@
expression E1,E2,E3;
@@

- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)


This misses the semantic distinction between the first and second
arguments of kcalloc(). The first argument is supposed to be the
number of elements to allocate and the second their size. As a
consequence, the following hunks in your pathc are wrong:


Yes you are right. Andrew Morton fixed the problem in a
subsequent patch.

I should have written a more precise semantic patch such as

@@
expression E;
constant c;
type T;
@@

- kzalloc(sizeof(T) * c, E)
+ kcalloc(c, sizeof(T), E)


Note that sometimes the code is written as  kzalloc(c * sizeof(T), E)
as in   kzalloc(2 * sizeof(struct resource), GFP_KERNEL)  but
our transformation engine can handle the commutativity of '*' and still
performs the right transformation.




diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/ 
pci.c

index 9d63d7f..b84955f 100644
--- a/arch/arm/mach-iop13xx/pci.c
+++ b/arch/arm/mach-iop13xx/pci.c
@@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pci
if (nr > 1)
return 0;

-   res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+   res = kcalloc(sizeof(struct resource), 2, GFP_KERNEL);
if (!res)
panic("PCI: unable to alloc resources");

-   memset(res, 0, sizeof(struct resource) * 2);

/* 'nr' assumptions:
 * ATUX is always 0





-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] some kmalloc/memset -kzalloc (tree wide)

2007-07-07 Thread yoann padioleau


On 7 juil. 07, at 15:07, Tilman Schmidt wrote:


Am 06.07.2007 18:51 schrieb Yoann Padioleau:

@@
expression E1,E2,E3;
@@

- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)


This misses the semantic distinction between the first and second
arguments of kcalloc(). The first argument is supposed to be the
number of elements to allocate and the second their size. As a
consequence, the following hunks in your pathc are wrong:


Yes you are right. Andrew Morton fixed the problem in a
subsequent patch.

I should have written a more precise semantic patch such as

@@
expression E;
constant c;
type T;
@@

- kzalloc(sizeof(T) * c, E)
+ kcalloc(c, sizeof(T), E)


Note that sometimes the code is written as  kzalloc(c * sizeof(T), E)
as in   kzalloc(2 * sizeof(struct resource), GFP_KERNEL)  but
our transformation engine can handle the commutativity of '*' and still
performs the right transformation.




diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/ 
pci.c

index 9d63d7f..b84955f 100644
--- a/arch/arm/mach-iop13xx/pci.c
+++ b/arch/arm/mach-iop13xx/pci.c
@@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pci
if (nr  1)
return 0;

-   res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+   res = kcalloc(sizeof(struct resource), 2, GFP_KERNEL);
if (!res)
panic(PCI: unable to alloc resources);

-   memset(res, 0, sizeof(struct resource) * 2);

/* 'nr' assumptions:
 * ATUX is always 0





-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential compiler error, irqfunc caller sites update

2007-07-05 Thread Yoann Padioleau

In 7d12e780e003f93433d49ce78cfedf4b4c52adc5 David Howells performed
this evolution: 
 "IRQ: Maintain regs pointer globally rather than passing to IRQ handlers"

He correctly updated many of the function definitions that were using
this extra regs pointer parameter but forgot to update some caller
sites of those functions. The reason the modifications was not
properly done on all drivers is that some drivers were rarely compiled
because they are for AMIGA, or that some code sites were inside
#ifdefs where the option is not set or inside #if 0.

Here is the semantic patch that found the occurences 
and fixed the problem.

@ rule1 @
identifier fn;
identifier irq, dev_id;
typedef irqreturn_t;
@@

static irqreturn_t fn(int irq, void *dev_id) 
{
   ...
}

@@
identifier rule1.fn;
expression E1, E2, E3;
@@

 fn(E1, E2
-   ,E3
   )

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]> 



diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 7f6d02c..38b688f 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1654,7 +1654,7 @@ static void fs_poll (unsigned long data)
 {
struct fs_dev *dev = (struct fs_dev *) data;
   
-   fs_irq (0, dev, NULL);
+   fs_irq (0, dev);
dev->timer.expires = jiffies + FS_POLL_FREQ;
add_timer (>timer);
 }
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 8f0d7ce..2143eeb 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -634,7 +634,7 @@ static void am79c961_poll_controller(str
 {
unsigned long flags;
local_irq_save(flags);
-   am79c961_interrupt(dev->irq, dev, NULL);
+   am79c961_interrupt(dev->irq, dev);
local_irq_restore(flags);
 }
 #endif
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index 6683afc..d5f694f 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -222,7 +222,7 @@ #ifdef CONFIG_NET_POLL_CONTROLLER
 static void ixpdev_poll_controller(struct net_device *dev)
 {
disable_irq(IRQ_IXP2000_THDA0);
-   ixpdev_interrupt(IRQ_IXP2000_THDA0, dev, NULL);
+   ixpdev_interrupt(IRQ_IXP2000_THDA0, dev);
enable_irq(IRQ_IXP2000_THDA0);
 }
 #endif
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 132e214..e7fdcf1 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -1159,7 +1159,7 @@ static void sbmac_netpoll(struct net_dev
 
__raw_writeq(0, sc->sbm_imr);
 
-   sbmac_intr(irq, netdev, NULL);
+   sbmac_intr(irq, netdev);
 
 #ifdef CONFIG_SBMAC_COALESCE
__raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << 
S_MAC_TX_CH0) |
diff --git a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c
index 93b41f4..45097fb 100644
--- a/drivers/scsi/53c7xx.c
+++ b/drivers/scsi/53c7xx.c
@@ -5177,7 +5177,7 @@ #endif
 if (NCR53c7x0_read8(hostdata->istat) & (ISTAT_DIP|ISTAT_SIP)) {
printk ("scsi%d : dropped interrupt for command %ld\n", host->host_no,
cmd->pid);
-   NCR53c7x0_intr (host->irq, NULL, NULL);
+   NCR53c7x0_intr (host->irq, NULL);
return SCSI_ABORT_BUSY;
 }

diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 7025025..1a60f9c 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -336,7 +336,7 @@ static int uss720_irq(int usbstatus, voi
memcpy(priv->reg, buffer, 4);
/* if nAck interrupts are enabled and we have an interrupt, call the 
interrupt procedure */
if (priv->reg[2] & priv->reg[1] & 0x10)
-   parport_generic_irq(0, pp, NULL);
+   parport_generic_irq(0, pp);
return 1;
 }
 #endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential compiler error, irqfunc caller sites update

2007-07-05 Thread Yoann Padioleau

In 7d12e780e003f93433d49ce78cfedf4b4c52adc5 David Howells performed
this evolution: 
 IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

He correctly updated many of the function definitions that were using
this extra regs pointer parameter but forgot to update some caller
sites of those functions. The reason the modifications was not
properly done on all drivers is that some drivers were rarely compiled
because they are for AMIGA, or that some code sites were inside
#ifdefs where the option is not set or inside #if 0.

Here is the semantic patch that found the occurences 
and fixed the problem.

@ rule1 @
identifier fn;
identifier irq, dev_id;
typedef irqreturn_t;
@@

static irqreturn_t fn(int irq, void *dev_id) 
{
   ...
}

@@
identifier rule1.fn;
expression E1, E2, E3;
@@

 fn(E1, E2
-   ,E3
   )

Signed-off-by: Yoann Padioleau [EMAIL PROTECTED] 



diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 7f6d02c..38b688f 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1654,7 +1654,7 @@ static void fs_poll (unsigned long data)
 {
struct fs_dev *dev = (struct fs_dev *) data;
   
-   fs_irq (0, dev, NULL);
+   fs_irq (0, dev);
dev-timer.expires = jiffies + FS_POLL_FREQ;
add_timer (dev-timer);
 }
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 8f0d7ce..2143eeb 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -634,7 +634,7 @@ static void am79c961_poll_controller(str
 {
unsigned long flags;
local_irq_save(flags);
-   am79c961_interrupt(dev-irq, dev, NULL);
+   am79c961_interrupt(dev-irq, dev);
local_irq_restore(flags);
 }
 #endif
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index 6683afc..d5f694f 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -222,7 +222,7 @@ #ifdef CONFIG_NET_POLL_CONTROLLER
 static void ixpdev_poll_controller(struct net_device *dev)
 {
disable_irq(IRQ_IXP2000_THDA0);
-   ixpdev_interrupt(IRQ_IXP2000_THDA0, dev, NULL);
+   ixpdev_interrupt(IRQ_IXP2000_THDA0, dev);
enable_irq(IRQ_IXP2000_THDA0);
 }
 #endif
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 132e214..e7fdcf1 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -1159,7 +1159,7 @@ static void sbmac_netpoll(struct net_dev
 
__raw_writeq(0, sc-sbm_imr);
 
-   sbmac_intr(irq, netdev, NULL);
+   sbmac_intr(irq, netdev);
 
 #ifdef CONFIG_SBMAC_COALESCE
__raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER)  
S_MAC_TX_CH0) |
diff --git a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c
index 93b41f4..45097fb 100644
--- a/drivers/scsi/53c7xx.c
+++ b/drivers/scsi/53c7xx.c
@@ -5177,7 +5177,7 @@ #endif
 if (NCR53c7x0_read8(hostdata-istat)  (ISTAT_DIP|ISTAT_SIP)) {
printk (scsi%d : dropped interrupt for command %ld\n, host-host_no,
cmd-pid);
-   NCR53c7x0_intr (host-irq, NULL, NULL);
+   NCR53c7x0_intr (host-irq, NULL);
return SCSI_ABORT_BUSY;
 }

diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 7025025..1a60f9c 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -336,7 +336,7 @@ static int uss720_irq(int usbstatus, voi
memcpy(priv-reg, buffer, 4);
/* if nAck interrupts are enabled and we have an interrupt, call the 
interrupt procedure */
if (priv-reg[2]  priv-reg[1]  0x10)
-   parport_generic_irq(0, pp, NULL);
+   parport_generic_irq(0, pp);
return 1;
 }
 #endif

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [KJ] Re: [PATCH] bugfix GFP_KERNEL -> GFP_ATOMIC in spin_locked region

2007-06-05 Thread Yoann Padioleau
Oliver Neukum <[EMAIL PROTECTED]> writes:

> Am Dienstag, 5. Juni 2007 13:05 schrieb Yoann Padioleau:
>> Ok. Do you have a preference on the format ?  a : format  ?
>> 
>> Is there a place that gathered all those implicit programming rules 
>> (that copy_from_user must not be called inside a spinlock, etc) so that
>> I can translate them in a script for our tool.
>
> How much C does your tool understand? 

The tool understands almost all the C language but the analysis we do
for the moment are intra-procedural so when we look for 
 spin_lock();
 ...
 copy_from_user();

it can detect cases and code paths only when the two function calls
are in the same function. It could be extended but it would require to
do a full analysis of the kernel source. Maybe if some functions of
the library have an attribute in their prototype in the .h such as

 __might_sleep copy_from_user(); 

it could help.

> You might basically
> test for code paths that go to "might_sleep()"

Ok, thanks. If you know other implicit programming rules,
I would be glad to know them, or if you know places
where thus rules are written.


BTW at one point I think the Linux community were using advanced
static analysis tools such as the one made by Dawson Engler (now
Coverity). The communitty have stopped using such tools ? Isn't the
role of sparse to detect bugs such as the dangerous copy_from_user()
inside spinlocked region ?


>
>   Regards
>   Oliver
>
> ___
> Kernel-janitors mailing list
> [EMAIL PROTECTED]
> https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [KJ] Re: [PATCH] bugfix GFP_KERNEL -> GFP_ATOMIC in spin_locked region

2007-06-05 Thread Yoann Padioleau
Andrew Morton <[EMAIL PROTECTED]> writes:

>> 
>>  net/wan/lmc/lmc_main.c|2 +-
>>  scsi/megaraid/megaraid_mm.c   |2 +-
>>  usb/serial/io_ti.c|2 +-
>>  usb/serial/ti_usb_3410_5052.c |2 +-
>>  usb/serial/whiteheat.c|6 +++---
>>  5 files changed, 7 insertions(+), 7 deletions(-)
>
> This patch covers three areas of maintainer responsibility, so poor old me
> has to split it up and redo the changelogs.  Oh well.

Sorry. 

For modifications that crosscut the kernel it is not very practical to
look each time for the maintainer. We plan to send a patch that
replaces some calls to kmalloc/memset with kzalloc; do we have to split
it for each maintainer ?

>> diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
>> index ae132c1..750b3ef 100644
>> --- a/drivers/net/wan/lmc/lmc_main.c
>> +++ b/drivers/net/wan/lmc/lmc_main.c
>> @@ -483,7 +483,7 @@ #endif /* end ifdef _DBG_EVENTLOG */
>>  break;
>>  }
>>  
>> -data = kmalloc(xc.len, GFP_KERNEL);
>> +data = kmalloc(xc.len, GFP_ATOMIC);
>>  if(data == 0x0){
>>  printk(KERN_WARNING "%s: Failed to allocate 
>> memory for copy\n", dev->name);
>>  ret = -ENOMEM;
>
> A few lines later we do:
>
>   if(copy_from_user(data, xc.data, xc.len))
>
> which also is illegal under spinlock.

I have launched my tool to detect such situations and I get this 
(in a diff-like format).

--- /home/pad/kernels/git/linux-2.6/arch/cris/arch-v10/drivers/gpio.c   
2007-03-27 15:12:38.0 +0200
+++ /tmp/output.c   2007-06-05 11:38:47.0 +0200
@@ -776,7 +776,7 @@
/* bits set in *arg is set to input,
 * *arg updated with current input pins.
 */
-   if (copy_from_user(, (unsigned long*)arg, sizeof(val)))
{
ret = -EFAULT;
break;
@@ -789,7 +789,7 @@
/* bits set in *arg is set to output,
 * *arg updated with current output pins.
 */
-   if (copy_from_user(, (unsigned long*)arg, sizeof(val)))
{
ret = -EFAULT;
break;


--- /home/pad/kernels/git/linux-2.6/arch/mips/au1000/common/power.c 
2007-03-27 15:12:41.0 +0200
+++ /tmp/output.c   2007-06-05 11:38:57.0 +0200
@@ -330,7 +330,7 @@
spin_unlock_irqrestore(_lock, flags);
return -EFAULT;
}
-   if (copy_from_user(buf, buffer, *len)) {
spin_unlock_irqrestore(_lock, flags);
return -EFAULT;
}

and some cases in lmc_main.c


>
>
> Frankly, I think that a better use of this tool would be to just report on
> the errors, let humans fix them up.

Ok. Do you have a preference on the format ?  a : format  ?

Is there a place that gathered all those implicit programming rules 
(that copy_from_user must not be called inside a spinlock, etc) so that
I can translate them in a script for our tool.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [KJ] Re: [PATCH] bugfix GFP_KERNEL - GFP_ATOMIC in spin_locked region

2007-06-05 Thread Yoann Padioleau
Andrew Morton [EMAIL PROTECTED] writes:

 
  net/wan/lmc/lmc_main.c|2 +-
  scsi/megaraid/megaraid_mm.c   |2 +-
  usb/serial/io_ti.c|2 +-
  usb/serial/ti_usb_3410_5052.c |2 +-
  usb/serial/whiteheat.c|6 +++---
  5 files changed, 7 insertions(+), 7 deletions(-)

 This patch covers three areas of maintainer responsibility, so poor old me
 has to split it up and redo the changelogs.  Oh well.

Sorry. 

For modifications that crosscut the kernel it is not very practical to
look each time for the maintainer. We plan to send a patch that
replaces some calls to kmalloc/memset with kzalloc; do we have to split
it for each maintainer ?

 diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
 index ae132c1..750b3ef 100644
 --- a/drivers/net/wan/lmc/lmc_main.c
 +++ b/drivers/net/wan/lmc/lmc_main.c
 @@ -483,7 +483,7 @@ #endif /* end ifdef _DBG_EVENTLOG */
  break;
  }
  
 -data = kmalloc(xc.len, GFP_KERNEL);
 +data = kmalloc(xc.len, GFP_ATOMIC);
  if(data == 0x0){
  printk(KERN_WARNING %s: Failed to allocate 
 memory for copy\n, dev-name);
  ret = -ENOMEM;

 A few lines later we do:

   if(copy_from_user(data, xc.data, xc.len))

 which also is illegal under spinlock.

I have launched my tool to detect such situations and I get this 
(in a diff-like format).

--- /home/pad/kernels/git/linux-2.6/arch/cris/arch-v10/drivers/gpio.c   
2007-03-27 15:12:38.0 +0200
+++ /tmp/output.c   2007-06-05 11:38:47.0 +0200
@@ -776,7 +776,7 @@
/* bits set in *arg is set to input,
 * *arg updated with current input pins.
 */
-   if (copy_from_user(val, (unsigned long*)arg, sizeof(val)))
{
ret = -EFAULT;
break;
@@ -789,7 +789,7 @@
/* bits set in *arg is set to output,
 * *arg updated with current output pins.
 */
-   if (copy_from_user(val, (unsigned long*)arg, sizeof(val)))
{
ret = -EFAULT;
break;


--- /home/pad/kernels/git/linux-2.6/arch/mips/au1000/common/power.c 
2007-03-27 15:12:41.0 +0200
+++ /tmp/output.c   2007-06-05 11:38:57.0 +0200
@@ -330,7 +330,7 @@
spin_unlock_irqrestore(pm_lock, flags);
return -EFAULT;
}
-   if (copy_from_user(buf, buffer, *len)) {
spin_unlock_irqrestore(pm_lock, flags);
return -EFAULT;
}

and some cases in lmc_main.c




 Frankly, I think that a better use of this tool would be to just report on
 the errors, let humans fix them up.

Ok. Do you have a preference on the format ?  a file:line format  ?

Is there a place that gathered all those implicit programming rules 
(that copy_from_user must not be called inside a spinlock, etc) so that
I can translate them in a script for our tool.


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [KJ] Re: [PATCH] bugfix GFP_KERNEL - GFP_ATOMIC in spin_locked region

2007-06-05 Thread Yoann Padioleau
Oliver Neukum [EMAIL PROTECTED] writes:

 Am Dienstag, 5. Juni 2007 13:05 schrieb Yoann Padioleau:
 Ok. Do you have a preference on the format ?  a file:line format  ?
 
 Is there a place that gathered all those implicit programming rules 
 (that copy_from_user must not be called inside a spinlock, etc) so that
 I can translate them in a script for our tool.

 How much C does your tool understand? 

The tool understands almost all the C language but the analysis we do
for the moment are intra-procedural so when we look for 
 spin_lock();
 ...
 copy_from_user();

it can detect cases and code paths only when the two function calls
are in the same function. It could be extended but it would require to
do a full analysis of the kernel source. Maybe if some functions of
the library have an attribute in their prototype in the .h such as

 __might_sleep copy_from_user(); 

it could help.

 You might basically
 test for code paths that go to might_sleep()

Ok, thanks. If you know other implicit programming rules,
I would be glad to know them, or if you know places
where thus rules are written.


BTW at one point I think the Linux community were using advanced
static analysis tools such as the one made by Dawson Engler (now
Coverity). The communitty have stopped using such tools ? Isn't the
role of sparse to detect bugs such as the dangerous copy_from_user()
inside spinlocked region ?



   Regards
   Oliver

 ___
 Kernel-janitors mailing list
 [EMAIL PROTECTED]
 https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] old declaration ritchie style fix in arch/parisc/math-emu/

2007-06-04 Thread Yoann Padioleau

Use consistent function ANSI declaration style.

Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]> 





 dfadd.c   |   10 +-
 fmpyfadd.c|   30 ++
 fpudispatch.c |   22 ++
 3 files changed, 29 insertions(+), 33 deletions(-)


diff --git a/arch/parisc/math-emu/dfadd.c b/arch/parisc/math-emu/dfadd.c
index e147d7d..5a7d524 100644
--- a/arch/parisc/math-emu/dfadd.c
+++ b/arch/parisc/math-emu/dfadd.c
@@ -45,11 +45,11 @@ #include "dbl_float.h"
 /*
  * Double_add: add two double precision values.
  */
-dbl_fadd(
-dbl_floating_point *leftptr,
-dbl_floating_point *rightptr,
-dbl_floating_point *dstptr,
-unsigned int *status)
+int dbl_fadd(
+   dbl_floating_point *leftptr,
+   dbl_floating_point *rightptr,
+   dbl_floating_point *dstptr,
+   unsigned int *status)
 {
 register unsigned int signless_upper_left, signless_upper_right, save;
 register unsigned int leftp1, leftp2, rightp1, rightp2, extent;
diff --git a/arch/parisc/math-emu/fmpyfadd.c b/arch/parisc/math-emu/fmpyfadd.c
index 5dd7f93..c0a0f28 100644
--- a/arch/parisc/math-emu/fmpyfadd.c
+++ b/arch/parisc/math-emu/fmpyfadd.c
@@ -716,10 +716,12 @@ dbl_fmpyfadd(
  *  Double Floating-point Multiply Negate Fused Add
  */
 
-dbl_fmpynfadd(src1ptr,src2ptr,src3ptr,status,dstptr)
-
-dbl_floating_point *src1ptr, *src2ptr, *src3ptr, *dstptr;
-unsigned int *status;
+int dbl_fmpynfadd(
+   dbl_floating_point *src1ptr,
+   dbl_floating_point *src2ptr,
+   dbl_floating_point *src3ptr,
+   unsigned int *status,
+   dbl_floating_point *dstptr)
 {
unsigned int opnd1p1, opnd1p2, opnd2p1, opnd2p2, opnd3p1, opnd3p2;
register unsigned int tmpresp1, tmpresp2, tmpresp3, tmpresp4;
@@ -1374,10 +1376,12 @@ unsigned int *status;
  *  Single Floating-point Multiply Fused Add
  */
 
-sgl_fmpyfadd(src1ptr,src2ptr,src3ptr,status,dstptr)
-
-sgl_floating_point *src1ptr, *src2ptr, *src3ptr, *dstptr;
-unsigned int *status;
+int sgl_fmpyfadd(
+   sgl_floating_point *src1ptr,
+   sgl_floating_point *src2ptr,
+   sgl_floating_point *src3ptr,
+   unsigned int *status,
+   sgl_floating_point *dstptr)
 {
unsigned int opnd1, opnd2, opnd3;
register unsigned int tmpresp1, tmpresp2;
@@ -2015,10 +2019,12 @@ unsigned int *status;
  *  Single Floating-point Multiply Negate Fused Add
  */
 
-sgl_fmpynfadd(src1ptr,src2ptr,src3ptr,status,dstptr)
-
-sgl_floating_point *src1ptr, *src2ptr, *src3ptr, *dstptr;
-unsigned int *status;
+int sgl_fmpynfadd(
+   sgl_floating_point *src1ptr,
+   sgl_floating_point *src2ptr,
+   sgl_floating_point *src3ptr,
+   unsigned int *status,
+   sgl_floating_point *dstptr)
 {
unsigned int opnd1, opnd2, opnd3;
register unsigned int tmpresp1, tmpresp2;
diff --git a/arch/parisc/math-emu/fpudispatch.c 
b/arch/parisc/math-emu/fpudispatch.c
index 6e28f9f..f8fa3f9 100644
--- a/arch/parisc/math-emu/fpudispatch.c
+++ b/arch/parisc/math-emu/fpudispatch.c
@@ -701,9 +701,7 @@ decode_0c(u_int ir, u_int class, u_int s
 }
 
 static u_int
-decode_0e(ir,class,subop,fpregs)
-u_int ir,class,subop;
-u_int fpregs[];
+decode_0e(u_int ir, u_int class, u_int subop, u_int fpregs[])
 {
u_int r1,r2,t;  /* operand register offsets */
u_int fmt;  /* also sf for class 1 conversions */
@@ -1113,9 +,7 @@ u_int fpregs[];
  * routine to decode the 06 (FMPYADD and FMPYCFXT) instruction
  */
 static u_int
-decode_06(ir,fpregs)
-u_int ir;
-u_int fpregs[];
+decode_06(u_int ir,u_int fpregs[])
 {
u_int rm1, rm2, tm, ra, ta; /* operands */
u_int fmt;
@@ -1253,9 +1249,7 @@ u_int fpregs[];
  * routine to decode the 26 (FMPYSUB) instruction
  */
 static u_int
-decode_26(ir,fpregs)
-u_int ir;
-u_int fpregs[];
+decode_26(u_int ir,u_int fpregs[])
 {
u_int rm1, rm2, tm, ra, ta; /* operands */
u_int fmt;
@@ -1344,9 +1338,7 @@ u_int fpregs[];
  * routine to decode the 2E (FMPYFADD,FMPYNFADD) instructions
  */
 static u_int
-decode_2e(ir,fpregs)
-u_int ir;
-u_int fpregs[];
+decode_2e(u_int ir, u_int fpregs[])
 {
u_int rm1, rm2, ra, t; /* operands */
u_int fmt;
@@ -1410,10 +1402,8 @@ u_int fpregs[];
  * of FCMP is being emulated.
  */
 static void
-update_status_cbit(status, new_status, fpu_type, y_field)
-u_int *status, new_status;
-u_int fpu_type;
-u_int y_field;
+update_status_cbit(u_int *status, u_int new_status, u_int fpu_type, 
+  u_int y_field)
 {
/*
 * For PA89 FPU's which implement the Compare Queue and

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] potential parse error in ifdef part 3

2007-06-04 Thread Yoann Padioleau

parse errors in ifdefs

Fix various bits of obviously-busted code which we're not happening to
compile, due to ifdefs.


Signed-off-by: Yoann Padioleau <[EMAIL PROTECTED]> 

 arch/i386/math-emu/fpu_entry.c |2 +-
 arch/m68k/mac/debug.c  |2 +-
 arch/ppc/syslib/qspan_pci.c|4 ++--
 arch/sh64/kernel/pci_sh5.c |8 
 drivers/cdrom/mcdx.c   |2 +-
 drivers/tc/zs.c|2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)



diff --git a/arch/m68k/mac/debug.c b/arch/m68k/mac/debug.c
index 7a5bed5..e8a5713 100644
--- a/arch/m68k/mac/debug.c
+++ b/arch/m68k/mac/debug.c
@@ -71,7 +71,7 @@ #ifdef DEBUG_SCREEN
 
/* calculate current offset */
pengoffset = (unsigned char *)mac_videobase +
-   (150+line*2) * mac_rowbytes) + 80 * peng;
+   (150+line*2) * mac_rowbytes + 80 * peng;
 
pptr = pengoffset;
 
diff --git a/arch/ppc/syslib/qspan_pci.c b/arch/ppc/syslib/qspan_pci.c
index 85053b2..7a97c74 100644
--- a/arch/ppc/syslib/qspan_pci.c
+++ b/arch/ppc/syslib/qspan_pci.c
@@ -365,13 +365,13 @@ int qspan_pcibios_find_class(unsigned in
 }
 
 void __init
-m8xx_pcibios_fixup(void))
+m8xx_pcibios_fixup(void)
 {
/* Lots to do here, all board and configuration specific. */
 }
 
 void __init
-m8xx_setup_pci_ptrs(void))
+m8xx_setup_pci_ptrs(void)
 {
set_config_access_method(qspan);
 
diff --git a/arch/sh64/kernel/pci_sh5.c b/arch/sh64/kernel/pci_sh5.c
index fb51660..3334f99 100644
--- a/arch/sh64/kernel/pci_sh5.c
+++ b/arch/sh64/kernel/pci_sh5.c
@@ -521,10 +521,10 @@ #if 1
bus->resource[0]->start = PCIBIOS_MIN_IO;
bus->resource[1]->start = PCIBIOS_MIN_MEM;
 #else
-   bus->resource[0]->end = 0
-   bus->resource[1]->end = 0
-   bus->resource[0]->start =0
- bus->resource[1]->start = 0;
+   bus->resource[0]->end = 0;
+   bus->resource[1]->end = 0;
+   bus->resource[0]->start =0;
+   bus->resource[1]->start = 0;
 #endif
/* Turn off downstream PF memory address range by default */
bus->resource[2]->start = 1024*1024;
diff --git a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
index f574962..4310cc8 100644
--- a/drivers/cdrom/mcdx.c
+++ b/drivers/cdrom/mcdx.c
@@ -1053,11 +1053,11 @@ static void __exit mcdx_exit(void)
if (unregister_blkdev(MAJOR_NR, "mcdx") != 0) {
xwarn("cleanup() unregister_blkdev() failed\n");
}
-   blk_cleanup_queue(mcdx_queue);
 #if !MCDX_QUIET
else
xinfo("cleanup() succeeded\n");
 #endif
+   blk_cleanup_queue(mcdx_queue);
 }
 
 #ifdef MODULE
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index 3524e3f..61de78a 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -2182,7 +2182,7 @@ struct dec_serial_hook zs_kgdbhook = {
.init_info  = kgdbhook_init_info,
.rx_char= kgdbhook_rx_char,
.cflags = B38400 | CS8 | CLOCAL,
-}
+};
 
 void __init zs_kgdb_hook(int tty_num)
 {
diff --git a/arch/i386/math-emu/fpu_entry.c b/arch/i386/math-emu/fpu_entry.c
index ddf8fa3..1853524 100644
--- a/arch/i386/math-emu/fpu_entry.c
+++ b/arch/i386/math-emu/fpu_entry.c
@@ -754,7 +754,7 @@ #endif /* PECULIAR_486 */
 return -1;
   if ( offset )
 if (__copy_to_user(d+other, (u_char *)>st_space, offset))
-  return -1
+  return -1;
   RE_ENTRANT_CHECK_ON;
 
   return 1;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] bugfix GFP_KERNEL -> GFP_ATOMIC in spin_locked region

2007-06-04 Thread Yoann Padioleau

In a few files a function such as usb_submit_urb is taking GFP_KERNEL
as an argument whereas this function call is inside a
spin_lock_irqsave region of code. Documentation says that it must be
GFP_ATOMIC instead.

Me and my colleagues have made a tool targeting program
transformations in device drivers. We have designed a scripting
language for specifying easily program transformations and a
transformation engine for performing them. In the spirit of Linux
development practice, the language is based on the patch syntax. We
call our scripts "semantic patches" because as opposed to traditional
patches, our semantic patches do not work at the line level but on a
high level representation of the C program.

FYI here is our semantic patch detecting invalid use of GFP_KERNEL and
fixing the problem:

@@
identifier fn;
@@

 spin_lock_irqsave(...)
 ... when != spin_unlock_irqrestore(...)
 fn(...,
- GFP_KERNEL
+ GFP_ATOMIC
   ,...
   )
 
And now the real patch resulting from the automated transformation:

 net/wan/lmc/lmc_main.c|2 +-
 scsi/megaraid/megaraid_mm.c   |2 +-
 usb/serial/io_ti.c|2 +-
 usb/serial/ti_usb_3410_5052.c |2 +-
 usb/serial/whiteheat.c|6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index ae132c1..750b3ef 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -483,7 +483,7 @@ #endif /* end ifdef _DBG_EVENTLOG */
 break;
 }
 
-data = kmalloc(xc.len, GFP_KERNEL);
+data = kmalloc(xc.len, GFP_ATOMIC);
 if(data == 0x0){
 printk(KERN_WARNING "%s: Failed to allocate memory 
for copy\n", dev->name);
 ret = -ENOMEM;
diff --git a/drivers/scsi/megaraid/megaraid_mm.c 
b/drivers/scsi/megaraid/megaraid_mm.c
index e075a52..edee220 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -547,7 +547,7 @@ mraid_mm_attach_buf(mraid_mmadp_t *adp, 
 
kioc->pool_index= right_pool;
kioc->free_buf  = 1;
-   kioc->buf_vaddr = pci_pool_alloc(pool->handle, GFP_KERNEL,
+   kioc->buf_vaddr = pci_pool_alloc(pool->handle, GFP_ATOMIC,
>buf_paddr);
spin_unlock_irqrestore(>lock, flags);
 
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 544098d..9ec38e3 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2351,7 +2351,7 @@ static int restart_read(struct edgeport_
urb->complete = edge_bulk_in_callback;
urb->context = edge_port;
urb->dev = edge_port->port->serial->dev;
-   status = usb_submit_urb(urb, GFP_KERNEL);
+   status = usb_submit_urb(urb, GFP_ATOMIC);
}
edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING;
edge_port->shadow_mcr |= MCR_RTS;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c 
b/drivers/usb/serial/ti_usb_3410_5052.c
index 4203e2b..10dc36f 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1559,7 +1559,7 @@ static int ti_restart_read(struct ti_por
urb->complete = ti_bulk_in_callback;
urb->context = tport;
urb->dev = tport->tp_port->serial->dev;
-   status = usb_submit_urb(urb, GFP_KERNEL);
+   status = usb_submit_urb(urb, GFP_ATOMIC);
}
tport->tp_read_urb_state = TI_READ_URB_RUNNING;
 
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 27c5f8f..1b01207 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -1116,7 +1116,7 @@ static int firm_send_command (struct usb
memcpy (_buffer[1], data, datasize);
command_port->write_urb->transfer_buffer_length = datasize + 1;
command_port->write_urb->dev = port->serial->dev;
-   retval = usb_submit_urb (command_port->write_urb, GFP_KERNEL);
+   retval = usb_submit_urb (command_port->write_urb, GFP_ATOMIC);
if (retval) {
dbg("%s - submit urb failed", __FUNCTION__);
goto exit;
@@ -1316,7 +1316,7 @@ static int start_command_port(struct usb
usb_clear_halt(serial->dev, command_port->read_urb->pipe);
 
command_port->read_urb->dev = serial->dev;
-   retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL);
+   retval = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);
if (retval) {
err("%s - failed submitting read urb, error %d", 
__FUNCTION__, retval);
goto exit;
@@ -1363,7 +1363,7 @@ static int start_port_read(struct usb_se
wrap = list_entry(tmp, 

[PATCH] bugfix GFP_KERNEL - GFP_ATOMIC in spin_locked region

2007-06-04 Thread Yoann Padioleau

In a few files a function such as usb_submit_urb is taking GFP_KERNEL
as an argument whereas this function call is inside a
spin_lock_irqsave region of code. Documentation says that it must be
GFP_ATOMIC instead.

Me and my colleagues have made a tool targeting program
transformations in device drivers. We have designed a scripting
language for specifying easily program transformations and a
transformation engine for performing them. In the spirit of Linux
development practice, the language is based on the patch syntax. We
call our scripts semantic patches because as opposed to traditional
patches, our semantic patches do not work at the line level but on a
high level representation of the C program.

FYI here is our semantic patch detecting invalid use of GFP_KERNEL and
fixing the problem:

@@
identifier fn;
@@

 spin_lock_irqsave(...)
 ... when != spin_unlock_irqrestore(...)
 fn(...,
- GFP_KERNEL
+ GFP_ATOMIC
   ,...
   )
 
And now the real patch resulting from the automated transformation:

 net/wan/lmc/lmc_main.c|2 +-
 scsi/megaraid/megaraid_mm.c   |2 +-
 usb/serial/io_ti.c|2 +-
 usb/serial/ti_usb_3410_5052.c |2 +-
 usb/serial/whiteheat.c|6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index ae132c1..750b3ef 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -483,7 +483,7 @@ #endif /* end ifdef _DBG_EVENTLOG */
 break;
 }
 
-data = kmalloc(xc.len, GFP_KERNEL);
+data = kmalloc(xc.len, GFP_ATOMIC);
 if(data == 0x0){
 printk(KERN_WARNING %s: Failed to allocate memory 
for copy\n, dev-name);
 ret = -ENOMEM;
diff --git a/drivers/scsi/megaraid/megaraid_mm.c 
b/drivers/scsi/megaraid/megaraid_mm.c
index e075a52..edee220 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -547,7 +547,7 @@ mraid_mm_attach_buf(mraid_mmadp_t *adp, 
 
kioc-pool_index= right_pool;
kioc-free_buf  = 1;
-   kioc-buf_vaddr = pci_pool_alloc(pool-handle, GFP_KERNEL,
+   kioc-buf_vaddr = pci_pool_alloc(pool-handle, GFP_ATOMIC,
kioc-buf_paddr);
spin_unlock_irqrestore(pool-lock, flags);
 
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 544098d..9ec38e3 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2351,7 +2351,7 @@ static int restart_read(struct edgeport_
urb-complete = edge_bulk_in_callback;
urb-context = edge_port;
urb-dev = edge_port-port-serial-dev;
-   status = usb_submit_urb(urb, GFP_KERNEL);
+   status = usb_submit_urb(urb, GFP_ATOMIC);
}
edge_port-ep_read_urb_state = EDGE_READ_URB_RUNNING;
edge_port-shadow_mcr |= MCR_RTS;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c 
b/drivers/usb/serial/ti_usb_3410_5052.c
index 4203e2b..10dc36f 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1559,7 +1559,7 @@ static int ti_restart_read(struct ti_por
urb-complete = ti_bulk_in_callback;
urb-context = tport;
urb-dev = tport-tp_port-serial-dev;
-   status = usb_submit_urb(urb, GFP_KERNEL);
+   status = usb_submit_urb(urb, GFP_ATOMIC);
}
tport-tp_read_urb_state = TI_READ_URB_RUNNING;
 
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 27c5f8f..1b01207 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -1116,7 +1116,7 @@ static int firm_send_command (struct usb
memcpy (transfer_buffer[1], data, datasize);
command_port-write_urb-transfer_buffer_length = datasize + 1;
command_port-write_urb-dev = port-serial-dev;
-   retval = usb_submit_urb (command_port-write_urb, GFP_KERNEL);
+   retval = usb_submit_urb (command_port-write_urb, GFP_ATOMIC);
if (retval) {
dbg(%s - submit urb failed, __FUNCTION__);
goto exit;
@@ -1316,7 +1316,7 @@ static int start_command_port(struct usb
usb_clear_halt(serial-dev, command_port-read_urb-pipe);
 
command_port-read_urb-dev = serial-dev;
-   retval = usb_submit_urb(command_port-read_urb, GFP_KERNEL);
+   retval = usb_submit_urb(command_port-read_urb, GFP_ATOMIC);
if (retval) {
err(%s - failed submitting read urb, error %d, 
__FUNCTION__, retval);
goto exit;
@@ -1363,7 +1363,7 @@ static int start_port_read(struct usb_se
wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
  

  1   2   >