[PATCH] fix 'and' typo in drivers/block/paride/pt.c

2007-10-27 Thread Roel Kluin
Fix 'and' typo (PT_WRITE_OK is defined 2)

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 9f4e67e..b91accf 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -664,7 +664,7 @@ static int pt_open(struct inode *inode, struct file *file)
goto out;
 
err = -EROFS;
-   if ((!tape-flags  PT_WRITE_OK)  (file-f_mode  2))
+   if ((!(tape-flags  PT_WRITE_OK))  (file-f_mode  2))
goto out;
 
if (!(iminor(inode)  128))
-
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 1/?] Unlock when sn_oemdata can't be extended

2007-10-24 Thread Roel Kluin
This includes some that I think I have reported earlier:
in drivers/media/dvb/dvb-usb/au6610.c
and drivers/media/dvb/dvb-usb/gl861.c
--
  Some more unlocking issues
  Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c
index 6be1c57..a6b7ccd 100644
--- a/drivers/char/drm/sis_mm.c
+++ b/drivers/char/drm/sis_mm.c
@@ -134,6 +134,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file_priv,
  dev_priv->agp_initialized)) {
DRM_ERROR
("Attempt to allocate from uninitialized memory 
manager.\n");
+   mutex_unlock(>struct_mutex);
return -EINVAL;
}
 
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index 755570c..d607c9e 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -397,6 +397,7 @@ static ssize_t set_div(struct device *dev, struct 
device_attribute *devattr,
default:
dev_err(>dev,
"illegal value for fan divider (%d)\n", div);
+   mutex_unlock(>update_lock);
return -EINVAL;
}
 
diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
index 79119f5..bd6da7a 100644
--- a/drivers/macintosh/macio-adb.c
+++ b/drivers/macintosh/macio-adb.c
@@ -155,6 +155,7 @@ static int macio_adb_reset_bus(void)
while ((in_8(>ctrl.r) & ADB_RST) != 0) {
if (--timeout == 0) {
out_8(>ctrl.r, in_8(>ctrl.r) & ~ADB_RST);
+   spin_unlock_irqrestore(_lock, flags);
return -1;
}
}
diff --git a/drivers/media/dvb/dvb-usb/au6610.c 
b/drivers/media/dvb/dvb-usb/au6610.c
index 18e0b16..f3ff813 100644
--- a/drivers/media/dvb/dvb-usb/au6610.c
+++ b/drivers/media/dvb/dvb-usb/au6610.c
@@ -79,12 +79,12 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(>i2c_mutex) < 0)
-   return -EAGAIN;
-
if (num > 2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(>i2c_mutex) < 0)
+   return -EAGAIN;
+
for (i = 0; i < num; i++) {
/* write/read request */
if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
diff --git a/drivers/media/dvb/dvb-usb/gl861.c 
b/drivers/media/dvb/dvb-usb/gl861.c
index f01d99c..6b99d9f 100644
--- a/drivers/media/dvb/dvb-usb/gl861.c
+++ b/drivers/media/dvb/dvb-usb/gl861.c
@@ -56,12 +56,12 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(>i2c_mutex) < 0)
-   return -EAGAIN;
-
if (num > 2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(>i2c_mutex) < 0)
+   return -EAGAIN;
+
for (i = 0; i < num; i++) {
/* write/read request */
if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index edd6828..5478549 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -1476,6 +1476,7 @@ e100_ioctl(struct net_device *dev, struct ifreq *ifr, int 
cmd)
e100_set_duplex(dev, autoneg);
break;
default:
+   spin_unlock(>lock);
return -EINVAL;
}
spin_unlock(>lock);
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index d1131a8..716f532 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -496,6 +496,7 @@ static int mdc800_usb_probe (struct usb_interface *intf,
 
retval = usb_register_dev(intf, _class);
if (retval) {
+   mutex_unlock(>io_lock);
err ("Not able to get a minor for this device.");
return -ENODEV;
}
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index cd5a565..185c093 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -300,6 +300,7 @@ static int iTCO_wdt_start(void)
 
/* disable chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit()) {
+   spin_unlock(_wdt_private.io_lock);
printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot 
disabled by hardware\n");
return -EIO;
}
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 006fc64..37bdef1 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -153,8 +153,10 @@ static int mmap(struct file *file, struct 

Re: [PATCH 1/?] Unlock when sn_oemdata can't be extended

2007-10-24 Thread Roel Kluin
 Several unlocking issues
 Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/net/9p/mux.c b/net/9p/mux.c
index f140147..c9f0805 100644
--- a/net/9p/mux.c
+++ b/net/9p/mux.c
@@ -222,8 +222,10 @@ static int p9_mux_poll_start(struct p9_conn *m)
}
 
if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) {
-   if (vptlast == NULL)
+   if (vptlast == NULL) {
+   mutex_unlock(_mux_task_lock);
return -ENOMEM;
+   }
 
P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i);
list_add(>mux_list, >mux_list);
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 817169e..b09c499 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -282,8 +282,10 @@ find_inlist_lock_noload(struct list_head *head, const char 
*name, int *error,
return NULL;
 
list_for_each_entry(e, head, list) {
-   if (strcmp(e->name, name) == 0)
+   if (strcmp(e->name, name) == 0) {
+   mutex_unlock(mutex);
return e;
+   }
}
*error = -ENOENT;
mutex_unlock(mutex);
diff --git a/net/netfilter/nf_conntrack_netlink.c 
b/net/netfilter/nf_conntrack_netlink.c
index 9be1826..cf18097 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1079,7 +1079,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff 
*skb,
CTA_TUPLE_MASTER,
u3);
if (err < 0)
-   return err;
+   goto out_unlock;
 
master_h = __nf_conntrack_find(, NULL);
if (master_h == NULL) {
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 509defe..859fdc0 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -750,8 +750,10 @@ static int rose_connect(struct socket *sock, struct 
sockaddr *uaddr, int addr_le
 
rose->neighbour = rose_get_neigh(>srose_addr, ,
 );
-   if (!rose->neighbour)
-   return -ENETUNREACH;
+   if (!rose->neighbour) {
+   err = -ENETUNREACH;
+   goto out_release;
+   }
 
rose->lci = rose_new_lci(rose->neighbour);
if (!rose->lci) {
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index 23018a7..5b0e9bd 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -1833,12 +1833,16 @@ au1550_open(struct inode *inode, struct file *file)
}
 
if (file->f_mode & FMODE_READ) {
-   if ((ret = prog_dmabuf_adc(s)))
+   if ((ret = prog_dmabuf_adc(s))) {
+   mutex_unlock(>open_mutex);
return ret;
+   }
}
if (file->f_mode & FMODE_WRITE) {
-   if ((ret = prog_dmabuf_dac(s)))
+   if ((ret = prog_dmabuf_dac(s))) {
+   mutex_unlock(>open_mutex);
return ret;
+   }
}
 
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
diff --git a/sound/oss/dmasound/dmasound_atari.c 
b/sound/oss/dmasound/dmasound_atari.c
index 285239d..d23a089 100644
--- a/sound/oss/dmasound/dmasound_atari.c
+++ b/sound/oss/dmasound/dmasound_atari.c
@@ -1276,6 +1276,7 @@ static irqreturn_t AtaInterrupt(int irq, void *dummy)
 * (almost) like on the TT.
 */
write_sq_ignore_int = 0;
+   spin_unlock();
return IRQ_HANDLED;
}
 
@@ -1284,6 +1285,7 @@ static irqreturn_t AtaInterrupt(int irq, void *dummy)
 * the sq variables, so better don't do anything here.
 */
WAKE_UP(write_sq.sync_queue);
+   spin_unlock();
return IRQ_HANDLED;
}
 
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 880b824..2f62ad6 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -608,6 +608,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream 
*subs,
/* set the format to the board */
err = mixart_set_format(stream, format);
if(err < 0) {
+   mutex_unlock(>setup_mutex);
return err;
}
 

-
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 1/?] Unlock when sn_oemdata can't be extended

2007-10-24 Thread Roel Kluin
 Several unlocking issues
 Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/net/9p/mux.c b/net/9p/mux.c
index f140147..c9f0805 100644
--- a/net/9p/mux.c
+++ b/net/9p/mux.c
@@ -222,8 +222,10 @@ static int p9_mux_poll_start(struct p9_conn *m)
}
 
if (i = ARRAY_SIZE(p9_mux_poll_tasks)) {
-   if (vptlast == NULL)
+   if (vptlast == NULL) {
+   mutex_unlock(p9_mux_task_lock);
return -ENOMEM;
+   }
 
P9_DPRINTK(P9_DEBUG_MUX, put in proc %d\n, i);
list_add(m-mux_list, vptlast-mux_list);
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 817169e..b09c499 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -282,8 +282,10 @@ find_inlist_lock_noload(struct list_head *head, const char 
*name, int *error,
return NULL;
 
list_for_each_entry(e, head, list) {
-   if (strcmp(e-name, name) == 0)
+   if (strcmp(e-name, name) == 0) {
+   mutex_unlock(mutex);
return e;
+   }
}
*error = -ENOENT;
mutex_unlock(mutex);
diff --git a/net/netfilter/nf_conntrack_netlink.c 
b/net/netfilter/nf_conntrack_netlink.c
index 9be1826..cf18097 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1079,7 +1079,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff 
*skb,
CTA_TUPLE_MASTER,
u3);
if (err  0)
-   return err;
+   goto out_unlock;
 
master_h = __nf_conntrack_find(master, NULL);
if (master_h == NULL) {
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 509defe..859fdc0 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -750,8 +750,10 @@ static int rose_connect(struct socket *sock, struct 
sockaddr *uaddr, int addr_le
 
rose-neighbour = rose_get_neigh(addr-srose_addr, cause,
 diagnostic);
-   if (!rose-neighbour)
-   return -ENETUNREACH;
+   if (!rose-neighbour) {
+   err = -ENETUNREACH;
+   goto out_release;
+   }
 
rose-lci = rose_new_lci(rose-neighbour);
if (!rose-lci) {
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index 23018a7..5b0e9bd 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -1833,12 +1833,16 @@ au1550_open(struct inode *inode, struct file *file)
}
 
if (file-f_mode  FMODE_READ) {
-   if ((ret = prog_dmabuf_adc(s)))
+   if ((ret = prog_dmabuf_adc(s))) {
+   mutex_unlock(s-open_mutex);
return ret;
+   }
}
if (file-f_mode  FMODE_WRITE) {
-   if ((ret = prog_dmabuf_dac(s)))
+   if ((ret = prog_dmabuf_dac(s))) {
+   mutex_unlock(s-open_mutex);
return ret;
+   }
}
 
s-open_mode |= file-f_mode  (FMODE_READ | FMODE_WRITE);
diff --git a/sound/oss/dmasound/dmasound_atari.c 
b/sound/oss/dmasound/dmasound_atari.c
index 285239d..d23a089 100644
--- a/sound/oss/dmasound/dmasound_atari.c
+++ b/sound/oss/dmasound/dmasound_atari.c
@@ -1276,6 +1276,7 @@ static irqreturn_t AtaInterrupt(int irq, void *dummy)
 * (almost) like on the TT.
 */
write_sq_ignore_int = 0;
+   spin_unlock(dmasound.lock);
return IRQ_HANDLED;
}
 
@@ -1284,6 +1285,7 @@ static irqreturn_t AtaInterrupt(int irq, void *dummy)
 * the sq variables, so better don't do anything here.
 */
WAKE_UP(write_sq.sync_queue);
+   spin_unlock(dmasound.lock);
return IRQ_HANDLED;
}
 
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 880b824..2f62ad6 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -608,6 +608,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream 
*subs,
/* set the format to the board */
err = mixart_set_format(stream, format);
if(err  0) {
+   mutex_unlock(mgr-setup_mutex);
return err;
}
 

-
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 1/?] Unlock when sn_oemdata can't be extended

2007-10-24 Thread Roel Kluin
This includes some that I think I have reported earlier:
in drivers/media/dvb/dvb-usb/au6610.c
and drivers/media/dvb/dvb-usb/gl861.c
--
  Some more unlocking issues
  Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c
index 6be1c57..a6b7ccd 100644
--- a/drivers/char/drm/sis_mm.c
+++ b/drivers/char/drm/sis_mm.c
@@ -134,6 +134,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file_priv,
  dev_priv-agp_initialized)) {
DRM_ERROR
(Attempt to allocate from uninitialized memory 
manager.\n);
+   mutex_unlock(dev-struct_mutex);
return -EINVAL;
}
 
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index 755570c..d607c9e 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -397,6 +397,7 @@ static ssize_t set_div(struct device *dev, struct 
device_attribute *devattr,
default:
dev_err(client-dev,
illegal value for fan divider (%d)\n, div);
+   mutex_unlock(data-update_lock);
return -EINVAL;
}
 
diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
index 79119f5..bd6da7a 100644
--- a/drivers/macintosh/macio-adb.c
+++ b/drivers/macintosh/macio-adb.c
@@ -155,6 +155,7 @@ static int macio_adb_reset_bus(void)
while ((in_8(adb-ctrl.r)  ADB_RST) != 0) {
if (--timeout == 0) {
out_8(adb-ctrl.r, in_8(adb-ctrl.r)  ~ADB_RST);
+   spin_unlock_irqrestore(macio_lock, flags);
return -1;
}
}
diff --git a/drivers/media/dvb/dvb-usb/au6610.c 
b/drivers/media/dvb/dvb-usb/au6610.c
index 18e0b16..f3ff813 100644
--- a/drivers/media/dvb/dvb-usb/au6610.c
+++ b/drivers/media/dvb/dvb-usb/au6610.c
@@ -79,12 +79,12 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(d-i2c_mutex)  0)
-   return -EAGAIN;
-
if (num  2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(d-i2c_mutex)  0)
+   return -EAGAIN;
+
for (i = 0; i  num; i++) {
/* write/read request */
if (i+1  num  (msg[i+1].flags  I2C_M_RD)) {
diff --git a/drivers/media/dvb/dvb-usb/gl861.c 
b/drivers/media/dvb/dvb-usb/gl861.c
index f01d99c..6b99d9f 100644
--- a/drivers/media/dvb/dvb-usb/gl861.c
+++ b/drivers/media/dvb/dvb-usb/gl861.c
@@ -56,12 +56,12 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(d-i2c_mutex)  0)
-   return -EAGAIN;
-
if (num  2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(d-i2c_mutex)  0)
+   return -EAGAIN;
+
for (i = 0; i  num; i++) {
/* write/read request */
if (i+1  num  (msg[i+1].flags  I2C_M_RD)) {
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index edd6828..5478549 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -1476,6 +1476,7 @@ e100_ioctl(struct net_device *dev, struct ifreq *ifr, int 
cmd)
e100_set_duplex(dev, autoneg);
break;
default:
+   spin_unlock(np-lock);
return -EINVAL;
}
spin_unlock(np-lock);
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index d1131a8..716f532 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -496,6 +496,7 @@ static int mdc800_usb_probe (struct usb_interface *intf,
 
retval = usb_register_dev(intf, mdc800_class);
if (retval) {
+   mutex_unlock(mdc800-io_lock);
err (Not able to get a minor for this device.);
return -ENODEV;
}
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index cd5a565..185c093 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -300,6 +300,7 @@ static int iTCO_wdt_start(void)
 
/* disable chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit()) {
+   spin_unlock(iTCO_wdt_private.io_lock);
printk(KERN_ERR PFX failed to reset NO_REBOOT flag, reboot 
disabled by hardware\n);
return -EIO;
}
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 006fc64..37bdef1 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -153,8 +153,10 @@ static int mmap(struct file *file, struct vm_area_struct 
*vma)
mutex_lock(bb-mutex);
 
/* need attr_sd for attr, its parent for kobj */
-   if (!sysfs_get_active_two(attr_sd

[PATCH 2/2] Fix unlock on error

2007-10-23 Thread Roel Kluin
Fix unlock on error
Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c
index a0a9105..a6e6e78 100644
--- a/arch/mips/kernel/irixsig.c
+++ b/arch/mips/kernel/irixsig.c
@@ -426,6 +426,7 @@ asmlinkage int irix_sigprocmask(int how, irix_sigset_t 
__user *new,
break;
 
default:
+   spin_unlock_irq(>sighand->siglock);
return -EINVAL;
}
recalc_sigpending();
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index 1899601..11f5f72 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -525,6 +525,7 @@ static inline int set_sysint1_assign(unsigned int irq, 
unsigned char assign)
intassign1 |= (uint16_t)assign << 9;
break;
default:
+   spin_unlock_irq(>lock);
return -EINVAL;
}
 
@@ -592,6 +593,7 @@ static inline int set_sysint2_assign(unsigned int irq, 
unsigned char assign)
intassign3 |= (uint16_t)assign << 12;
break;
default:
+spin_unlock_irq(>lock);
return -EINVAL;
}
 
-
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 1/?] Unlock when sn_oemdata can't be extended

2007-10-23 Thread Roel Kluin
Unlock when sn_oemdata can't be extended
Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/ia64/sn/kernel/mca.c b/arch/ia64/sn/kernel/mca.c
index 3db62f2..868c9aa 100644
--- a/arch/ia64/sn/kernel/mca.c
+++ b/arch/ia64/sn/kernel/mca.c
@@ -98,6 +98,7 @@ sn_platform_plat_specific_err_print(const u8 * sect_header, 
u8 ** oemdata,
while (*sn_oemdata_size > sn_oemdata_bufsize) {
u8 *newbuf = vmalloc(*sn_oemdata_size);
if (!newbuf) {
+   mutex_unlock(_oemdata_mutex);
printk(KERN_ERR "%s: unable to extend sn_oemdata\n",
   __FUNCTION__);
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] Fix unlocking before return in gpio

2007-10-23 Thread Roel Kluin
Fix unlocking before return in gpio
Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/cris/arch-v10/drivers/gpio.c 
b/arch/cris/arch-v10/drivers/gpio.c
index f389ed6..0d347a7 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -297,8 +297,10 @@ gpio_poll(struct file *file,
data = *R_PORT_PB_DATA;
else if (priv->minor == GPIO_MINOR_G)
data = *R_PORT_G_DATA;
-   else
+   else {
+   spin_unlock(_lock);
return 0;
+   }

if ((data & priv->highalarm) ||
(~data & priv->lowalarm)) {
@@ -381,18 +383,21 @@ static ssize_t gpio_write(struct file * file, const char 
* buf, size_t count,
 
ssize_t retval = count;
if (priv->minor !=GPIO_MINOR_A && priv->minor != GPIO_MINOR_B) {
-   return -EFAULT;
+   retval = -EFAULT;
+   goto out;
}
 
if (!access_ok(VERIFY_READ, buf, count)) {
-   return -EFAULT;
+   retval = -EFAULT;
+   goto out;
}
clk_mask = priv->clk_mask;
data_mask = priv->data_mask;
/* It must have been configured using the IO_CFG_WRITE_MODE */
/* Perhaps a better error code? */
if (clk_mask == 0 || data_mask == 0) {
-   return -EPERM;
+   retval = -EPERM;
+   goto out;
}
write_msb = priv->write_msb;
D(printk("gpio_write: %lu to data 0x%02X clk 0x%02X msb: %i\n",count, 
data_mask, clk_mask, write_msb));
@@ -425,6 +430,7 @@ static ssize_t gpio_write(struct file * file, const char * 
buf, size_t count,
}
}
}
+out:
spin_unlock(_lock);
return retval;
 }
@@ -506,6 +512,7 @@ gpio_release(struct inode *inode, struct file *filp)
while (p) {
if (p->highalarm | p->lowalarm) {
gpio_some_alarms = 1;
+   spin_unlock(_lock);
return 0;
}
p = p->next;
-
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] Unlock when ssp tries to close an invalid port

2007-10-23 Thread Roel Kluin
Unlock when ssp tries to close an invalid port
Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/arm/mach-pxa/ssp.c b/arch/arm/mach-pxa/ssp.c
index 71766ac..422afee 100644
--- a/arch/arm/mach-pxa/ssp.c
+++ b/arch/arm/mach-pxa/ssp.c
@@ -309,6 +309,7 @@ void ssp_exit(struct ssp_dev *dev)
 
if (dev->port > PXA_SSP_PORTS || dev->port == 0) {
printk(KERN_WARNING "SSP: tried to close invalid port\n");
+   mutex_unlock();
return;
}
 

-
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] unlock 12c_mutex before return

2007-10-23 Thread Roel Kluin
Andreas Schwab wrote:

>> -if (num > 2)
>> +if (num > 2) {
>> +mutex_unlock(>i2c_mutex);
>>  return -EINVAL;
> 
> How about moving the check before the lock?

Good suggestion. Patch below covers both previous patches.
--
Move check before lock

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/media/dvb/dvb-usb/au6610.c 
b/drivers/media/dvb/dvb-usb/au6610.c
index 18e0b16..f3ff813 100644
--- a/drivers/media/dvb/dvb-usb/au6610.c
+++ b/drivers/media/dvb/dvb-usb/au6610.c
@@ -79,12 +79,12 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(>i2c_mutex) < 0)
-   return -EAGAIN;
-
if (num > 2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(>i2c_mutex) < 0)
+   return -EAGAIN;
+
for (i = 0; i < num; i++) {
/* write/read request */
if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
diff --git a/drivers/media/dvb/dvb-usb/gl861.c 
b/drivers/media/dvb/dvb-usb/gl861.c
index f01d99c..6b99d9f 100644
--- a/drivers/media/dvb/dvb-usb/gl861.c
+++ b/drivers/media/dvb/dvb-usb/gl861.c
@@ -56,12 +56,12 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(>i2c_mutex) < 0)
-   return -EAGAIN;
-
if (num > 2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(>i2c_mutex) < 0)
+   return -EAGAIN;
+
for (i = 0; i < num; i++) {
/* write/read request */
if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {

-
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] unlock 12c_mutex before return

2007-10-23 Thread Roel Kluin
Andreas Schwab wrote:

 -if (num  2)
 +if (num  2) {
 +mutex_unlock(d-i2c_mutex);
  return -EINVAL;
 
 How about moving the check before the lock?

Good suggestion. Patch below covers both previous patches.
--
Move check before lock

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/media/dvb/dvb-usb/au6610.c 
b/drivers/media/dvb/dvb-usb/au6610.c
index 18e0b16..f3ff813 100644
--- a/drivers/media/dvb/dvb-usb/au6610.c
+++ b/drivers/media/dvb/dvb-usb/au6610.c
@@ -79,12 +79,12 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(d-i2c_mutex)  0)
-   return -EAGAIN;
-
if (num  2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(d-i2c_mutex)  0)
+   return -EAGAIN;
+
for (i = 0; i  num; i++) {
/* write/read request */
if (i+1  num  (msg[i+1].flags  I2C_M_RD)) {
diff --git a/drivers/media/dvb/dvb-usb/gl861.c 
b/drivers/media/dvb/dvb-usb/gl861.c
index f01d99c..6b99d9f 100644
--- a/drivers/media/dvb/dvb-usb/gl861.c
+++ b/drivers/media/dvb/dvb-usb/gl861.c
@@ -56,12 +56,12 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
 
-   if (mutex_lock_interruptible(d-i2c_mutex)  0)
-   return -EAGAIN;
-
if (num  2)
return -EINVAL;
 
+   if (mutex_lock_interruptible(d-i2c_mutex)  0)
+   return -EAGAIN;
+
for (i = 0; i  num; i++) {
/* write/read request */
if (i+1  num  (msg[i+1].flags  I2C_M_RD)) {

-
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] Unlock when ssp tries to close an invalid port

2007-10-23 Thread Roel Kluin
Unlock when ssp tries to close an invalid port
Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/arm/mach-pxa/ssp.c b/arch/arm/mach-pxa/ssp.c
index 71766ac..422afee 100644
--- a/arch/arm/mach-pxa/ssp.c
+++ b/arch/arm/mach-pxa/ssp.c
@@ -309,6 +309,7 @@ void ssp_exit(struct ssp_dev *dev)
 
if (dev-port  PXA_SSP_PORTS || dev-port == 0) {
printk(KERN_WARNING SSP: tried to close invalid port\n);
+   mutex_unlock(mutex);
return;
}
 

-
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] Fix unlocking before return in gpio

2007-10-23 Thread Roel Kluin
Fix unlocking before return in gpio
Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/cris/arch-v10/drivers/gpio.c 
b/arch/cris/arch-v10/drivers/gpio.c
index f389ed6..0d347a7 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -297,8 +297,10 @@ gpio_poll(struct file *file,
data = *R_PORT_PB_DATA;
else if (priv-minor == GPIO_MINOR_G)
data = *R_PORT_G_DATA;
-   else
+   else {
+   spin_unlock(gpio_lock);
return 0;
+   }

if ((data  priv-highalarm) ||
(~data  priv-lowalarm)) {
@@ -381,18 +383,21 @@ static ssize_t gpio_write(struct file * file, const char 
* buf, size_t count,
 
ssize_t retval = count;
if (priv-minor !=GPIO_MINOR_A  priv-minor != GPIO_MINOR_B) {
-   return -EFAULT;
+   retval = -EFAULT;
+   goto out;
}
 
if (!access_ok(VERIFY_READ, buf, count)) {
-   return -EFAULT;
+   retval = -EFAULT;
+   goto out;
}
clk_mask = priv-clk_mask;
data_mask = priv-data_mask;
/* It must have been configured using the IO_CFG_WRITE_MODE */
/* Perhaps a better error code? */
if (clk_mask == 0 || data_mask == 0) {
-   return -EPERM;
+   retval = -EPERM;
+   goto out;
}
write_msb = priv-write_msb;
D(printk(gpio_write: %lu to data 0x%02X clk 0x%02X msb: %i\n,count, 
data_mask, clk_mask, write_msb));
@@ -425,6 +430,7 @@ static ssize_t gpio_write(struct file * file, const char * 
buf, size_t count,
}
}
}
+out:
spin_unlock(gpio_lock);
return retval;
 }
@@ -506,6 +512,7 @@ gpio_release(struct inode *inode, struct file *filp)
while (p) {
if (p-highalarm | p-lowalarm) {
gpio_some_alarms = 1;
+   spin_unlock(gpio_lock);
return 0;
}
p = p-next;
-
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 1/?] Unlock when sn_oemdata can't be extended

2007-10-23 Thread Roel Kluin
Unlock when sn_oemdata can't be extended
Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/ia64/sn/kernel/mca.c b/arch/ia64/sn/kernel/mca.c
index 3db62f2..868c9aa 100644
--- a/arch/ia64/sn/kernel/mca.c
+++ b/arch/ia64/sn/kernel/mca.c
@@ -98,6 +98,7 @@ sn_platform_plat_specific_err_print(const u8 * sect_header, 
u8 ** oemdata,
while (*sn_oemdata_size  sn_oemdata_bufsize) {
u8 *newbuf = vmalloc(*sn_oemdata_size);
if (!newbuf) {
+   mutex_unlock(sn_oemdata_mutex);
printk(KERN_ERR %s: unable to extend sn_oemdata\n,
   __FUNCTION__);
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 2/2] Fix unlock on error

2007-10-23 Thread Roel Kluin
Fix unlock on error
Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c
index a0a9105..a6e6e78 100644
--- a/arch/mips/kernel/irixsig.c
+++ b/arch/mips/kernel/irixsig.c
@@ -426,6 +426,7 @@ asmlinkage int irix_sigprocmask(int how, irix_sigset_t 
__user *new,
break;
 
default:
+   spin_unlock_irq(current-sighand-siglock);
return -EINVAL;
}
recalc_sigpending();
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index 1899601..11f5f72 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -525,6 +525,7 @@ static inline int set_sysint1_assign(unsigned int irq, 
unsigned char assign)
intassign1 |= (uint16_t)assign  9;
break;
default:
+   spin_unlock_irq(desc-lock);
return -EINVAL;
}
 
@@ -592,6 +593,7 @@ static inline int set_sysint2_assign(unsigned int irq, 
unsigned char assign)
intassign3 |= (uint16_t)assign  12;
break;
default:
+spin_unlock_irq(desc-lock);
return -EINVAL;
}
 
-
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] several returns before unlocking in lmc_ioctl

2007-10-22 Thread Roel Kluin
I think we should keep the lmc_tracing. Use this patch instead.

--
Several returns before unlocking in lmc_ioctl

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 5ea8772..64eb578 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  * To date internally, just copy this out to the user.
  */
 case LMCIOCGINFO: /*fold01*/
-if (copy_to_user(ifr->ifr_data, >ictl, sizeof (lmc_ctl_t)))
-return -EFAULT;
-ret = 0;
+   if (copy_to_user(ifr->ifr_data, >ictl, sizeof(lmc_ctl_t)))
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCSINFO: /*fold01*/
@@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 sc->lmc_media->set_status (sc, );
 
@@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
break;
}
 
-   if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t)))
-return -EFAULT;
+   if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 
if (new_type == old_type)
@@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 sc->lmc_xinfo.Magic1 = 0xDEADBEEF;
 
 if (copy_to_user(ifr->ifr_data, >lmc_xinfo,
- sizeof (struct lmc_xinfo)))
-return -EFAULT;
-ret = 0;
+   sizeof(struct lmc_xinfo))) {
+   ret = -EFAULT;
+   else
+   ret = 0;
 
 break;
 
@@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 if (copy_to_user(ifr->ifr_data, >stats,
  sizeof (struct lmc_statistics)))
-return -EFAULT;
-
-ret = 0;
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCCLEARLMCSTATS: /*fold01*/
@@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 sc->lmc_media->set_circuit_type(sc, ctl.circuit_type);
 sc->ictl.circuit_type = ctl.circuit_type;
 ret = 0;
@@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 #ifdef DEBUG
 case LMCIOCDUMPEVENTLOG:
-if (copy_to_user(ifr->ifr_data, , sizeof (u32)))
-return -EFAULT;
+   if (copy_to_user(ifr->ifr_data, , sizeof(u32))) {
+   ret = -EFAULT;
+   break;
+   }
 if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof 
(lmcEventLogBuf)))
-return -EFAULT;
+   ret = -EFAULT;
+   else
+   ret = 0;
 
-ret = 0;
 break;
 #endif /* end ifdef _DBG_EVENTLOG */
 case LMCIOCT1CONTROL: /*fold01*/
@@ -346,8 +357,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  */
 netif_stop_queue(dev);
 
-if (copy_from_user(, ifr->ifr_data, sizeof (struct 
lmc_xilinx_control)))
-return -EFAULT;
+   if (copy_from_user(, ifr->ifr_data, sizeof(struct 
lmc_xilinx_control))) {
+   ret = -EFAULT;
+   break;
+   }
 switch(xc.command){
 case lmc_xilinx_reset: /*fold02*/
 {

-
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] Unlock before return in p9_mux_poll_start

2007-10-22 Thread Roel Kluin
commit 9f822afc65cc094c905901f9d92bf25042f9ed22
Author: Roel Kluin <[EMAIL PROTECTED]>
Date:   Tue Oct 23 03:15:55 2007 +0200

Unlock before return in p9_mux_poll_start

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>

diff --git a/net/9p/mux.c b/net/9p/mux.c
index f140147..c9f0805 100644
--- a/net/9p/mux.c
+++ b/net/9p/mux.c
@@ -222,8 +222,10 @@ static int p9_mux_poll_start(struct p9_conn *m)
}
 
if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) {
-   if (vptlast == NULL)
+   if (vptlast == NULL) {
+   mutex_unlock(_mux_task_lock);
return -ENOMEM;
+   }
 
P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i);
list_add(>mux_list, >mux_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/


[PATCH] Unlock in iTCO_wdt_start when reboot is disabled

2007-10-22 Thread Roel Kluin
commit 61c31efe4e9c34531666a6c5857ecd19c8db
Author: Roel Kluin <[EMAIL PROTECTED]>
Date:   Tue Oct 23 03:08:27 2007 +0200

Unlock in iTCO_wdt_start when reboot is disabled

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index cd5a565..185c093 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -300,6 +300,7 @@ static int iTCO_wdt_start(void)
 
/* disable chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit()) {
+   spin_unlock(_wdt_private.io_lock);
printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot 
disabled by hardware\n");
return -EIO;
}
-
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] several returns before unlocking in lmc_ioctl

2007-10-22 Thread Roel Kluin
Several returns before unlocking in lmc_ioctl

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 5ea8772..af7b3e4 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  * To date internally, just copy this out to the user.
  */
 case LMCIOCGINFO: /*fold01*/
-if (copy_to_user(ifr->ifr_data, >ictl, sizeof (lmc_ctl_t)))
-return -EFAULT;
-ret = 0;
+   if (copy_to_user(ifr->ifr_data, >ictl, sizeof(lmc_ctl_t)))
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCSINFO: /*fold01*/
@@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 sc->lmc_media->set_status (sc, );
 
@@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
break;
}
 
-   if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t)))
-return -EFAULT;
+   if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 
if (new_type == old_type)
@@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 sc->lmc_xinfo.Magic1 = 0xDEADBEEF;
 
 if (copy_to_user(ifr->ifr_data, >lmc_xinfo,
- sizeof (struct lmc_xinfo)))
-return -EFAULT;
-ret = 0;
+   sizeof(struct lmc_xinfo))) {
+   ret = -EFAULT;
+   else
+   ret = 0;
 
 break;
 
@@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 if (copy_to_user(ifr->ifr_data, >stats,
  sizeof (struct lmc_statistics)))
-return -EFAULT;
-
-ret = 0;
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCCLEARLMCSTATS: /*fold01*/
@@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 sc->lmc_media->set_circuit_type(sc, ctl.circuit_type);
 sc->ictl.circuit_type = ctl.circuit_type;
 ret = 0;
@@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 #ifdef DEBUG
 case LMCIOCDUMPEVENTLOG:
-if (copy_to_user(ifr->ifr_data, , sizeof (u32)))
-return -EFAULT;
+   if (copy_to_user(ifr->ifr_data, , sizeof(u32))) {
+   ret = -EFAULT;
+   break;
+   }
 if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof 
(lmcEventLogBuf)))
-return -EFAULT;
+   ret = -EFAULT;
+   else
+   ret = 0;
 
-ret = 0;
 break;
 #endif /* end ifdef _DBG_EVENTLOG */
 case LMCIOCT1CONTROL: /*fold01*/
@@ -346,8 +357,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  */
 netif_stop_queue(dev);
 
-if (copy_from_user(, ifr->ifr_data, sizeof (struct 
lmc_xilinx_control)))
-return -EFAULT;
+   if (copy_from_user(, ifr->ifr_data, sizeof(struct 
lmc_xilinx_control))) {
+   ret = -EFAULT;
+   break;
+   }
 switch(xc.command){
 case lmc_xilinx_reset: /*fold02*/
 {
@@ -618,8 +631,8 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 }
 
 spin_unlock_irqrestore(>lmc_lock, flags); /*fold01*/
-
-lmc_trace(dev, "lmc_ioctl out");
+if (ret >= 0)
+   lmc_trace(dev, "lmc_ioctl out");
 
 return ret;
 }
-
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] unlock 12c_mutex before return

2007-10-22 Thread Roel Kluin
And a similar one in drivers/media/dvb/dvb-usb/gl861.c
--
unlock 12c_mutex before return -EINVAL

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/media/dvb/dvb-usb/gl861.c 
b/drivers/media/dvb/dvb-usb/gl861.c
index f01d99c..20c340a 100644
--- a/drivers/media/dvb/dvb-usb/gl861.c
+++ b/drivers/media/dvb/dvb-usb/gl861.c
@@ -59,8 +59,10 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
if (mutex_lock_interruptible(>i2c_mutex) < 0)
return -EAGAIN;
 
-   if (num > 2)
+   if (num > 2) {
+   mutex_unlock(>i2c_mutex);
return -EINVAL;
+   }
 
for (i = 0; i < num; i++) {
/* write/read request */

-
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] unlock 12c_mutex before return

2007-10-22 Thread Roel Kluin
unlock 12c_mutex before return -EINVAL

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/media/dvb/dvb-usb/au6610.c 
b/drivers/media/dvb/dvb-usb/au6610.c
index 18e0b16..31f47c7 100644
--- a/drivers/media/dvb/dvb-usb/au6610.c
+++ b/drivers/media/dvb/dvb-usb/au6610.c
@@ -82,8 +82,10 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
if (mutex_lock_interruptible(>i2c_mutex) < 0)
return -EAGAIN;
 
-   if (num > 2)
+   if (num > 2) {
+mutex_unlock(>i2c_mutex);
return -EINVAL;
+   }
 
for (i = 0; i < num; i++) {
/* write/read request */
-
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] unlock before bug returns

2007-10-22 Thread Roel Kluin
Rene Herman wrote:
> On 10/22/2007 02:40 PM, Pekka Enberg wrote:
> 
>> NAK. This will cause double-unlock when CONFIG_BUG is disabled. It's
>> incorrect to assume that BUG() will always terminate the current
>> process.
> 
> (which by the way also means that the "return;" delete from your
> original patch changes behaviour for !CONFIG_BUG, and probably not for
> the better).
> 
> Rene.

Thanks for your comments. A patch containing this suggestion is:

[PATCH retry] return hidden bug and unlock bugs.

Roel
-
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 retry] return hidden bug and unlock bugs

2007-10-22 Thread Roel Kluin
Roel Kluin wrote:
> This patches shouldn't alter behavior when CONFIG_BUG is disabled. It is meant
> as a replacement for the previous patches.
> 
> Concerning the patch changing fs/buffer.c, I am still wondering whether
> "page_cache_release(page)" should be placed before or after the BUG().

...

> @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t 
> dma_addr, size_t size,
>   printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx "
>  " base %lx size %x\n", dma_addr, arena->dma_base,
>  arena->size);
> - return;
>   BUG();
> + return;
>   }

As suggested by Ray Lee, BUG() is changed into WARN_ON(1)

--
Unlock before BUG(), but don't change behavior in the case when
CONFIG_BUG is disabled. Also changes a return-hidden BUG() in
a WARN_ON(1)

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>

diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..d04f151 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx "
   " base %lx size %x\n", dma_addr, arena->dma_base,
   arena->size);
+   WARN_ON(1);
return;
-   BUG();
}
 
npages = calc_npages((dma_addr & ~PAGE_MASK) + size);
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5a4cc20..12bd0eb 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -357,8 +357,8 @@ void gpmc_cs_free(int cs)
spin_lock(_mem_lock);
if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
-   BUG();
spin_unlock(_mem_lock);
+   BUG();
return;
}
gpmc_cs_disable_mem(cs);
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 88629a3..e72bead 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -100,8 +100,11 @@ static ssize_t vol_attribute_show(struct device *dev,
ret = sprintf(buf, "%lld\n", vol->used_bytes);
else if (attr == _vol_upd_marker)
ret = sprintf(buf, "%d\n", vol->upd_marker);
-   else
+   else {
+   spin_unlock(>ubi->volumes_lock);
BUG();
+   return -EINVAL;
+   }
spin_unlock(>ubi->volumes_lock);
return ret;
 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e3c8284..f337578 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8722,7 +8722,9 @@ static int ipw_wx_get_freq(struct net_device *dev,
break;
 
default:
+   mutex_unlock(>mutex);
BUG();
+   return -EINVAL;
}
} else
wrqu->freq.m = 0;
diff --git a/fs/buffer.c b/fs/buffer.c
index 7249e01..90a3785 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block,
return page;
 
 failed:
-   BUG();
unlock_page(page);
page_cache_release(page);
+   BUG();
return NULL;
 }
 
diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..2dd48c1 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1604,11 +1604,16 @@ void __init kmem_cache_init(void)
/* 6) resize the head arrays to their final sizes */
{
struct kmem_cache *cachep;
+   int fail = 0;
mutex_lock(_chain_mutex);
list_for_each_entry(cachep, _chain, next)
-   if (enable_cpucache(cachep))
+   if (enable_cpucache(cachep)) {
+   fail = 1;
+   mutex_unlock(_chain_mutex);
BUG();
-   mutex_unlock(_chain_mutex);
+   }
+   if (fail != 1)
+   mutex_unlock(_chain_mutex);
}
 
/* Annotate slab for lockdep -- annotate the malloc caches */
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index 657ee69..e551b0b 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -752,8 +752,11 @@ all_acked:
sp->call = call;
rxrpc_get_call(call);
spin_lock_bh(>lock);
-   if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0)
+   if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) {
+   spin_unloc

Re: [PATCH] return hidden bug

2007-10-22 Thread Roel Kluin
Ray Lee wrote:

>>> I'm sorry, perhaps I poured myself a cup of stupid this morning, but
>>> isn't the above patch effectively introducing a BUG where none could
>>> be reached before? In other words, for the patch to have zero
>>> behavioral change, wouldn't it have to remove the BUG() altogether?
>> True, but obviously not intended. I think the intention was to expose this 
>> bug.
> 
> Arguing intentions is very dangerous. I've written code like that
> where the intention is to make it simple to turn a printk into a full
> bug and back and forth during development. At the end of the day, the
> fact remains that you're changing behavior.
> 
> Let me turn this around. Do you have an alpha and have you tried out
> your patch? If not, then I'd suggest turning it into a WARN_ON(1)
> instead, as in this specific case you're risking turning what was a
> working system into one that doesn't.

No, I haven't and, I will change it, but it's included with my other
changes. see the reply that I'll write shortly for.
[PATCH retry] return hidden bug and unlock bugs.

Roel


-
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] return hidden bug

2007-10-22 Thread Roel Kluin
Ray Lee wrote:

> I'm sorry, perhaps I poured myself a cup of stupid this morning, but
> isn't the above patch effectively introducing a BUG where none could
> be reached before? In other words, for the patch to have zero
> behavioral change, wouldn't it have to remove the BUG() altogether?

True, but obviously not intended. I think the intention was to expose this bug.

-
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 retry] return hidden bug and unlock bugs

2007-10-22 Thread Roel Kluin
This patches shouldn't alter behavior when CONFIG_BUG is disabled. It is meant
as a replacement for the previous patches.

Concerning the patch changing fs/buffer.c, I am still wondering whether
"page_cache_release(page)" should be placed before or after the BUG().
--
Unlock before BUG(), but don't change behavior in the case when
CONFIG_BUG is disabled

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..6a69425 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx "
   " base %lx size %x\n", dma_addr, arena->dma_base,
   arena->size);
-   return;
BUG();
+   return;
}
 
npages = calc_npages((dma_addr & ~PAGE_MASK) + size);
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5a4cc20..12bd0eb 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -357,8 +357,8 @@ void gpmc_cs_free(int cs)
spin_lock(_mem_lock);
if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
-   BUG();
spin_unlock(_mem_lock);
+   BUG();
return;
}
gpmc_cs_disable_mem(cs);
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 88629a3..e72bead 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -100,8 +100,11 @@ static ssize_t vol_attribute_show(struct device *dev,
ret = sprintf(buf, "%lld\n", vol->used_bytes);
else if (attr == _vol_upd_marker)
ret = sprintf(buf, "%d\n", vol->upd_marker);
-   else
+   else {
+   spin_unlock(>ubi->volumes_lock);
BUG();
+   return -EINVAL;
+   }
spin_unlock(>ubi->volumes_lock);
return ret;
 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e3c8284..f337578 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8722,7 +8722,9 @@ static int ipw_wx_get_freq(struct net_device *dev,
break;
 
default:
+   mutex_unlock(>mutex);
BUG();
+   return -EINVAL;
}
} else
wrqu->freq.m = 0;
diff --git a/fs/buffer.c b/fs/buffer.c
index 7249e01..90a3785 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block,
return page;
 
 failed:
-   BUG();
unlock_page(page);
page_cache_release(page);
+   BUG();
return NULL;
 }
 
diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..2dd48c1 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1604,11 +1604,16 @@ void __init kmem_cache_init(void)
/* 6) resize the head arrays to their final sizes */
{
struct kmem_cache *cachep;
+   int fail = 0;
mutex_lock(_chain_mutex);
list_for_each_entry(cachep, _chain, next)
-   if (enable_cpucache(cachep))
+   if (enable_cpucache(cachep)) {
+   fail = 1;
+   mutex_unlock(_chain_mutex);
BUG();
-   mutex_unlock(_chain_mutex);
+   }
+   if (fail != 1)
+   mutex_unlock(_chain_mutex);
}
 
/* Annotate slab for lockdep -- annotate the malloc caches */
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index 657ee69..e551b0b 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -752,8 +752,11 @@ all_acked:
sp->call = call;
rxrpc_get_call(call);
spin_lock_bh(>lock);
-   if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0)
+   if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) {
+   spin_unlock_bh(>lock);
BUG();
+   goto process_further;
+   }
spin_unlock_bh(>lock);
goto process_further;
}
diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
index 3c04b00..48804e1 100644
--- a/net/rxrpc/ar-call.c
+++ b/net/rxrpc/ar-call.c
@@ -426,9 +426,12 @@ void rxrpc_release_call(struct rxrpc_call *call)
   call->rx_first_oos);
 
spin_lock_bh(>lock);
-   if (test_and_set_bit(RXRPC_CALL_RELEASED, >flags))
+   if (test_and_set_bit(RXRPC_CAL

Re: [PATCH] unlock before bug returns

2007-10-22 Thread Roel Kluin

>> should we bother to unlock before panicking, or is the unlock not
>> required either?
> 
> BUG() kills the current process, but not the whole system.
> 
> Unlocking the lock means that the rest of the system has somewhat
> of a chance of surviving.  Not unlocking means a guaranteed hang
> for the rest of the system, making a BUG() no better than panic.
> 
> Please keep the unlock.

In that case I guess the pathc below fixes some more unlockings before
bugging.

in the third patch: maybe BUG before "page_cache_release(page)"?
I also spotted some cases where it was attempted to free after BUG().
should that occur before BUG() as well?

--

    Unlock before BUG()

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 88629a3..679c8b4 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -100,8 +100,10 @@ static ssize_t vol_attribute_show(struct device *dev,
ret = sprintf(buf, "%lld\n", vol->used_bytes);
else if (attr == _vol_upd_marker)
ret = sprintf(buf, "%d\n", vol->upd_marker);
-   else
+   else{
+   spin_unlock(>ubi->volumes_lock);
BUG();
+   }
spin_unlock(>ubi->volumes_lock);
return ret;
 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e3c8284..67ed205 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8722,6 +8722,7 @@ static int ipw_wx_get_freq(struct net_device *dev,
break;
 
default:
+   mutex_unlock(>mutex);
BUG();
}
} else
diff --git a/fs/buffer.c b/fs/buffer.c
index 76403b1..460c17d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block,
return page;
 
 failed:
-   BUG();
unlock_page(page);
page_cache_release(page);
+   BUG();
return NULL;
 }
 
diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..20c58dc 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1606,8 +1606,10 @@ void __init kmem_cache_init(void)
struct kmem_cache *cachep;
mutex_lock(_chain_mutex);
list_for_each_entry(cachep, _chain, next)
-   if (enable_cpucache(cachep))
+   if (enable_cpucache(cachep)) {
+   mutex_unlock(_chain_mutex);
BUG();
+   }
mutex_unlock(_chain_mutex);
}
 
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index 657ee69..c56e773 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -752,8 +752,10 @@ all_acked:
sp->call = call;
rxrpc_get_call(call);
spin_lock_bh(>lock);
-   if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0)
+   if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) {
+   spin_unlock_bh(>lock);
BUG();
+   }
spin_unlock_bh(>lock);
goto process_further;
}
diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
index 3c04b00..0d30466 100644
--- a/net/rxrpc/ar-call.c
+++ b/net/rxrpc/ar-call.c
@@ -426,8 +426,10 @@ void rxrpc_release_call(struct rxrpc_call *call)
   call->rx_first_oos);
 
spin_lock_bh(>lock);
-   if (test_and_set_bit(RXRPC_CALL_RELEASED, >flags))
+   if (test_and_set_bit(RXRPC_CALL_RELEASED, >flags)) {
+   spin_unlock_bh(>lock);
BUG();
+   }
spin_unlock_bh(>lock);
 
/* dissociate from the socket
-
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] unlock before bug returns

2007-10-22 Thread Roel Kluin

 should we bother to unlock before panicking, or is the unlock not
 required either?
 
 BUG() kills the current process, but not the whole system.
 
 Unlocking the lock means that the rest of the system has somewhat
 of a chance of surviving.  Not unlocking means a guaranteed hang
 for the rest of the system, making a BUG() no better than panic.
 
 Please keep the unlock.

In that case I guess the pathc below fixes some more unlockings before
bugging.

in the third patch: maybe BUG before page_cache_release(page)?
I also spotted some cases where it was attempted to free after BUG().
should that occur before BUG() as well?

--

Unlock before BUG()

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 88629a3..679c8b4 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -100,8 +100,10 @@ static ssize_t vol_attribute_show(struct device *dev,
ret = sprintf(buf, %lld\n, vol-used_bytes);
else if (attr == attr_vol_upd_marker)
ret = sprintf(buf, %d\n, vol-upd_marker);
-   else
+   else{
+   spin_unlock(vol-ubi-volumes_lock);
BUG();
+   }
spin_unlock(vol-ubi-volumes_lock);
return ret;
 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e3c8284..67ed205 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8722,6 +8722,7 @@ static int ipw_wx_get_freq(struct net_device *dev,
break;
 
default:
+   mutex_unlock(priv-mutex);
BUG();
}
} else
diff --git a/fs/buffer.c b/fs/buffer.c
index 76403b1..460c17d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block,
return page;
 
 failed:
-   BUG();
unlock_page(page);
page_cache_release(page);
+   BUG();
return NULL;
 }
 
diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..20c58dc 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1606,8 +1606,10 @@ void __init kmem_cache_init(void)
struct kmem_cache *cachep;
mutex_lock(cache_chain_mutex);
list_for_each_entry(cachep, cache_chain, next)
-   if (enable_cpucache(cachep))
+   if (enable_cpucache(cachep)) {
+   mutex_unlock(cache_chain_mutex);
BUG();
+   }
mutex_unlock(cache_chain_mutex);
}
 
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index 657ee69..c56e773 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -752,8 +752,10 @@ all_acked:
sp-call = call;
rxrpc_get_call(call);
spin_lock_bh(call-lock);
-   if (rxrpc_queue_rcv_skb(call, skb, true, true)  0)
+   if (rxrpc_queue_rcv_skb(call, skb, true, true)  0) {
+   spin_unlock_bh(call-lock);
BUG();
+   }
spin_unlock_bh(call-lock);
goto process_further;
}
diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
index 3c04b00..0d30466 100644
--- a/net/rxrpc/ar-call.c
+++ b/net/rxrpc/ar-call.c
@@ -426,8 +426,10 @@ void rxrpc_release_call(struct rxrpc_call *call)
   call-rx_first_oos);
 
spin_lock_bh(call-lock);
-   if (test_and_set_bit(RXRPC_CALL_RELEASED, call-flags))
+   if (test_and_set_bit(RXRPC_CALL_RELEASED, call-flags)) {
+   spin_unlock_bh(call-lock);
BUG();
+   }
spin_unlock_bh(call-lock);
 
/* dissociate from the socket
-
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 retry] return hidden bug and unlock bugs

2007-10-22 Thread Roel Kluin
This patches shouldn't alter behavior when CONFIG_BUG is disabled. It is meant
as a replacement for the previous patches.

Concerning the patch changing fs/buffer.c, I am still wondering whether
page_cache_release(page) should be placed before or after the BUG().
--
Unlock before BUG(), but don't change behavior in the case when
CONFIG_BUG is disabled

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..6a69425 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR Bogus pci_unmap_single: dma_addr %lx 
base %lx size %x\n, dma_addr, arena-dma_base,
   arena-size);
-   return;
BUG();
+   return;
}
 
npages = calc_npages((dma_addr  ~PAGE_MASK) + size);
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5a4cc20..12bd0eb 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -357,8 +357,8 @@ void gpmc_cs_free(int cs)
spin_lock(gpmc_mem_lock);
if (cs = GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
printk(KERN_ERR Trying to free non-reserved GPMC CS%d\n, cs);
-   BUG();
spin_unlock(gpmc_mem_lock);
+   BUG();
return;
}
gpmc_cs_disable_mem(cs);
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 88629a3..e72bead 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -100,8 +100,11 @@ static ssize_t vol_attribute_show(struct device *dev,
ret = sprintf(buf, %lld\n, vol-used_bytes);
else if (attr == attr_vol_upd_marker)
ret = sprintf(buf, %d\n, vol-upd_marker);
-   else
+   else {
+   spin_unlock(vol-ubi-volumes_lock);
BUG();
+   return -EINVAL;
+   }
spin_unlock(vol-ubi-volumes_lock);
return ret;
 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e3c8284..f337578 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8722,7 +8722,9 @@ static int ipw_wx_get_freq(struct net_device *dev,
break;
 
default:
+   mutex_unlock(priv-mutex);
BUG();
+   return -EINVAL;
}
} else
wrqu-freq.m = 0;
diff --git a/fs/buffer.c b/fs/buffer.c
index 7249e01..90a3785 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block,
return page;
 
 failed:
-   BUG();
unlock_page(page);
page_cache_release(page);
+   BUG();
return NULL;
 }
 
diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..2dd48c1 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1604,11 +1604,16 @@ void __init kmem_cache_init(void)
/* 6) resize the head arrays to their final sizes */
{
struct kmem_cache *cachep;
+   int fail = 0;
mutex_lock(cache_chain_mutex);
list_for_each_entry(cachep, cache_chain, next)
-   if (enable_cpucache(cachep))
+   if (enable_cpucache(cachep)) {
+   fail = 1;
+   mutex_unlock(cache_chain_mutex);
BUG();
-   mutex_unlock(cache_chain_mutex);
+   }
+   if (fail != 1)
+   mutex_unlock(cache_chain_mutex);
}
 
/* Annotate slab for lockdep -- annotate the malloc caches */
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index 657ee69..e551b0b 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -752,8 +752,11 @@ all_acked:
sp-call = call;
rxrpc_get_call(call);
spin_lock_bh(call-lock);
-   if (rxrpc_queue_rcv_skb(call, skb, true, true)  0)
+   if (rxrpc_queue_rcv_skb(call, skb, true, true)  0) {
+   spin_unlock_bh(call-lock);
BUG();
+   goto process_further;
+   }
spin_unlock_bh(call-lock);
goto process_further;
}
diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
index 3c04b00..48804e1 100644
--- a/net/rxrpc/ar-call.c
+++ b/net/rxrpc/ar-call.c
@@ -426,9 +426,12 @@ void rxrpc_release_call(struct rxrpc_call *call)
   call-rx_first_oos);
 
spin_lock_bh(call-lock);
-   if (test_and_set_bit(RXRPC_CALL_RELEASED, call-flags))
+   if (test_and_set_bit(RXRPC_CALL_RELEASED, call-flags)) {
+   spin_unlock_bh(call-lock);
BUG

Re: [PATCH] return hidden bug

2007-10-22 Thread Roel Kluin
Ray Lee wrote:

 I'm sorry, perhaps I poured myself a cup of stupid this morning, but
 isn't the above patch effectively introducing a BUG where none could
 be reached before? In other words, for the patch to have zero
 behavioral change, wouldn't it have to remove the BUG() altogether?

True, but obviously not intended. I think the intention was to expose this bug.

-
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] return hidden bug

2007-10-22 Thread Roel Kluin
Ray Lee wrote:

 I'm sorry, perhaps I poured myself a cup of stupid this morning, but
 isn't the above patch effectively introducing a BUG where none could
 be reached before? In other words, for the patch to have zero
 behavioral change, wouldn't it have to remove the BUG() altogether?
 True, but obviously not intended. I think the intention was to expose this 
 bug.
 
 Arguing intentions is very dangerous. I've written code like that
 where the intention is to make it simple to turn a printk into a full
 bug and back and forth during development. At the end of the day, the
 fact remains that you're changing behavior.
 
 Let me turn this around. Do you have an alpha and have you tried out
 your patch? If not, then I'd suggest turning it into a WARN_ON(1)
 instead, as in this specific case you're risking turning what was a
 working system into one that doesn't.

No, I haven't and, I will change it, but it's included with my other
changes. see the reply that I'll write shortly for.
[PATCH retry] return hidden bug and unlock bugs.

Roel


-
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 retry] return hidden bug and unlock bugs

2007-10-22 Thread Roel Kluin
Roel Kluin wrote:
 This patches shouldn't alter behavior when CONFIG_BUG is disabled. It is meant
 as a replacement for the previous patches.
 
 Concerning the patch changing fs/buffer.c, I am still wondering whether
 page_cache_release(page) should be placed before or after the BUG().

...

 @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t 
 dma_addr, size_t size,
   printk(KERN_ERR Bogus pci_unmap_single: dma_addr %lx 
   base %lx size %x\n, dma_addr, arena-dma_base,
  arena-size);
 - return;
   BUG();
 + return;
   }

As suggested by Ray Lee, BUG() is changed into WARN_ON(1)

--
Unlock before BUG(), but don't change behavior in the case when
CONFIG_BUG is disabled. Also changes a return-hidden BUG() in
a WARN_ON(1)

Signed-off-by: Roel Kluin [EMAIL PROTECTED]

diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..d04f151 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR Bogus pci_unmap_single: dma_addr %lx 
base %lx size %x\n, dma_addr, arena-dma_base,
   arena-size);
+   WARN_ON(1);
return;
-   BUG();
}
 
npages = calc_npages((dma_addr  ~PAGE_MASK) + size);
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5a4cc20..12bd0eb 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -357,8 +357,8 @@ void gpmc_cs_free(int cs)
spin_lock(gpmc_mem_lock);
if (cs = GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
printk(KERN_ERR Trying to free non-reserved GPMC CS%d\n, cs);
-   BUG();
spin_unlock(gpmc_mem_lock);
+   BUG();
return;
}
gpmc_cs_disable_mem(cs);
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 88629a3..e72bead 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -100,8 +100,11 @@ static ssize_t vol_attribute_show(struct device *dev,
ret = sprintf(buf, %lld\n, vol-used_bytes);
else if (attr == attr_vol_upd_marker)
ret = sprintf(buf, %d\n, vol-upd_marker);
-   else
+   else {
+   spin_unlock(vol-ubi-volumes_lock);
BUG();
+   return -EINVAL;
+   }
spin_unlock(vol-ubi-volumes_lock);
return ret;
 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e3c8284..f337578 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8722,7 +8722,9 @@ static int ipw_wx_get_freq(struct net_device *dev,
break;
 
default:
+   mutex_unlock(priv-mutex);
BUG();
+   return -EINVAL;
}
} else
wrqu-freq.m = 0;
diff --git a/fs/buffer.c b/fs/buffer.c
index 7249e01..90a3785 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block,
return page;
 
 failed:
-   BUG();
unlock_page(page);
page_cache_release(page);
+   BUG();
return NULL;
 }
 
diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..2dd48c1 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1604,11 +1604,16 @@ void __init kmem_cache_init(void)
/* 6) resize the head arrays to their final sizes */
{
struct kmem_cache *cachep;
+   int fail = 0;
mutex_lock(cache_chain_mutex);
list_for_each_entry(cachep, cache_chain, next)
-   if (enable_cpucache(cachep))
+   if (enable_cpucache(cachep)) {
+   fail = 1;
+   mutex_unlock(cache_chain_mutex);
BUG();
-   mutex_unlock(cache_chain_mutex);
+   }
+   if (fail != 1)
+   mutex_unlock(cache_chain_mutex);
}
 
/* Annotate slab for lockdep -- annotate the malloc caches */
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index 657ee69..e551b0b 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -752,8 +752,11 @@ all_acked:
sp-call = call;
rxrpc_get_call(call);
spin_lock_bh(call-lock);
-   if (rxrpc_queue_rcv_skb(call, skb, true, true)  0)
+   if (rxrpc_queue_rcv_skb(call, skb, true, true)  0) {
+   spin_unlock_bh(call-lock);
BUG();
+   goto process_further;
+   }
spin_unlock_bh(call-lock);
goto

Re: [PATCH] unlock before bug returns

2007-10-22 Thread Roel Kluin
Rene Herman wrote:
 On 10/22/2007 02:40 PM, Pekka Enberg wrote:
 
 NAK. This will cause double-unlock when CONFIG_BUG is disabled. It's
 incorrect to assume that BUG() will always terminate the current
 process.
 
 (which by the way also means that the return; delete from your
 original patch changes behaviour for !CONFIG_BUG, and probably not for
 the better).
 
 Rene.

Thanks for your comments. A patch containing this suggestion is:

[PATCH retry] return hidden bug and unlock bugs.

Roel
-
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] unlock 12c_mutex before return

2007-10-22 Thread Roel Kluin
unlock 12c_mutex before return -EINVAL

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/media/dvb/dvb-usb/au6610.c 
b/drivers/media/dvb/dvb-usb/au6610.c
index 18e0b16..31f47c7 100644
--- a/drivers/media/dvb/dvb-usb/au6610.c
+++ b/drivers/media/dvb/dvb-usb/au6610.c
@@ -82,8 +82,10 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
if (mutex_lock_interruptible(d-i2c_mutex)  0)
return -EAGAIN;
 
-   if (num  2)
+   if (num  2) {
+mutex_unlock(d-i2c_mutex);
return -EINVAL;
+   }
 
for (i = 0; i  num; i++) {
/* write/read request */
-
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] unlock 12c_mutex before return

2007-10-22 Thread Roel Kluin
And a similar one in drivers/media/dvb/dvb-usb/gl861.c
--
unlock 12c_mutex before return -EINVAL

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/media/dvb/dvb-usb/gl861.c 
b/drivers/media/dvb/dvb-usb/gl861.c
index f01d99c..20c340a 100644
--- a/drivers/media/dvb/dvb-usb/gl861.c
+++ b/drivers/media/dvb/dvb-usb/gl861.c
@@ -59,8 +59,10 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
if (mutex_lock_interruptible(d-i2c_mutex)  0)
return -EAGAIN;
 
-   if (num  2)
+   if (num  2) {
+   mutex_unlock(d-i2c_mutex);
return -EINVAL;
+   }
 
for (i = 0; i  num; i++) {
/* write/read request */

-
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] several returns before unlocking in lmc_ioctl

2007-10-22 Thread Roel Kluin
Several returns before unlocking in lmc_ioctl

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 5ea8772..af7b3e4 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  * To date internally, just copy this out to the user.
  */
 case LMCIOCGINFO: /*fold01*/
-if (copy_to_user(ifr-ifr_data, sc-ictl, sizeof (lmc_ctl_t)))
-return -EFAULT;
-ret = 0;
+   if (copy_to_user(ifr-ifr_data, sc-ictl, sizeof(lmc_ctl_t)))
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCSINFO: /*fold01*/
@@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(ctl, ifr-ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(ctl, ifr-ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 sc-lmc_media-set_status (sc, ctl);
 
@@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
break;
}
 
-   if (copy_from_user(new_type, ifr-ifr_data, sizeof(u_int16_t)))
-return -EFAULT;
+   if (copy_from_user(new_type, ifr-ifr_data, sizeof(u_int16_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 
if (new_type == old_type)
@@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 sc-lmc_xinfo.Magic1 = 0xDEADBEEF;
 
 if (copy_to_user(ifr-ifr_data, sc-lmc_xinfo,
- sizeof (struct lmc_xinfo)))
-return -EFAULT;
-ret = 0;
+   sizeof(struct lmc_xinfo))) {
+   ret = -EFAULT;
+   else
+   ret = 0;
 
 break;
 
@@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 if (copy_to_user(ifr-ifr_data, sc-stats,
  sizeof (struct lmc_statistics)))
-return -EFAULT;
-
-ret = 0;
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCCLEARLMCSTATS: /*fold01*/
@@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(ctl, ifr-ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(ctl, ifr-ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 sc-lmc_media-set_circuit_type(sc, ctl.circuit_type);
 sc-ictl.circuit_type = ctl.circuit_type;
 ret = 0;
@@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 #ifdef DEBUG
 case LMCIOCDUMPEVENTLOG:
-if (copy_to_user(ifr-ifr_data, lmcEventLogIndex, sizeof (u32)))
-return -EFAULT;
+   if (copy_to_user(ifr-ifr_data, lmcEventLogIndex, sizeof(u32))) {
+   ret = -EFAULT;
+   break;
+   }
 if (copy_to_user(ifr-ifr_data + sizeof (u32), lmcEventLogBuf, sizeof 
(lmcEventLogBuf)))
-return -EFAULT;
+   ret = -EFAULT;
+   else
+   ret = 0;
 
-ret = 0;
 break;
 #endif /* end ifdef _DBG_EVENTLOG */
 case LMCIOCT1CONTROL: /*fold01*/
@@ -346,8 +357,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  */
 netif_stop_queue(dev);
 
-if (copy_from_user(xc, ifr-ifr_data, sizeof (struct 
lmc_xilinx_control)))
-return -EFAULT;
+   if (copy_from_user(xc, ifr-ifr_data, sizeof(struct 
lmc_xilinx_control))) {
+   ret = -EFAULT;
+   break;
+   }
 switch(xc.command){
 case lmc_xilinx_reset: /*fold02*/
 {
@@ -618,8 +631,8 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 }
 
 spin_unlock_irqrestore(sc-lmc_lock, flags); /*fold01*/
-
-lmc_trace(dev, lmc_ioctl out);
+if (ret = 0)
+   lmc_trace(dev, lmc_ioctl out);
 
 return ret;
 }
-
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] Unlock in iTCO_wdt_start when reboot is disabled

2007-10-22 Thread Roel Kluin
commit 61c31efe4e9c34531666a6c5857ecd19c8db
Author: Roel Kluin [EMAIL PROTECTED]
Date:   Tue Oct 23 03:08:27 2007 +0200

Unlock in iTCO_wdt_start when reboot is disabled

Signed-off-by: Roel Kluin [EMAIL PROTECTED]

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index cd5a565..185c093 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -300,6 +300,7 @@ static int iTCO_wdt_start(void)
 
/* disable chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit()) {
+   spin_unlock(iTCO_wdt_private.io_lock);
printk(KERN_ERR PFX failed to reset NO_REBOOT flag, reboot 
disabled by hardware\n);
return -EIO;
}
-
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] Unlock before return in p9_mux_poll_start

2007-10-22 Thread Roel Kluin
commit 9f822afc65cc094c905901f9d92bf25042f9ed22
Author: Roel Kluin [EMAIL PROTECTED]
Date:   Tue Oct 23 03:15:55 2007 +0200

Unlock before return in p9_mux_poll_start

Signed-off-by: Roel Kluin [EMAIL PROTECTED]

diff --git a/net/9p/mux.c b/net/9p/mux.c
index f140147..c9f0805 100644
--- a/net/9p/mux.c
+++ b/net/9p/mux.c
@@ -222,8 +222,10 @@ static int p9_mux_poll_start(struct p9_conn *m)
}
 
if (i = ARRAY_SIZE(p9_mux_poll_tasks)) {
-   if (vptlast == NULL)
+   if (vptlast == NULL) {
+   mutex_unlock(p9_mux_task_lock);
return -ENOMEM;
+   }
 
P9_DPRINTK(P9_DEBUG_MUX, put in proc %d\n, i);
list_add(m-mux_list, vptlast-mux_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] several returns before unlocking in lmc_ioctl

2007-10-22 Thread Roel Kluin
I think we should keep the lmc_tracing. Use this patch instead.

--
Several returns before unlocking in lmc_ioctl

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 5ea8772..64eb578 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  * To date internally, just copy this out to the user.
  */
 case LMCIOCGINFO: /*fold01*/
-if (copy_to_user(ifr-ifr_data, sc-ictl, sizeof (lmc_ctl_t)))
-return -EFAULT;
-ret = 0;
+   if (copy_to_user(ifr-ifr_data, sc-ictl, sizeof(lmc_ctl_t)))
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCSINFO: /*fold01*/
@@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(ctl, ifr-ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(ctl, ifr-ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 sc-lmc_media-set_status (sc, ctl);
 
@@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
break;
}
 
-   if (copy_from_user(new_type, ifr-ifr_data, sizeof(u_int16_t)))
-return -EFAULT;
+   if (copy_from_user(new_type, ifr-ifr_data, sizeof(u_int16_t))) {
+   ret = -EFAULT;
+   break;
+   }
 
 
if (new_type == old_type)
@@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 sc-lmc_xinfo.Magic1 = 0xDEADBEEF;
 
 if (copy_to_user(ifr-ifr_data, sc-lmc_xinfo,
- sizeof (struct lmc_xinfo)))
-return -EFAULT;
-ret = 0;
+   sizeof(struct lmc_xinfo))) {
+   ret = -EFAULT;
+   else
+   ret = 0;
 
 break;
 
@@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 if (copy_to_user(ifr-ifr_data, sc-stats,
  sizeof (struct lmc_statistics)))
-return -EFAULT;
-
-ret = 0;
+   ret = -EFAULT;
+   else
+   ret = 0;
 break;
 
 case LMCIOCCLEARLMCSTATS: /*fold01*/
@@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 break;
 }
 
-if (copy_from_user(ctl, ifr-ifr_data, sizeof (lmc_ctl_t)))
-return -EFAULT;
+   if (copy_from_user(ctl, ifr-ifr_data, sizeof(lmc_ctl_t))) {
+   ret = -EFAULT;
+   break;
+   }
 sc-lmc_media-set_circuit_type(sc, ctl.circuit_type);
 sc-ictl.circuit_type = ctl.circuit_type;
 ret = 0;
@@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
 
 #ifdef DEBUG
 case LMCIOCDUMPEVENTLOG:
-if (copy_to_user(ifr-ifr_data, lmcEventLogIndex, sizeof (u32)))
-return -EFAULT;
+   if (copy_to_user(ifr-ifr_data, lmcEventLogIndex, sizeof(u32))) {
+   ret = -EFAULT;
+   break;
+   }
 if (copy_to_user(ifr-ifr_data + sizeof (u32), lmcEventLogBuf, sizeof 
(lmcEventLogBuf)))
-return -EFAULT;
+   ret = -EFAULT;
+   else
+   ret = 0;
 
-ret = 0;
 break;
 #endif /* end ifdef _DBG_EVENTLOG */
 case LMCIOCT1CONTROL: /*fold01*/
@@ -346,8 +357,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, 
int cmd) /*fold00*/
  */
 netif_stop_queue(dev);
 
-if (copy_from_user(xc, ifr-ifr_data, sizeof (struct 
lmc_xilinx_control)))
-return -EFAULT;
+   if (copy_from_user(xc, ifr-ifr_data, sizeof(struct 
lmc_xilinx_control))) {
+   ret = -EFAULT;
+   break;
+   }
 switch(xc.command){
 case lmc_xilinx_reset: /*fold02*/
 {

-
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] unlock before bug returns

2007-10-21 Thread Roel Kluin
Roel Kluin wrote:

> unlock before bug returns

>   if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
>   printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
> - BUG();
>   spin_unlock(_mem_lock);
> - return;
> + BUG();


should we bother to unlock before panicking, or is the unlock not required 
either?

-
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] unlock before bug returns

2007-10-21 Thread Roel Kluin
I think the unlock should be before bugging?

--
unlock before bug returns

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5a4cc20..c910170 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -357,9 +357,8 @@ void gpmc_cs_free(int cs)
spin_lock(_mem_lock);
if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
-   BUG();
spin_unlock(_mem_lock);
-   return;
+   BUG();
}
gpmc_cs_disable_mem(cs);
release_resource(_cs_mem[cs]);
-
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] return hidden bug

2007-10-21 Thread Roel Kluin
Rik van Riel wrote:
> On Mon, 22 Oct 2007 03:05:05 +0200
> Roel Kluin <[EMAIL PROTECTED]> wrote:
> 
>> return hidden bug
>> 
>> Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
>>
>> diff --git a/arch/alpha/kernel/pci_iommu.c
>> b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644
>> --- a/arch/alpha/kernel/pci_iommu.c
>> +++ b/arch/alpha/kernel/pci_iommu.c
>> @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t
>> dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single:
>> dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base,
>> arena->size);
>> -return;
>>  BUG();
>> +return;
>>  }
>>  
>>  npages = calc_npages((dma_addr & ~PAGE_MASK) + size);
> 
> BUG() will terminate the process that runs into it, so you can
> just remove the return alltogether.  If BUG() is hit, the return
> will never be reached.
> 
---
hidden bug returns

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..ca55c33 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,7 +365,6 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx "
   " base %lx size %x\n", dma_addr, arena->dma_base,
   arena->size);
-   return;
BUG();
}
 

-
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] return hidden bug

2007-10-21 Thread Roel Kluin
return hidden bug

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>

diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..6a69425 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx "
   " base %lx size %x\n", dma_addr, arena->dma_base,
   arena->size);
-   return;
BUG();
+   return;
}
 
npages = calc_npages((dma_addr & ~PAGE_MASK) + size);
-
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] errors with assignments in if

2007-10-21 Thread Roel Kluin
Roel Kluin wrote:
> I am not entirely certain about the third one:
> 
> from fs/udf/udf_sb.h:
> 
> #define UDF_SB_VAT(X)   ( UDF_SB(X)->s_vat )
> 
> if it's the desired behavior then I think this should at least be changed to
> 
> UDF_SB_VAT(sb) = udf_iget(sb, ino);
> if (!(UDF_SB_VAT(sb)))

On a second glance, I think it's the desired behavior. Use this patch instead.
---
Errors with assignments in ifs

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>

diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index d9af436..e6e85b7 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -651,7 +651,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask,
break;
case CM_SYSCLKOUT_SEL1:
div_addr = (u32)_CLKOUT_CTRL;
-   if ((div_off == 3) || (div_off = 11))
+   if ((div_off == 3) || (div_off == 11))
mask= 0x3;
break;
case CM_CORE_SEL1:
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 948a9b2..ed610ed 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -883,7 +883,7 @@ setup_elsa_isa(struct IsdnCard *card)
val += 'A' - 3;
if (val == 'B' || val == 'C')
val ^= 1;
-   if ((cs->subtyp == ELSA_PCFPRO) && (val = 'G'))
+   if ((cs->subtyp == ELSA_PCFPRO) && (val == 'G'))
val = 'C';
printk(KERN_INFO
   "Elsa: %s found at %#lx Rev.:%c IRQ %d\n",

-
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] errors with assignments in if

2007-10-21 Thread Roel Kluin
I am not entirely certain about the third one:

from fs/udf/udf_sb.h:

#define UDF_SB_VAT(X)   ( UDF_SB(X)->s_vat )

if it's the desired behavior then I think this should at least be changed to

UDF_SB_VAT(sb) = udf_iget(sb, ino);
if (!(UDF_SB_VAT(sb)))

---
Errors with assignments in ifs

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index d9af436..e6e85b7 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -651,7 +651,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask,
break;
case CM_SYSCLKOUT_SEL1:
div_addr = (u32)_CLKOUT_CTRL;
-   if ((div_off == 3) || (div_off = 11))
+   if ((div_off == 3) || (div_off == 11))
mask= 0x3;
break;
case CM_CORE_SEL1:
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 948a9b2..ed610ed 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -883,7 +883,7 @@ setup_elsa_isa(struct IsdnCard *card)
val += 'A' - 3;
if (val == 'B' || val == 'C')
val ^= 1;
-   if ((cs->subtyp == ELSA_PCFPRO) && (val = 'G'))
+   if ((cs->subtyp == ELSA_PCFPRO) && (val == 'G'))
val = 'C';
printk(KERN_INFO
   "Elsa: %s found at %#lx Rev.:%c IRQ %d\n",
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4360c7a..353c9e8 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1308,7 +1308,7 @@ static int udf_load_partition(struct super_block *sb, 
kernel_lb_addr *fileset)
if (j == UDF_SB_NUMPARTS(sb))
return 1;
 
-   if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
+   if (!(UDF_SB_VAT(sb) == udf_iget(sb, ino)))
return 1;
 
if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
-
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] errors with assignments in if

2007-10-21 Thread Roel Kluin
I am not entirely certain about the third one:

from fs/udf/udf_sb.h:

#define UDF_SB_VAT(X)   ( UDF_SB(X)-s_vat )

if it's the desired behavior then I think this should at least be changed to

UDF_SB_VAT(sb) = udf_iget(sb, ino);
if (!(UDF_SB_VAT(sb)))

---
Errors with assignments in ifs

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index d9af436..e6e85b7 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -651,7 +651,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask,
break;
case CM_SYSCLKOUT_SEL1:
div_addr = (u32)PRCM_CLKOUT_CTRL;
-   if ((div_off == 3) || (div_off = 11))
+   if ((div_off == 3) || (div_off == 11))
mask= 0x3;
break;
case CM_CORE_SEL1:
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 948a9b2..ed610ed 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -883,7 +883,7 @@ setup_elsa_isa(struct IsdnCard *card)
val += 'A' - 3;
if (val == 'B' || val == 'C')
val ^= 1;
-   if ((cs-subtyp == ELSA_PCFPRO)  (val = 'G'))
+   if ((cs-subtyp == ELSA_PCFPRO)  (val == 'G'))
val = 'C';
printk(KERN_INFO
   Elsa: %s found at %#lx Rev.:%c IRQ %d\n,
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4360c7a..353c9e8 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1308,7 +1308,7 @@ static int udf_load_partition(struct super_block *sb, 
kernel_lb_addr *fileset)
if (j == UDF_SB_NUMPARTS(sb))
return 1;
 
-   if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
+   if (!(UDF_SB_VAT(sb) == udf_iget(sb, ino)))
return 1;
 
if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
-
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] errors with assignments in if

2007-10-21 Thread Roel Kluin
Roel Kluin wrote:
 I am not entirely certain about the third one:
 
 from fs/udf/udf_sb.h:
 
 #define UDF_SB_VAT(X)   ( UDF_SB(X)-s_vat )
 
 if it's the desired behavior then I think this should at least be changed to
 
 UDF_SB_VAT(sb) = udf_iget(sb, ino);
 if (!(UDF_SB_VAT(sb)))

On a second glance, I think it's the desired behavior. Use this patch instead.
---
Errors with assignments in ifs

Signed-off-by: Roel Kluin [EMAIL PROTECTED]

diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index d9af436..e6e85b7 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -651,7 +651,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask,
break;
case CM_SYSCLKOUT_SEL1:
div_addr = (u32)PRCM_CLKOUT_CTRL;
-   if ((div_off == 3) || (div_off = 11))
+   if ((div_off == 3) || (div_off == 11))
mask= 0x3;
break;
case CM_CORE_SEL1:
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 948a9b2..ed610ed 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -883,7 +883,7 @@ setup_elsa_isa(struct IsdnCard *card)
val += 'A' - 3;
if (val == 'B' || val == 'C')
val ^= 1;
-   if ((cs-subtyp == ELSA_PCFPRO)  (val = 'G'))
+   if ((cs-subtyp == ELSA_PCFPRO)  (val == 'G'))
val = 'C';
printk(KERN_INFO
   Elsa: %s found at %#lx Rev.:%c IRQ %d\n,

-
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] return hidden bug

2007-10-21 Thread Roel Kluin
return hidden bug

Signed-off-by: Roel Kluin [EMAIL PROTECTED]

diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..6a69425 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR Bogus pci_unmap_single: dma_addr %lx 
base %lx size %x\n, dma_addr, arena-dma_base,
   arena-size);
-   return;
BUG();
+   return;
}
 
npages = calc_npages((dma_addr  ~PAGE_MASK) + size);
-
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] return hidden bug

2007-10-21 Thread Roel Kluin
Rik van Riel wrote:
 On Mon, 22 Oct 2007 03:05:05 +0200
 Roel Kluin [EMAIL PROTECTED] wrote:
 
 return hidden bug
 
 Signed-off-by: Roel Kluin [EMAIL PROTECTED]

 diff --git a/arch/alpha/kernel/pci_iommu.c
 b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644
 --- a/arch/alpha/kernel/pci_iommu.c
 +++ b/arch/alpha/kernel/pci_iommu.c
 @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t
 dma_addr, size_t size, printk(KERN_ERR Bogus pci_unmap_single:
 dma_addr %lx   base %lx size %x\n, dma_addr, arena-dma_base,
 arena-size);
 -return;
  BUG();
 +return;
  }
  
  npages = calc_npages((dma_addr  ~PAGE_MASK) + size);
 
 BUG() will terminate the process that runs into it, so you can
 just remove the return alltogether.  If BUG() is hit, the return
 will never be reached.
 
---
hidden bug returns

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c4707..ca55c33 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -365,7 +365,6 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, 
size_t size,
printk(KERN_ERR Bogus pci_unmap_single: dma_addr %lx 
base %lx size %x\n, dma_addr, arena-dma_base,
   arena-size);
-   return;
BUG();
}
 

-
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] unlock before bug returns

2007-10-21 Thread Roel Kluin
I think the unlock should be before bugging?

--
unlock before bug returns

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5a4cc20..c910170 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -357,9 +357,8 @@ void gpmc_cs_free(int cs)
spin_lock(gpmc_mem_lock);
if (cs = GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
printk(KERN_ERR Trying to free non-reserved GPMC CS%d\n, cs);
-   BUG();
spin_unlock(gpmc_mem_lock);
-   return;
+   BUG();
}
gpmc_cs_disable_mem(cs);
release_resource(gpmc_cs_mem[cs]);
-
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] unlock before bug returns

2007-10-21 Thread Roel Kluin
Roel Kluin wrote:

 unlock before bug returns

   if (cs = GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
   printk(KERN_ERR Trying to free non-reserved GPMC CS%d\n, cs);
 - BUG();
   spin_unlock(gpmc_mem_lock);
 - return;
 + BUG();


should we bother to unlock before panicking, or is the unlock not required 
either?

-
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 9/9] RT: Only dirty a cacheline if the priority is actually changing

2007-10-19 Thread Roel Kluin
Gregory Haskins wrote:
> We can avoid dirtying a rq related cacheline with a simple check, so why not.
> 
> Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
> ---
> 
>  0 files changed, 0 insertions(+), 0 deletions(-)

I think you wanted a patch here?
-
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 9/9] RT: Only dirty a cacheline if the priority is actually changing

2007-10-19 Thread Roel Kluin
Gregory Haskins wrote:
 We can avoid dirtying a rq related cacheline with a simple check, so why not.
 
 Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
 ---
 
  0 files changed, 0 insertions(+), 0 deletions(-)

I think you wanted a patch here?
-
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 1/4] fix not-and/or errors

2007-10-18 Thread Roel Kluin
previously applied changes removed and changed as suggested.

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 7dce318..752ae26 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int 
mask)
 
switch (mask) {
case MLED_ON:
-   out = !out & 0x1;
+   out = !out;
break;
case GLED_ON:
out = (out & 0x1) + 1;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 73c44cb..289165e 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -2882,7 +2882,8 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned 
int cmd_in, unsigned lon
!(STp->use_pf & PF_TESTED)) {
/* Try the other possible state of Page Format 
if not
   already tried */
-   STp->use_pf = !STp->use_pf | PF_TESTED;
+   STp->use_pf ^= PF_TESTED | USE_PF; /* remove 
USE_PF, set *
+   * PF_TESTED 
*/
st_release_request(SRpnt);
SRpnt = NULL;
return st_int_ioctl(STp, cmd_in, arg);

-
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 1/4] fix not-and/or errors

2007-10-18 Thread Roel Kluin
Al Viro wrote:
> On Wed, Oct 17, 2007 at 03:46:43PM +0200, Roel Kluin wrote:
>> +++ b/drivers/misc/asus-laptop.c
>> @@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, 
>> int mask)
>>  
>>  switch (mask) {
>>  case MLED_ON:
>> -out = !out & 0x1;
>> +out = !(out & 0x1);
> 
> Not sure if that's what had been intended.

It seems to me if I look at the code, that it's intended to make a bool out of 
'out'. That's
nonsense because of the precedence the ! will turn it into a boolean before the 
& 0x1.

x = !x & y behaves like x = !x for y != 0. 
for y = 1 the behavior is even the same for x = !(x & y)
so it does not matter in this case, except for clarity. I'll make it out = !out.

> 
>> @@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, 
>> unsigned int cmd_in, unsigned lon
>>  !(STp->use_pf & PF_TESTED)) {
>>  /* Try the other possible state of Page Format 
>> if not
>> already tried */
>> -STp->use_pf = !STp->use_pf | PF_TESTED;
>> +STp->use_pf = !(STp->use_pf | PF_TESTED);
> 
> Wrong.  This code, ugly as it is, happens to be correct.  Replacement
> isn't.  I would rewrite it as ^= PF_TESTED | USE_PF; /* remove USE_PF, set *
>     * PF_TESTED */
> 
> The rest is covered by Alexey's patch and one I'd posted as followup.


ok, thanks, I'll correct and omit these in my follow up patch.

Roel
-
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 4/4 returns] fix not-and/or errors

2007-10-18 Thread Roel Kluin
Thanks for comments, here a second version with previously covered commits 
removed

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/arm/mach-pxa/mfp.c b/arch/arm/mach-pxa/mfp.c
index 5cd3cad..7229319 100644
--- a/arch/arm/mach-pxa/mfp.c
+++ b/arch/arm/mach-pxa/mfp.c
@@ -199,7 +199,7 @@ void pxa3xx_mfp_set_edge(int mfp, int edge)
 
mfpr_val &= ~MFPR_EDGE_MASK;
mfpr_val |= (edge & 0x3u) << MFPR_ERE_OFFSET;
-   mfpr_val |= (!edge & 0x1) << MFPR_EC_OFFSET;
+   mfpr_val |= (!(edge & 0x1)) << MFPR_EC_OFFSET;
 
mfpr_writel(mfpr_off, mfpr_val);
mfpr_sync();
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 958bac1..e8f9c85 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -89,7 +89,7 @@ static irqreturn_t dma_tei(int irq, void *dev_id)
 
 static int sh_dmac_request_dma(struct dma_channel *chan)
 {
-   if (unlikely(!chan->flags & DMA_TEI_CAPABLE))
+   if (unlikely(!(chan->flags & DMA_TEI_CAPABLE)))
return 0;
 
return request_irq(get_dmte_irq(chan->chan), dma_tei,
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index d915fec..1db2055 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -596,7 +596,7 @@ write_led(const char __user * buffer, unsigned long count,
(led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask);
 
if (invert) /* invert target value */
-   led_out = !led_out & 0x1;
+   led_out = !led_out;
 
if (!write_acpi_int(hotk->handle, ledname, led_out, NULL))
printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9b2c0f7..3762ce2 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -420,8 +420,7 @@ static int acpi_battery_update(struct acpi_battery *battery,
result = acpi_battery_get_status(battery);
if (result)
goto end;
-   if ((!battery->flags.battery_present_prev & 
acpi_battery_present(battery))
-   || (battery->flags.battery_present_prev & 
!acpi_battery_present(battery))) {
+   if (battery->flags.battery_present_prev != 
acpi_battery_present(battery)) {
result = acpi_battery_init_update(battery);
if (result)
goto end;
@@ -448,10 +447,7 @@ static void acpi_battery_notify_update(struct acpi_battery 
*battery)
return;
}
 
-   if ((!battery->flags.battery_present_prev &
-acpi_battery_present(battery)) ||
-   (battery->flags.battery_present_prev &
-!acpi_battery_present(battery))) {
+   if (battery->flags.battery_present_prev != 
acpi_battery_present(battery)) {
battery->flags.init_update = 1;
} else {
battery->flags.update[ACPI_BATTERY_INFO] = 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 4/4 returns] fix not-and/or errors

2007-10-18 Thread Roel Kluin
Thanks for comments, here a second version with previously covered commits 
removed

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/arm/mach-pxa/mfp.c b/arch/arm/mach-pxa/mfp.c
index 5cd3cad..7229319 100644
--- a/arch/arm/mach-pxa/mfp.c
+++ b/arch/arm/mach-pxa/mfp.c
@@ -199,7 +199,7 @@ void pxa3xx_mfp_set_edge(int mfp, int edge)
 
mfpr_val = ~MFPR_EDGE_MASK;
mfpr_val |= (edge  0x3u)  MFPR_ERE_OFFSET;
-   mfpr_val |= (!edge  0x1)  MFPR_EC_OFFSET;
+   mfpr_val |= (!(edge  0x1))  MFPR_EC_OFFSET;
 
mfpr_writel(mfpr_off, mfpr_val);
mfpr_sync();
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 958bac1..e8f9c85 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -89,7 +89,7 @@ static irqreturn_t dma_tei(int irq, void *dev_id)
 
 static int sh_dmac_request_dma(struct dma_channel *chan)
 {
-   if (unlikely(!chan-flags  DMA_TEI_CAPABLE))
+   if (unlikely(!(chan-flags  DMA_TEI_CAPABLE)))
return 0;
 
return request_irq(get_dmte_irq(chan-chan), dma_tei,
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index d915fec..1db2055 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -596,7 +596,7 @@ write_led(const char __user * buffer, unsigned long count,
(led_out) ? (hotk-status | ledmask) : (hotk-status  ~ledmask);
 
if (invert) /* invert target value */
-   led_out = !led_out  0x1;
+   led_out = !led_out;
 
if (!write_acpi_int(hotk-handle, ledname, led_out, NULL))
printk(KERN_WARNING Asus ACPI: LED (%s) write failed\n,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9b2c0f7..3762ce2 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -420,8 +420,7 @@ static int acpi_battery_update(struct acpi_battery *battery,
result = acpi_battery_get_status(battery);
if (result)
goto end;
-   if ((!battery-flags.battery_present_prev  
acpi_battery_present(battery))
-   || (battery-flags.battery_present_prev  
!acpi_battery_present(battery))) {
+   if (battery-flags.battery_present_prev != 
acpi_battery_present(battery)) {
result = acpi_battery_init_update(battery);
if (result)
goto end;
@@ -448,10 +447,7 @@ static void acpi_battery_notify_update(struct acpi_battery 
*battery)
return;
}
 
-   if ((!battery-flags.battery_present_prev 
-acpi_battery_present(battery)) ||
-   (battery-flags.battery_present_prev 
-!acpi_battery_present(battery))) {
+   if (battery-flags.battery_present_prev != 
acpi_battery_present(battery)) {
battery-flags.init_update = 1;
} else {
battery-flags.update[ACPI_BATTERY_INFO] = 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 1/4] fix not-and/or errors

2007-10-18 Thread Roel Kluin
Al Viro wrote:
 On Wed, Oct 17, 2007 at 03:46:43PM +0200, Roel Kluin wrote:
 +++ b/drivers/misc/asus-laptop.c
 @@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, 
 int mask)
  
  switch (mask) {
  case MLED_ON:
 -out = !out  0x1;
 +out = !(out  0x1);
 
 Not sure if that's what had been intended.

It seems to me if I look at the code, that it's intended to make a bool out of 
'out'. That's
nonsense because of the precedence the ! will turn it into a boolean before the 
 0x1.

x = !x  y behaves like x = !x for y != 0. 
for y = 1 the behavior is even the same for x = !(x  y)
so it does not matter in this case, except for clarity. I'll make it out = !out.

 
 @@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, 
 unsigned int cmd_in, unsigned lon
  !(STp-use_pf  PF_TESTED)) {
  /* Try the other possible state of Page Format 
 if not
 already tried */
 -STp-use_pf = !STp-use_pf | PF_TESTED;
 +STp-use_pf = !(STp-use_pf | PF_TESTED);
 
 Wrong.  This code, ugly as it is, happens to be correct.  Replacement
 isn't.  I would rewrite it as ^= PF_TESTED | USE_PF; /* remove USE_PF, set *
 * PF_TESTED */
 
 The rest is covered by Alexey's patch and one I'd posted as followup.


ok, thanks, I'll correct and omit these in my follow up patch.

Roel
-
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 1/4] fix not-and/or errors

2007-10-18 Thread Roel Kluin
previously applied changes removed and changed as suggested.

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 7dce318..752ae26 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int 
mask)
 
switch (mask) {
case MLED_ON:
-   out = !out  0x1;
+   out = !out;
break;
case GLED_ON:
out = (out  0x1) + 1;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 73c44cb..289165e 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -2882,7 +2882,8 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned 
int cmd_in, unsigned lon
!(STp-use_pf  PF_TESTED)) {
/* Try the other possible state of Page Format 
if not
   already tried */
-   STp-use_pf = !STp-use_pf | PF_TESTED;
+   STp-use_pf ^= PF_TESTED | USE_PF; /* remove 
USE_PF, set *
+   * PF_TESTED 
*/
st_release_request(SRpnt);
SRpnt = NULL;
return st_int_ioctl(STp, cmd_in, arg);

-
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 4/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
if(!x & y) should either be if(!(x & y)) or if(!x && y)
I made changes as seemed appropriate, but please review

    Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/arm/mach-pxa/mfp.c b/arch/arm/mach-pxa/mfp.c
index 5cd3cad..7229319 100644
--- a/arch/arm/mach-pxa/mfp.c
+++ b/arch/arm/mach-pxa/mfp.c
@@ -199,7 +199,7 @@ void pxa3xx_mfp_set_edge(int mfp, int edge)
 
mfpr_val &= ~MFPR_EDGE_MASK;
mfpr_val |= (edge & 0x3u) << MFPR_ERE_OFFSET;
-   mfpr_val |= (!edge & 0x1) << MFPR_EC_OFFSET;
+   mfpr_val |= (!(edge & 0x1)) << MFPR_EC_OFFSET;
 
mfpr_writel(mfpr_off, mfpr_val);
mfpr_sync();
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 3d45d24..7d78d22 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -858,7 +858,7 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu)
lsapic = (struct acpi_madt_local_sapic *)obj->buffer.pointer;
 
if ((lsapic->header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) ||
-   (!lsapic->lapic_flags & ACPI_MADT_ENABLED)) {
+   (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))) {
kfree(buffer.pointer);
return -EINVAL;
}
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 958bac1..e8f9c85 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -89,7 +89,7 @@ static irqreturn_t dma_tei(int irq, void *dev_id)
 
 static int sh_dmac_request_dma(struct dma_channel *chan)
 {
-   if (unlikely(!chan->flags & DMA_TEI_CAPABLE))
+   if (unlikely(!(chan->flags & DMA_TEI_CAPABLE)))
return 0;
 
return request_irq(get_dmte_irq(chan->chan), dma_tei,
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index cd8c740..a2cf955 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -1070,7 +1070,7 @@ static int set_rtc_mmss(unsigned long nowtime)
 * Not having a register set can lead to trouble.
 * Also starfire doesn't have a tod clock.
 */
-   if (!mregs && !dregs & !bregs)
+   if (!mregs && !dregs && !bregs)
return -1;
 
if (mregs) {
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index d915fec..5a67a87 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -596,7 +596,7 @@ write_led(const char __user * buffer, unsigned long count,
(led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask);
 
if (invert) /* invert target value */
-   led_out = !led_out & 0x1;
+   led_out = !(led_out & 0x1);
 
if (!write_acpi_int(hotk->handle, ledname, led_out, NULL))
printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9b2c0f7..48fbe9e 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -420,8 +420,8 @@ static int acpi_battery_update(struct acpi_battery *battery,
result = acpi_battery_get_status(battery);
if (result)
goto end;
-   if ((!battery->flags.battery_present_prev & 
acpi_battery_present(battery))
-   || (battery->flags.battery_present_prev & 
!acpi_battery_present(battery))) {
+   if ((!battery->flags.battery_present_prev && 
acpi_battery_present(battery))
+   || (battery->flags.battery_present_prev && 
!acpi_battery_present(battery))) {
result = acpi_battery_init_update(battery);
if (result)
goto end;
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 9f4e67e..37079d9 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -660,11 +660,11 @@ static int pt_open(struct inode *inode, struct file *file)
pt_identify(tape);
 
err = -ENODEV;
-   if (!tape->flags & PT_MEDIA)
+   if (!(tape->flags & PT_MEDIA))
goto out;
 
err = -EROFS;
-   if ((!tape->flags & PT_WRITE_OK) && (file->f_mode & 2))
+   if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2))
goto out;
 
if (!(iminor(inode) & 128))

-
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 2/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
Roel Kluin wrote:
> if(!x & y) should either be if(!(x & y)) or if(!x && y)
> I made changes as seemed appropriate, but please review
> 
> several changes to drivers/net/
> 
> Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
> 
hmmm forgot to place '---' here, should I resend?
> diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
> index cf70522..14141a5 100644
> --- a/drivers/net/e1000e/82571.c
> +++ b/drivers/net/e1000e/82571.c


-
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 3/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
commit 568f9787e58b4d24be50ab2abf1c7dab12a9ef2c
Author: Roel Kluin <[EMAIL PROTECTED]>
Date:   Wed Oct 17 15:16:44 2007 +0200

if(!x & y) should either be if(!(x & y)) or if(!x && y)
I made changes as seemed appropriate, but please review

several changes to drivers/isdn/
    
    Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
index ee2b0b9..8325022 100644
--- a/drivers/isdn/act2000/module.c
+++ b/drivers/isdn/act2000/module.c
@@ -310,7 +310,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
}
break;
case ISDN_CMD_DIAL:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c->arg & 0x0f)))
break;
@@ -339,7 +339,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
}
return ret;
case ISDN_CMD_ACCEPTD:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c->arg & 0x0f)))
break;
@@ -347,11 +347,11 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
actcapi_select_b2_protocol_req(card, chan);
return 0;
case ISDN_CMD_ACCEPTB:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
return 0;
case ISDN_CMD_HANGUP:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c->arg & 0x0f)))
break;
@@ -366,7 +366,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
}
return 0;
case ISDN_CMD_SETEAZ:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c->arg & 0x0f)))
break;
@@ -386,7 +386,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
actcapi_listen_req(card);
return 0;
case ISDN_CMD_CLREAZ:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c->arg & 0x0f)))
break;
@@ -394,14 +394,14 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
actcapi_listen_req(card);
return 0;
case ISDN_CMD_SETL2:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c->arg & 0x0f)))
break;
chan->l2prot = (c->arg >> 8);
return 0;
case ISDN_CMD_SETL3:
-   if (!card->flags & ACT2000_FLAGS_RUNNING)
+   if (!(card->flags & ACT2000_FLAGS_RUNNING))
return -ENODEV;
if ((c->arg >> 8) != ISDN_PROTO_L3_TRANS) {
printk(KERN_WARNING "L3 protocol unknown\n");
@@ -524,7 +524,7 @@ if_writecmd(const u_char __user *buf, int len, int id, int 
channel)
 act2000_card *card = act2000_findcard(id);
 
 if (card) {
-if (!card->flags & ACT2000_FLAGS_RUNNING)
+if (!(card->flags & ACT2000_FLAGS_RUNNING))
 return -ENODEV;
 return (len);
 }
@@ -539,7 +539,7 @@ if_readstatus(u_char __user * buf, int len, int id, int 
channel)
 act2000_card *card = act2000_findcard(id);

 if (card) {
-if (!card->flags & ACT2000_FLAGS_RUNNING)
+if (!(card->flags & ACT2000

[PATCH 2/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
if(!x & y) should either be if(!(x & y)) or if(!x && y)
I made changes as seemed appropriate, but please review

several changes to drivers/net/

    Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index cf70522..14141a5 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -283,7 +283,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter 
*adapter)
adapter->flags &= ~FLAG_HAS_WOL;
/* quad ports only support WoL on port A */
if (adapter->flags & FLAG_IS_QUAD_PORT &&
-   (!adapter->flags & FLAG_IS_QUAD_PORT_A))
+   (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
adapter->flags &= ~FLAG_HAS_WOL;
break;
 
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 074055e..e3eca6d 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -6407,7 +6407,7 @@ static int airo_set_encode(struct net_device *dev,
set_wep_key(local, index, NULL, 0, perm, 1);
} else
/* Don't complain if only change the mode */
-   if(!dwrq->flags & IW_ENCODE_MODE) {
+   if(!(dwrq->flags & IW_ENCODE_MODE)) {
return -EINVAL;
}
}
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 059ce3f..57cc7e5 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1759,7 +1759,7 @@ static int atmel_set_encode(struct net_device *dev,
priv->default_key = index;
} else
/* Don't complain if only change the mode */
-   if (!dwrq->flags & IW_ENCODE_MODE) {
+   if (!(dwrq->flags & IW_ENCODE_MODE)) {
return -EINVAL;
}
}
diff --git a/drivers/net/wireless/libertas/wext.c 
b/drivers/net/wireless/libertas/wext.c
index c6f5aa3..d93438c 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1380,7 +1380,7 @@ static int wlan_get_encodeext(struct net_device *dev,
index = adapter->wep_tx_keyidx;
}
 
-   if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
+   if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
ext->alg != IW_ENCODE_ALG_WEP) {
if (index != 0 || adapter->mode != IW_MODE_INFRA)
goto out;
diff --git a/drivers/net/wireless/p54common.c b/drivers/net/wireless/p54common.c
index 2c63cf0..b67a31e 100644
--- a/drivers/net/wireless/p54common.c
+++ b/drivers/net/wireless/p54common.c
@@ -374,7 +374,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, 
struct sk_buff *skb)
if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) != 0)
pad = entry_data->align[0];
 
-   if (!status.control.flags & IEEE80211_TXCTL_NO_ACK) {
+   if (!(status.control.flags & IEEE80211_TXCTL_NO_ACK)) {
if (!(payload->status & 0x01))
status.flags |= IEEE80211_TX_STATUS_ACK;
else
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c 
b/drivers/net/wireless/prism54/isl_ioctl.c
index 6d80ca4..b9d0073 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -1118,7 +1118,7 @@ prism54_set_encode(struct net_device *ndev, struct 
iw_request_info *info,
mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
);
} else {
-   if (!dwrq->flags & IW_ENCODE_MODE) {
+   if (!(dwrq->flags & IW_ENCODE_MODE)) {
/* we cannot do anything. Complain. */
return -EINVAL;
}
@@ -2610,7 +2610,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,
mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
);
} else {
-   if (!param->u.crypt.flags & IW_ENCODE_MODE) {
+   if (!(param->u.crypt.flags & IW_ENCODE_MODE)) {
/* we cannot do anything. Complain. */
return -EINVAL;
}
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c 
b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
index 857dcf3..3c1cca4 100644

[PATCH 1/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
if(!x & y) should either be if(!(x & y)) or if(!x && y)
I made changes as seemed appropriate, but please review
this is against current git.

    Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c 
b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index f569b00..46f156f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -410,7 +410,7 @@ static int parse_mtoken(const char *ptr,unsigned int len,
int msk;
*valptr = 0;
for (idx = 0, msk = 1; valid_bits; idx++, msk <<= 1) {
-   if (!msk & valid_bits) continue;
+   if (!(msk & valid_bits)) continue;
valid_bits &= ~msk;
if (!names[idx]) continue;
slen = strlen(names[idx]);
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 7dce318..65c67d1 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int 
mask)
 
switch (mask) {
case MLED_ON:
-   out = !out & 0x1;
+   out = !(out & 0x1);
break;
case GLED_ON:
out = (out & 0x1) + 1;
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index b960f66..6de9d7e 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -343,10 +343,10 @@ static int cmf_copy_block(struct ccw_device *cdev)
 
if (sch->schib.scsw.fctl & SCSW_FCTL_START_FUNC) {
/* Don't copy if a start function is in progress. */
-   if ((!sch->schib.scsw.actl & SCSW_ACTL_SUSPENDED) &&
+   if ((!(sch->schib.scsw.actl & SCSW_ACTL_SUSPENDED)) &&
(sch->schib.scsw.actl &
 (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) &&
-   (!sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS))
+   (!(sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS)))
return -EBUSY;
}
cmb_data = cdev->private->cmb;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 73c44cb..81943ef 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned 
int cmd_in, unsigned lon
!(STp->use_pf & PF_TESTED)) {
/* Try the other possible state of Page Format 
if not
   already tried */
-   STp->use_pf = !STp->use_pf | PF_TESTED;
+   STp->use_pf = !(STp->use_pf | PF_TESTED);
st_release_request(SRpnt);
SRpnt = NULL;
return st_int_ioctl(STp, cmd_in, arg);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 60a8f55..b64309e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -335,7 +335,7 @@ static void kick_khubd(struct usb_hub *hub)
to_usb_interface(hub->intfdev)->pm_usage_cnt = 1;
 
spin_lock_irqsave(_event_lock, flags);
-   if (!hub->disconnected & list_empty(>event_list)) {
+   if (!hub->disconnected && list_empty(>event_list)) {
list_add_tail(>event_list, _event_list);
wake_up(_wait);
}
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 1a7d778..1d13dd0 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1476,7 +1476,7 @@ static int i810fb_cursor(struct fb_info *info, struct 
fb_cursor *cursor)
struct i810fb_par *par = info->par;
u8 __iomem *mmio = par->mmio_start_virtual;
 
-   if (!par->dev_flags & LOCKUP)
+   if (!(par->dev_flags & LOCKUP))
return -ENXIO;
 
if (cursor->image.width > 64 || cursor->image.height > 64)
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 4ba7f0b..ce62c15 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -3946,7 +3946,7 @@ static int __ocfs2_mark_extent_written(struct inode 
*inode,
struct ocfs2_merge_ctxt ctxt;
struct ocfs2_extent_list *rightmost_el;
 
-   if (!rec->e_flags & OCFS2_EXT_UNWRITTEN) {
+   if (!(rec->e_flags & OCFS2_EXT_UNWRITTEN)) {
ret = -EIO;
mlog_errno(ret);
goto out;
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 41c76ff..ef09fd2 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -670,7 +670,7 @@ static inline void 
ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *loc
 {
mlog_entry_void();
 
-   BUG_ON((!lockres->l_flags & O

[PATCH 1/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
if(!x  y) should either be if(!(x  y)) or if(!x  y)
I made changes as seemed appropriate, but please review
this is against current git.

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c 
b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index f569b00..46f156f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -410,7 +410,7 @@ static int parse_mtoken(const char *ptr,unsigned int len,
int msk;
*valptr = 0;
for (idx = 0, msk = 1; valid_bits; idx++, msk = 1) {
-   if (!msk  valid_bits) continue;
+   if (!(msk  valid_bits)) continue;
valid_bits = ~msk;
if (!names[idx]) continue;
slen = strlen(names[idx]);
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 7dce318..65c67d1 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int 
mask)
 
switch (mask) {
case MLED_ON:
-   out = !out  0x1;
+   out = !(out  0x1);
break;
case GLED_ON:
out = (out  0x1) + 1;
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index b960f66..6de9d7e 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -343,10 +343,10 @@ static int cmf_copy_block(struct ccw_device *cdev)
 
if (sch-schib.scsw.fctl  SCSW_FCTL_START_FUNC) {
/* Don't copy if a start function is in progress. */
-   if ((!sch-schib.scsw.actl  SCSW_ACTL_SUSPENDED) 
+   if ((!(sch-schib.scsw.actl  SCSW_ACTL_SUSPENDED)) 
(sch-schib.scsw.actl 
 (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) 
-   (!sch-schib.scsw.stctl  SCSW_STCTL_SEC_STATUS))
+   (!(sch-schib.scsw.stctl  SCSW_STCTL_SEC_STATUS)))
return -EBUSY;
}
cmb_data = cdev-private-cmb;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 73c44cb..81943ef 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned 
int cmd_in, unsigned lon
!(STp-use_pf  PF_TESTED)) {
/* Try the other possible state of Page Format 
if not
   already tried */
-   STp-use_pf = !STp-use_pf | PF_TESTED;
+   STp-use_pf = !(STp-use_pf | PF_TESTED);
st_release_request(SRpnt);
SRpnt = NULL;
return st_int_ioctl(STp, cmd_in, arg);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 60a8f55..b64309e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -335,7 +335,7 @@ static void kick_khubd(struct usb_hub *hub)
to_usb_interface(hub-intfdev)-pm_usage_cnt = 1;
 
spin_lock_irqsave(hub_event_lock, flags);
-   if (!hub-disconnected  list_empty(hub-event_list)) {
+   if (!hub-disconnected  list_empty(hub-event_list)) {
list_add_tail(hub-event_list, hub_event_list);
wake_up(khubd_wait);
}
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 1a7d778..1d13dd0 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1476,7 +1476,7 @@ static int i810fb_cursor(struct fb_info *info, struct 
fb_cursor *cursor)
struct i810fb_par *par = info-par;
u8 __iomem *mmio = par-mmio_start_virtual;
 
-   if (!par-dev_flags  LOCKUP)
+   if (!(par-dev_flags  LOCKUP))
return -ENXIO;
 
if (cursor-image.width  64 || cursor-image.height  64)
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 4ba7f0b..ce62c15 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -3946,7 +3946,7 @@ static int __ocfs2_mark_extent_written(struct inode 
*inode,
struct ocfs2_merge_ctxt ctxt;
struct ocfs2_extent_list *rightmost_el;
 
-   if (!rec-e_flags  OCFS2_EXT_UNWRITTEN) {
+   if (!(rec-e_flags  OCFS2_EXT_UNWRITTEN)) {
ret = -EIO;
mlog_errno(ret);
goto out;
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 41c76ff..ef09fd2 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -670,7 +670,7 @@ static inline void 
ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *loc
 {
mlog_entry_void();
 
-   BUG_ON((!lockres-l_flags  OCFS2_LOCK_BUSY));
+   BUG_ON((!(lockres-l_flags  OCFS2_LOCK_BUSY)));
BUG_ON(lockres-l_flags  OCFS2_LOCK_ATTACHED);
 
if (lockres-l_requested  LKM_NLMODE 
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
index 9b58dd6..bc67230 100644

Re: [PATCH 2/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
Roel Kluin wrote:
 if(!x  y) should either be if(!(x  y)) or if(!x  y)
 I made changes as seemed appropriate, but please review
 
 several changes to drivers/net/
 
 Signed-off-by: Roel Kluin [EMAIL PROTECTED]
 
hmmm forgot to place '---' here, should I resend?
 diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
 index cf70522..14141a5 100644
 --- a/drivers/net/e1000e/82571.c
 +++ b/drivers/net/e1000e/82571.c


-
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 4/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
if(!x  y) should either be if(!(x  y)) or if(!x  y)
I made changes as seemed appropriate, but please review

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/arm/mach-pxa/mfp.c b/arch/arm/mach-pxa/mfp.c
index 5cd3cad..7229319 100644
--- a/arch/arm/mach-pxa/mfp.c
+++ b/arch/arm/mach-pxa/mfp.c
@@ -199,7 +199,7 @@ void pxa3xx_mfp_set_edge(int mfp, int edge)
 
mfpr_val = ~MFPR_EDGE_MASK;
mfpr_val |= (edge  0x3u)  MFPR_ERE_OFFSET;
-   mfpr_val |= (!edge  0x1)  MFPR_EC_OFFSET;
+   mfpr_val |= (!(edge  0x1))  MFPR_EC_OFFSET;
 
mfpr_writel(mfpr_off, mfpr_val);
mfpr_sync();
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 3d45d24..7d78d22 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -858,7 +858,7 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu)
lsapic = (struct acpi_madt_local_sapic *)obj-buffer.pointer;
 
if ((lsapic-header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) ||
-   (!lsapic-lapic_flags  ACPI_MADT_ENABLED)) {
+   (!(lsapic-lapic_flags  ACPI_MADT_ENABLED))) {
kfree(buffer.pointer);
return -EINVAL;
}
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 958bac1..e8f9c85 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -89,7 +89,7 @@ static irqreturn_t dma_tei(int irq, void *dev_id)
 
 static int sh_dmac_request_dma(struct dma_channel *chan)
 {
-   if (unlikely(!chan-flags  DMA_TEI_CAPABLE))
+   if (unlikely(!(chan-flags  DMA_TEI_CAPABLE)))
return 0;
 
return request_irq(get_dmte_irq(chan-chan), dma_tei,
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index cd8c740..a2cf955 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -1070,7 +1070,7 @@ static int set_rtc_mmss(unsigned long nowtime)
 * Not having a register set can lead to trouble.
 * Also starfire doesn't have a tod clock.
 */
-   if (!mregs  !dregs  !bregs)
+   if (!mregs  !dregs  !bregs)
return -1;
 
if (mregs) {
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index d915fec..5a67a87 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -596,7 +596,7 @@ write_led(const char __user * buffer, unsigned long count,
(led_out) ? (hotk-status | ledmask) : (hotk-status  ~ledmask);
 
if (invert) /* invert target value */
-   led_out = !led_out  0x1;
+   led_out = !(led_out  0x1);
 
if (!write_acpi_int(hotk-handle, ledname, led_out, NULL))
printk(KERN_WARNING Asus ACPI: LED (%s) write failed\n,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9b2c0f7..48fbe9e 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -420,8 +420,8 @@ static int acpi_battery_update(struct acpi_battery *battery,
result = acpi_battery_get_status(battery);
if (result)
goto end;
-   if ((!battery-flags.battery_present_prev  
acpi_battery_present(battery))
-   || (battery-flags.battery_present_prev  
!acpi_battery_present(battery))) {
+   if ((!battery-flags.battery_present_prev  
acpi_battery_present(battery))
+   || (battery-flags.battery_present_prev  
!acpi_battery_present(battery))) {
result = acpi_battery_init_update(battery);
if (result)
goto end;
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 9f4e67e..37079d9 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -660,11 +660,11 @@ static int pt_open(struct inode *inode, struct file *file)
pt_identify(tape);
 
err = -ENODEV;
-   if (!tape-flags  PT_MEDIA)
+   if (!(tape-flags  PT_MEDIA))
goto out;
 
err = -EROFS;
-   if ((!tape-flags  PT_WRITE_OK)  (file-f_mode  2))
+   if ((!(tape-flags  PT_WRITE_OK))  (file-f_mode  2))
goto out;
 
if (!(iminor(inode)  128))

-
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 2/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
if(!x  y) should either be if(!(x  y)) or if(!x  y)
I made changes as seemed appropriate, but please review

several changes to drivers/net/

Signed-off-by: Roel Kluin [EMAIL PROTECTED]

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index cf70522..14141a5 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -283,7 +283,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter 
*adapter)
adapter-flags = ~FLAG_HAS_WOL;
/* quad ports only support WoL on port A */
if (adapter-flags  FLAG_IS_QUAD_PORT 
-   (!adapter-flags  FLAG_IS_QUAD_PORT_A))
+   (!(adapter-flags  FLAG_IS_QUAD_PORT_A)))
adapter-flags = ~FLAG_HAS_WOL;
break;
 
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 074055e..e3eca6d 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -6407,7 +6407,7 @@ static int airo_set_encode(struct net_device *dev,
set_wep_key(local, index, NULL, 0, perm, 1);
} else
/* Don't complain if only change the mode */
-   if(!dwrq-flags  IW_ENCODE_MODE) {
+   if(!(dwrq-flags  IW_ENCODE_MODE)) {
return -EINVAL;
}
}
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 059ce3f..57cc7e5 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1759,7 +1759,7 @@ static int atmel_set_encode(struct net_device *dev,
priv-default_key = index;
} else
/* Don't complain if only change the mode */
-   if (!dwrq-flags  IW_ENCODE_MODE) {
+   if (!(dwrq-flags  IW_ENCODE_MODE)) {
return -EINVAL;
}
}
diff --git a/drivers/net/wireless/libertas/wext.c 
b/drivers/net/wireless/libertas/wext.c
index c6f5aa3..d93438c 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1380,7 +1380,7 @@ static int wlan_get_encodeext(struct net_device *dev,
index = adapter-wep_tx_keyidx;
}
 
-   if (!ext-ext_flags  IW_ENCODE_EXT_GROUP_KEY 
+   if (!(ext-ext_flags  IW_ENCODE_EXT_GROUP_KEY) 
ext-alg != IW_ENCODE_ALG_WEP) {
if (index != 0 || adapter-mode != IW_MODE_INFRA)
goto out;
diff --git a/drivers/net/wireless/p54common.c b/drivers/net/wireless/p54common.c
index 2c63cf0..b67a31e 100644
--- a/drivers/net/wireless/p54common.c
+++ b/drivers/net/wireless/p54common.c
@@ -374,7 +374,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, 
struct sk_buff *skb)
if ((entry_hdr-magic1  cpu_to_le16(0x4000)) != 0)
pad = entry_data-align[0];
 
-   if (!status.control.flags  IEEE80211_TXCTL_NO_ACK) {
+   if (!(status.control.flags  IEEE80211_TXCTL_NO_ACK)) {
if (!(payload-status  0x01))
status.flags |= IEEE80211_TX_STATUS_ACK;
else
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c 
b/drivers/net/wireless/prism54/isl_ioctl.c
index 6d80ca4..b9d0073 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -1118,7 +1118,7 @@ prism54_set_encode(struct net_device *ndev, struct 
iw_request_info *info,
mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
index);
} else {
-   if (!dwrq-flags  IW_ENCODE_MODE) {
+   if (!(dwrq-flags  IW_ENCODE_MODE)) {
/* we cannot do anything. Complain. */
return -EINVAL;
}
@@ -2610,7 +2610,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,
mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
index);
} else {
-   if (!param-u.crypt.flags  IW_ENCODE_MODE) {
+   if (!(param-u.crypt.flags  IW_ENCODE_MODE)) {
/* we cannot do anything. Complain. */
return -EINVAL;
}
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c 
b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
index 857dcf3..3c1cca4 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
@@ -403,7 +403,7 @@ static int uw2453_init_hw(struct zd_rf *rf)
if (r)
return r

Re: [PATCH 3/4] fix not-and/or errors

2007-10-17 Thread Roel Kluin
commit 568f9787e58b4d24be50ab2abf1c7dab12a9ef2c
Author: Roel Kluin [EMAIL PROTECTED]
Date:   Wed Oct 17 15:16:44 2007 +0200

if(!x  y) should either be if(!(x  y)) or if(!x  y)
I made changes as seemed appropriate, but please review

several changes to drivers/isdn/

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
index ee2b0b9..8325022 100644
--- a/drivers/isdn/act2000/module.c
+++ b/drivers/isdn/act2000/module.c
@@ -310,7 +310,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
}
break;
case ISDN_CMD_DIAL:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c-arg  0x0f)))
break;
@@ -339,7 +339,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
}
return ret;
case ISDN_CMD_ACCEPTD:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c-arg  0x0f)))
break;
@@ -347,11 +347,11 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
actcapi_select_b2_protocol_req(card, chan);
return 0;
case ISDN_CMD_ACCEPTB:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
return 0;
case ISDN_CMD_HANGUP:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c-arg  0x0f)))
break;
@@ -366,7 +366,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
}
return 0;
case ISDN_CMD_SETEAZ:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c-arg  0x0f)))
break;
@@ -386,7 +386,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
actcapi_listen_req(card);
return 0;
case ISDN_CMD_CLREAZ:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c-arg  0x0f)))
break;
@@ -394,14 +394,14 @@ act2000_command(act2000_card * card, isdn_ctrl * c)
actcapi_listen_req(card);
return 0;
case ISDN_CMD_SETL2:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
if (!(chan = find_channel(card, c-arg  0x0f)))
break;
chan-l2prot = (c-arg  8);
return 0;
case ISDN_CMD_SETL3:
-   if (!card-flags  ACT2000_FLAGS_RUNNING)
+   if (!(card-flags  ACT2000_FLAGS_RUNNING))
return -ENODEV;
if ((c-arg  8) != ISDN_PROTO_L3_TRANS) {
printk(KERN_WARNING L3 protocol unknown\n);
@@ -524,7 +524,7 @@ if_writecmd(const u_char __user *buf, int len, int id, int 
channel)
 act2000_card *card = act2000_findcard(id);
 
 if (card) {
-if (!card-flags  ACT2000_FLAGS_RUNNING)
+if (!(card-flags  ACT2000_FLAGS_RUNNING))
 return -ENODEV;
 return (len);
 }
@@ -539,7 +539,7 @@ if_readstatus(u_char __user * buf, int len, int id, int 
channel)
 act2000_card *card = act2000_findcard(id);

 if (card) {
-if (!card-flags  ACT2000_FLAGS_RUNNING)
+if (!(card-flags  ACT2000_FLAGS_RUNNING))
 return -ENODEV;
 return (act2000_readstatus(buf, len, card));
 }
@@ -554,7 +554,7 @@ if_sendbuf(int id, int channel, int ack, struct sk_buff 
*skb)
 act2000_card *card = act2000_findcard(id);

 if (card

Re: [PATCH] tty_ioctl: Fix the baud_table check in encode_baud_rate

2007-10-16 Thread Roel Kluin
Since you were sending a fix, possibly I shouldn't comment on this. If so 
please disregard my
suggestion for a trivial cleanup.

Roel

Maciej W. Rozycki wrote:
> +void tty_termios_encode_baud_rate(struct ktermios *termios,
> +   speed_t ibaud, speed_t obaud)
>  {
>   int i = 0;
>   int ifound = -1, ofound = -1;
> @@ -251,12 +252,15 @@ void tty_termios_encode_baud_rate(struct
>   termios->c_cflag &= ~CBAUD;
>  
>   do {
> - if (obaud - oclose >= baud_table[i] && obaud + oclose <= 
> baud_table[i]) {
> + if (obaud - oclose <= baud_table[i] &&
> + obaud + oclose >= baud_table[i]) {

if(a - b <= c && a + b >= c)
if(a <= c + b && a + b >= c)
if(c + b >= a && a + b >= c)
if(b >= a - c && b >= c - a)
true, if:
b >= |a - c|
so
if (oclose >= abs(obaud - baud_table[i])) {

should work as well

>   termios->c_cflag |= baud_bits[i];
>   ofound = i;
>   }
> - if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= 
> baud_table[i]) {
> - /* For the case input == output don't set IBAUD bits if 
> the user didn't do so */
> + if (ibaud - iclose <= baud_table[i] &&
> + ibaud + iclose >= baud_table[i]) {

similarly,
if (iclose >= abs(ibaud - baud_table[i])) {

> + /* For the case input == output don't set IBAUD bits
> +if the user didn't do so */
>   if (ofound != i || ibinput)
>   termios->c_cflag |= (baud_bits[i] << IBSHIFT);
>   ifound = i;
-
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] tty_ioctl: Fix the baud_table check in encode_baud_rate

2007-10-16 Thread Roel Kluin
Since you were sending a fix, possibly I shouldn't comment on this. If so 
please disregard my
suggestion for a trivial cleanup.

Roel

Maciej W. Rozycki wrote:
 +void tty_termios_encode_baud_rate(struct ktermios *termios,
 +   speed_t ibaud, speed_t obaud)
  {
   int i = 0;
   int ifound = -1, ofound = -1;
 @@ -251,12 +252,15 @@ void tty_termios_encode_baud_rate(struct
   termios-c_cflag = ~CBAUD;
  
   do {
 - if (obaud - oclose = baud_table[i]  obaud + oclose = 
 baud_table[i]) {
 + if (obaud - oclose = baud_table[i] 
 + obaud + oclose = baud_table[i]) {

if(a - b = c  a + b = c)
if(a = c + b  a + b = c)
if(c + b = a  a + b = c)
if(b = a - c  b = c - a)
true, if:
b = |a - c|
so
if (oclose = abs(obaud - baud_table[i])) {

should work as well

   termios-c_cflag |= baud_bits[i];
   ofound = i;
   }
 - if (ibaud - iclose = baud_table[i]  ibaud + iclose = 
 baud_table[i]) {
 - /* For the case input == output don't set IBAUD bits if 
 the user didn't do so */
 + if (ibaud - iclose = baud_table[i] 
 + ibaud + iclose = baud_table[i]) {

similarly,
if (iclose = abs(ibaud - baud_table[i])) {

 + /* For the case input == output don't set IBAUD bits
 +if the user didn't do so */
   if (ofound != i || ibinput)
   termios-c_cflag |= (baud_bits[i]  IBSHIFT);
   ifound = i;
-
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 try #2] Input/Joystick Driver: add support AD7142 joystick driver

2007-10-12 Thread Roel Kluin
Bryan Wu wrote:
> +static int ad7142_i2c_read(struct i2c_client *client, unsigned short offset,
> + unsigned short *data, unsigned int len)
> +{
> + int ret = -1;
> + int i;
> + u8 block_data[32];
> +
> + if (len < 1 && len > 16) {

you want || here

> + printk(KERN_ERR "AD7142: read data length error\n");
> + return ret;
> + }
> +
> + /* Do raw I2C, not smbus compatible */
> + block_data[0] = (offset & 0xFF00) >> 8;
> + block_data[1] = (offset & 0x00FF);
> +
> + ret = i2c_master_send(client, block_data, 2);
> + if (ret < 0) {
> + printk(KERN_ERR "AD7142: I2C read error\n");
> + return ret;
> + }
> +
> + ret = i2c_master_recv(client, block_data, len * 2);
> + if (ret < 0) {
> + printk(KERN_ERR "AD7142: I2C transfer error\n");
> + return ret;
> + }
> +
> + for (i = 0; i < len; i++) {
> + unsigned short temp;
> + temp = block_data[2 * i];
> + temp = (temp << 8) & 0xFF00;
> + *data++ = temp | block_data[2 * i + 1];
> + }
> +
> + return ret;
> +}


-
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 try #2] Input/Joystick Driver: add support AD7142 joystick driver

2007-10-12 Thread Roel Kluin
Bryan Wu wrote:
 +static int ad7142_i2c_read(struct i2c_client *client, unsigned short offset,
 + unsigned short *data, unsigned int len)
 +{
 + int ret = -1;
 + int i;
 + u8 block_data[32];
 +
 + if (len  1  len  16) {

you want || here

 + printk(KERN_ERR AD7142: read data length error\n);
 + return ret;
 + }
 +
 + /* Do raw I2C, not smbus compatible */
 + block_data[0] = (offset  0xFF00)  8;
 + block_data[1] = (offset  0x00FF);
 +
 + ret = i2c_master_send(client, block_data, 2);
 + if (ret  0) {
 + printk(KERN_ERR AD7142: I2C read error\n);
 + return ret;
 + }
 +
 + ret = i2c_master_recv(client, block_data, len * 2);
 + if (ret  0) {
 + printk(KERN_ERR AD7142: I2C transfer error\n);
 + return ret;
 + }
 +
 + for (i = 0; i  len; i++) {
 + unsigned short temp;
 + temp = block_data[2 * i];
 + temp = (temp  8)  0xFF00;
 + *data++ = temp | block_data[2 * i + 1];
 + }
 +
 + return ret;
 +}


-
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 09/31] IGET: Stop BFS from using iget() and read_inode() [try #3]

2007-10-10 Thread Roel Kluin
It is very well possible that I misunderstand the locking order here,
but FWIW:

David Howells wrote:
> diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
> index f346eb1..76798c9 100644
> --- a/fs/bfs/inode.c
> +++ b/fs/bfs/inode.c
> @@ -32,25 +32,29 @@ MODULE_LICENSE("GPL");
>  
>  void dump_imap(const char *prefix, struct super_block * s);
>  
> -static void bfs_read_inode(struct inode * inode)
> +struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
>  {
> - unsigned long ino = inode->i_ino;
>   struct bfs_inode * di;
>   struct buffer_head * bh;
> + struct inode *inode;
>   int block, off;
>  
> + inode = iget_locked(sb, ino);

after this

> + if (IS_ERR(inode))
> + return ERR_PTR(-ENOMEM);
> + if (!(inode->i_state & I_NEW))
> + return inode;

Don't you have to unlock_new_inode(inode) before returning?

> +
>   if (ino < BFS_ROOT_INO || ino > BFS_SB(inode->i_sb)->si_lasti) {
>   printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino);
> - make_bad_inode(inode);
> - return;
> + goto error;
>   }
>  
>   block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1;
>   bh = sb_bread(inode->i_sb, block);
>   if (!bh) {
>   printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, 
> ino);
> - make_bad_inode(inode);
> - return;
> + goto error;
>   }
>  
>   off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
> @@ -85,6 +89,12 @@ static void bfs_read_inode(struct inode * inode)
>   BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino); /* can be 0 so we 
> store a copy */
>  
>   brelse(bh);
> + unlock_new_inode(inode);
> + return inode;
> +
> +error:

and also here?

> + iget_failed(inode);
> + return ERR_PTR(-EIO);
>  }
-
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 09/31] IGET: Stop BFS from using iget() and read_inode() [try #3]

2007-10-10 Thread Roel Kluin
It is very well possible that I misunderstand the locking order here,
but FWIW:

David Howells wrote:
 diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
 index f346eb1..76798c9 100644
 --- a/fs/bfs/inode.c
 +++ b/fs/bfs/inode.c
 @@ -32,25 +32,29 @@ MODULE_LICENSE(GPL);
  
  void dump_imap(const char *prefix, struct super_block * s);
  
 -static void bfs_read_inode(struct inode * inode)
 +struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
  {
 - unsigned long ino = inode-i_ino;
   struct bfs_inode * di;
   struct buffer_head * bh;
 + struct inode *inode;
   int block, off;
  
 + inode = iget_locked(sb, ino);

after this

 + if (IS_ERR(inode))
 + return ERR_PTR(-ENOMEM);
 + if (!(inode-i_state  I_NEW))
 + return inode;

Don't you have to unlock_new_inode(inode) before returning?

 +
   if (ino  BFS_ROOT_INO || ino  BFS_SB(inode-i_sb)-si_lasti) {
   printf(Bad inode number %s:%08lx\n, inode-i_sb-s_id, ino);
 - make_bad_inode(inode);
 - return;
 + goto error;
   }
  
   block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1;
   bh = sb_bread(inode-i_sb, block);
   if (!bh) {
   printf(Unable to read inode %s:%08lx\n, inode-i_sb-s_id, 
 ino);
 - make_bad_inode(inode);
 - return;
 + goto error;
   }
  
   off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
 @@ -85,6 +89,12 @@ static void bfs_read_inode(struct inode * inode)
   BFS_I(inode)-i_dsk_ino = le16_to_cpu(di-i_ino); /* can be 0 so we 
 store a copy */
  
   brelse(bh);
 + unlock_new_inode(inode);
 + return inode;
 +
 +error:

and also here?

 + iget_failed(inode);
 + return ERR_PTR(-EIO);
  }
-
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 v4] IBM power meter driver

2007-10-09 Thread Roel Kluin
Mark M. Hoffman wrote:
>> +static void ibmpex_register_bmc(int iface, struct device *dev)
>> +{
>> +struct ibmpex_bmc_data *data;
>> +int err;
>> +
>> +data = kzalloc(sizeof(*data), GFP_KERNEL);
>> +if (!data) {
>> +printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
>> +   "interface %d.\n", data->interface);
>> +return;
>> +}
>> +
>> +data->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
>> +data->address.channel = IPMI_BMC_CHANNEL;
>> +data->address.data[0] = 0;
>> +data->interface = iface;
>> +data->bmc_device = dev;
>> +
>> +/* Create IPMI messaging interface user */
>> +err = ipmi_create_user(data->interface, _data.ipmi_hndlrs,
>> +   data, >user);
>> +if (err < 0) {
>> +printk(KERN_ERR DRVNAME ": Error, unable to register user with "
>> +   "ipmi interface %d\n",
>> +   data->interface);
>> +goto out;
>> +}
>> +
>> +mutex_init(>lock);
>> +
>> +/* Initialize message */
>> +data->tx_msgid = 0;
>> +init_completion(>read_complete);
>> +data->tx_message.netfn = PEX_NET_FUNCTION;
>> +data->tx_message.cmd = PEX_COMMAND;
>> +data->tx_message.data = data->tx_msg_data;
>> +
>> +/* Does this BMC support PowerExecutive? */
>> +err = ibmpex_ver_check(data);
>> +if (err)
>> +goto out_user;
>> +
>> +/* Register the BMC as a HWMON class device */
>> +data->hwmon_dev = hwmon_device_register(data->bmc_device);
>> +
>> +if (IS_ERR(data->hwmon_dev)) {
>> +printk(KERN_ERR DRVNAME ": Error, unable to register hwmon "
>> +   "class device for interface %d\n",
>> +   data->interface);
>> +kfree(data);
>> +return;

don't you want to goto out_user here instead?

>> +}
>> +
>> +/* finally add the new bmc data to the bmc data list */
>> +dev_set_drvdata(dev, data);
>> +list_add_tail(>list, _data.bmc_data);
>> +
>> +/* Now go find all the sensors */
>> +err = ibmpex_find_sensors(data);
>> +if (err) {
>> +printk(KERN_ERR "Error %d allocating memory\n", err);
>> +goto out_register;
>> +}
>> +
>> +return;
>> +
>> +out_register:
>> +hwmon_device_unregister(data->hwmon_dev);
>> +out_user:
>> +ipmi_destroy_user(data->user);
>> +out:
>> +kfree(data);
>> +}


-
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 v4] IBM power meter driver

2007-10-09 Thread Roel Kluin
Mark M. Hoffman wrote:
 +static void ibmpex_register_bmc(int iface, struct device *dev)
 +{
 +struct ibmpex_bmc_data *data;
 +int err;
 +
 +data = kzalloc(sizeof(*data), GFP_KERNEL);
 +if (!data) {
 +printk(KERN_ERR DRVNAME : Insufficient memory for BMC 
 +   interface %d.\n, data-interface);
 +return;
 +}
 +
 +data-address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
 +data-address.channel = IPMI_BMC_CHANNEL;
 +data-address.data[0] = 0;
 +data-interface = iface;
 +data-bmc_device = dev;
 +
 +/* Create IPMI messaging interface user */
 +err = ipmi_create_user(data-interface, driver_data.ipmi_hndlrs,
 +   data, data-user);
 +if (err  0) {
 +printk(KERN_ERR DRVNAME : Error, unable to register user with 
 +   ipmi interface %d\n,
 +   data-interface);
 +goto out;
 +}
 +
 +mutex_init(data-lock);
 +
 +/* Initialize message */
 +data-tx_msgid = 0;
 +init_completion(data-read_complete);
 +data-tx_message.netfn = PEX_NET_FUNCTION;
 +data-tx_message.cmd = PEX_COMMAND;
 +data-tx_message.data = data-tx_msg_data;
 +
 +/* Does this BMC support PowerExecutive? */
 +err = ibmpex_ver_check(data);
 +if (err)
 +goto out_user;
 +
 +/* Register the BMC as a HWMON class device */
 +data-hwmon_dev = hwmon_device_register(data-bmc_device);
 +
 +if (IS_ERR(data-hwmon_dev)) {
 +printk(KERN_ERR DRVNAME : Error, unable to register hwmon 
 +   class device for interface %d\n,
 +   data-interface);
 +kfree(data);
 +return;

don't you want to goto out_user here instead?

 +}
 +
 +/* finally add the new bmc data to the bmc data list */
 +dev_set_drvdata(dev, data);
 +list_add_tail(data-list, driver_data.bmc_data);
 +
 +/* Now go find all the sensors */
 +err = ibmpex_find_sensors(data);
 +if (err) {
 +printk(KERN_ERR Error %d allocating memory\n, err);
 +goto out_register;
 +}
 +
 +return;
 +
 +out_register:
 +hwmon_device_unregister(data-hwmon_dev);
 +out_user:
 +ipmi_destroy_user(data-user);
 +out:
 +kfree(data);
 +}


-
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 08/12] NLM: Fix a circular lock dependency in lockd

2007-10-08 Thread Roel Kluin
Greg KH wrote:

@@ -477,10 +479,15 @@ nlmsvc_testlock(struct svc_rqst *rqstp, 
 
if (block == NULL) {
struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
+   struct nlm_host *host;
 
if (conf == NULL)
return nlm_granted;
-   block = nlmsvc_create_block(rqstp, file, lock, cookie);
+   /* Create host handle for callback */
+   host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
+   if (host == NULL)
+   return nlm_lck_denied_nolocks;
+   block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
if (block == NULL) {
kfree(conf);
return nlm_granted;

To be frankly I don't know what this is about, but shouldn't conf be freed if 
host == 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/


Re: [patch 08/12] NLM: Fix a circular lock dependency in lockd

2007-10-08 Thread Roel Kluin
Greg KH wrote:

@@ -477,10 +479,15 @@ nlmsvc_testlock(struct svc_rqst *rqstp, 
 
if (block == NULL) {
struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
+   struct nlm_host *host;
 
if (conf == NULL)
return nlm_granted;
-   block = nlmsvc_create_block(rqstp, file, lock, cookie);
+   /* Create host handle for callback */
+   host = nlmsvc_lookup_host(rqstp, lock-caller, lock-len);
+   if (host == NULL)
+   return nlm_lck_denied_nolocks;
+   block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
if (block == NULL) {
kfree(conf);
return nlm_granted;

To be frankly I don't know what this is about, but shouldn't conf be freed if 
host == 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/


Re: [PATCH] use array_size macro

2007-09-28 Thread Roel Kluin
Jeff Dike wrote:
> On Fri, Sep 28, 2007 at 12:56:31PM +0200, Roel Kluin wrote:
>> arch/um/kernel/tt/ptproxy/ptrace.c  |   12 ++--
> 
> I don't know what you're diffing against, but this file is history in
>  -mm, and will be gone in mainline after 2.6.23.
> 
> Jeff
> 
Thanks for noting me. I usually pull the masters branch, so my previously 
submitted
patches are against that. Apparently I have to apply the -mm patchset before 
sending
patches. Is there a git branch to pull from for that?

Roel
-
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] use array_size macro

2007-09-28 Thread Roel Kluin
Please use this one instead. it also removes an unnecessary #define.

This patch changes code to use the ARRAY_SIZE macro. This patch is the result 
of:
find -name *.[chsS] | xargs sed -i "s/sizeof(\(\w*\))[ \t]*\/[ 
\t]*sizeof(\1\[0\])/ARRAY_SIZE(\1)/g"

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>

 arch/arm/kernel/dma-isa.c   |2 +-
 arch/powerpc/platforms/celleb/scc_sio.c |2 +-
 arch/um/kernel/tt/ptproxy/ptrace.c  |   12 ++--
 drivers/char/synclink_gt.c  |2 +-
 drivers/net/apne.c  |2 +-
 drivers/net/arm/am79c961a.c |2 +-
 drivers/net/atl1/atl1_hw.c  |2 +-
 drivers/net/cs89x0.c|6 +++---
 drivers/net/fec_8xx/fec_mii.c   |4 ++--
 drivers/net/ibm_emac/ibm_emac_debug.c   |8 
 drivers/net/ne-h8300.c  |2 +-
 drivers/net/ne.c|2 +-
 drivers/net/ne2.c   |2 +-
 drivers/net/ne2k-pci.c  |2 +-
 drivers/net/netxen/netxen_nic_hw.c  |2 +-
 drivers/net/pcmcia/axnet_cs.c   |2 +-
 drivers/net/pcmcia/pcnet_cs.c   |2 +-
 drivers/net/sk98lin/skgesirq.c  |2 +-
 drivers/net/zorro8390.c |2 +-
 drivers/serial/68328serial.c|4 ++--
 drivers/serial/mcfserial.c  |7 ++-
 include/asm-parisc/mmzone.h |2 +-
 net/atm/proc.c  |2 +-
 23 files changed, 36 insertions(+), 39 deletions(-)

---
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c
index 0a3e9ad..2f080a3 100644
--- a/arch/arm/kernel/dma-isa.c
+++ b/arch/arm/kernel/dma-isa.c
@@ -216,7 +216,7 @@ void __init isa_init_dma(dma_t *dma)
 
request_dma(DMA_ISA_CASCADE, "cascade");
 
-   for (i = 0; i < sizeof(dma_resources) / 
sizeof(dma_resources[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(dma_resources); i++)
request_resource(_resource, dma_resources + i);
}
 }
diff --git a/arch/powerpc/platforms/celleb/scc_sio.c 
b/arch/powerpc/platforms/celleb/scc_sio.c
index bcd25f5..457651d 100644
--- a/arch/powerpc/platforms/celleb/scc_sio.c
+++ b/arch/powerpc/platforms/celleb/scc_sio.c
@@ -52,7 +52,7 @@ static int txx9_serial_init(void)
if (!node)
return 0;
 
-   for(i = 0; i < sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) {
+   for(i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) {
if (!(txx9_serial_bitmap & (1<pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -93,7 +93,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t 
arg2,
result = ptrace(PTRACE_GETFPXREGS, child, 0, regs);
if(result == -1) return(-errno);

-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -109,7 +109,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
result = ptrace(PTRACE_GETREGS, child, 0, regs);
if(result == -1) return(-errno);
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
ptrace (PTRACE_POKEDATA, debugger->pid,
arg4 + 4 * i, regs[i]);
return(result);
@@ -155,7 +155,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FP_FRAME_SIZE];
int i;
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
  arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETFPREGS, child, 0, regs);
@@ -171,7 +171,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FPX_FRAME_SIZE];
int i;
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
  arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETFPXREGS, child, 0, regs);
@@ -187,7 +187,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FRAME_SIZE];
int i;
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
regs[i] = ptrace(P

[PATCH] use array_size macro

2007-09-28 Thread Roel Kluin
This patch changes code to use the ARRAY_SIZE macro. This patch is the result 
of:
find -name *.[chsS] | xargs sed -i "s/sizeof(\(\w*\))[ \t]*\/[ 
\t]*sizeof(\1\[0\])/ARRAY_SIZE(\1)/g"

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c
index 0a3e9ad..2f080a3 100644
--- a/arch/arm/kernel/dma-isa.c
+++ b/arch/arm/kernel/dma-isa.c
@@ -216,7 +216,7 @@ void __init isa_init_dma(dma_t *dma)
 
request_dma(DMA_ISA_CASCADE, "cascade");
 
-   for (i = 0; i < sizeof(dma_resources) / 
sizeof(dma_resources[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(dma_resources); i++)
request_resource(_resource, dma_resources + i);
}
 }
diff --git a/arch/powerpc/platforms/celleb/scc_sio.c 
b/arch/powerpc/platforms/celleb/scc_sio.c
index bcd25f5..457651d 100644
--- a/arch/powerpc/platforms/celleb/scc_sio.c
+++ b/arch/powerpc/platforms/celleb/scc_sio.c
@@ -52,7 +52,7 @@ static int txx9_serial_init(void)
if (!node)
return 0;
 
-   for(i = 0; i < sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) {
+   for(i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) {
if (!(txx9_serial_bitmap & (1<pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -93,7 +93,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t 
arg2,
result = ptrace(PTRACE_GETFPXREGS, child, 0, regs);
if(result == -1) return(-errno);

-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -109,7 +109,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
result = ptrace(PTRACE_GETREGS, child, 0, regs);
if(result == -1) return(-errno);
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
ptrace (PTRACE_POKEDATA, debugger->pid,
arg4 + 4 * i, regs[i]);
return(result);
@@ -155,7 +155,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FP_FRAME_SIZE];
int i;
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
  arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETFPREGS, child, 0, regs);
@@ -171,7 +171,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FPX_FRAME_SIZE];
int i;
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
  arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETFPXREGS, child, 0, regs);
@@ -187,7 +187,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FRAME_SIZE];
int i;
 
-   for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i < ARRAY_SIZE(regs); i++)
regs[i] = ptrace(PTRACE_PEEKDATA, debugger->pid,
 arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETREGS, child, 0, regs);
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 2f97d2f..d27001a 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -4717,7 +4717,7 @@ static int register_test(struct slgt_info *info)
 {
static unsigned short patterns[] =
{0x, 0x, 0x, 0x, 0x6969, 0x9696};
-   static unsigned int count = sizeof(patterns)/sizeof(patterns[0]);
+   static unsigned int count = ARRAY_SIZE(patterns);
unsigned int i;
int rc = 0;
 
diff --git a/drivers/net/apne.c b/drivers/net/apne.c
index 9541911..8806151 100644
--- a/drivers/net/apne.c
+++ b/drivers/net/apne.c
@@ -247,7 +247,7 @@ static int __init apne_probe1(struct net_device *dev, int 
ioaddr)
{0x00,  NE_EN0_RSARHI},
{E8390_RREAD+E8390_START, NE_CMD},
};
-   for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++) {
+   for (i = 0; i < ARRAY_SIZE(program_seq); i++) {
outb(program_seq[i].value, ioaddr + program_seq[i].offset);
}
 
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 2143eeb..7796455 100644
---

Re: [PATCH] use array_size macro

2007-09-28 Thread Roel Kluin
Please use this one instead. it also removes an unnecessary #define.

This patch changes code to use the ARRAY_SIZE macro. This patch is the result 
of:
find -name *.[chsS] | xargs sed -i s/sizeof(\(\w*\))[ \t]*\/[ 
\t]*sizeof(\1\[0\])/ARRAY_SIZE(\1)/g

Signed-off-by: Roel Kluin [EMAIL PROTECTED]

 arch/arm/kernel/dma-isa.c   |2 +-
 arch/powerpc/platforms/celleb/scc_sio.c |2 +-
 arch/um/kernel/tt/ptproxy/ptrace.c  |   12 ++--
 drivers/char/synclink_gt.c  |2 +-
 drivers/net/apne.c  |2 +-
 drivers/net/arm/am79c961a.c |2 +-
 drivers/net/atl1/atl1_hw.c  |2 +-
 drivers/net/cs89x0.c|6 +++---
 drivers/net/fec_8xx/fec_mii.c   |4 ++--
 drivers/net/ibm_emac/ibm_emac_debug.c   |8 
 drivers/net/ne-h8300.c  |2 +-
 drivers/net/ne.c|2 +-
 drivers/net/ne2.c   |2 +-
 drivers/net/ne2k-pci.c  |2 +-
 drivers/net/netxen/netxen_nic_hw.c  |2 +-
 drivers/net/pcmcia/axnet_cs.c   |2 +-
 drivers/net/pcmcia/pcnet_cs.c   |2 +-
 drivers/net/sk98lin/skgesirq.c  |2 +-
 drivers/net/zorro8390.c |2 +-
 drivers/serial/68328serial.c|4 ++--
 drivers/serial/mcfserial.c  |7 ++-
 include/asm-parisc/mmzone.h |2 +-
 net/atm/proc.c  |2 +-
 23 files changed, 36 insertions(+), 39 deletions(-)

---
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c
index 0a3e9ad..2f080a3 100644
--- a/arch/arm/kernel/dma-isa.c
+++ b/arch/arm/kernel/dma-isa.c
@@ -216,7 +216,7 @@ void __init isa_init_dma(dma_t *dma)
 
request_dma(DMA_ISA_CASCADE, cascade);
 
-   for (i = 0; i  sizeof(dma_resources) / 
sizeof(dma_resources[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(dma_resources); i++)
request_resource(ioport_resource, dma_resources + i);
}
 }
diff --git a/arch/powerpc/platforms/celleb/scc_sio.c 
b/arch/powerpc/platforms/celleb/scc_sio.c
index bcd25f5..457651d 100644
--- a/arch/powerpc/platforms/celleb/scc_sio.c
+++ b/arch/powerpc/platforms/celleb/scc_sio.c
@@ -52,7 +52,7 @@ static int txx9_serial_init(void)
if (!node)
return 0;
 
-   for(i = 0; i  sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) {
+   for(i = 0; i  ARRAY_SIZE(txx9_scc_tab); i++) {
if (!(txx9_serial_bitmap  (1i)))
continue;
 
diff --git a/arch/um/kernel/tt/ptproxy/ptrace.c 
b/arch/um/kernel/tt/ptproxy/ptrace.c
index 4b4f617..5b526c4 100644
--- a/arch/um/kernel/tt/ptproxy/ptrace.c
+++ b/arch/um/kernel/tt/ptproxy/ptrace.c
@@ -77,7 +77,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t 
arg2,
result = ptrace(PTRACE_GETFPREGS, child, 0, regs);
if(result == -1) return(-errno);

-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
ptrace(PTRACE_POKEDATA, debugger-pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -93,7 +93,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t 
arg2,
result = ptrace(PTRACE_GETFPXREGS, child, 0, regs);
if(result == -1) return(-errno);

-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
ptrace(PTRACE_POKEDATA, debugger-pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -109,7 +109,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
result = ptrace(PTRACE_GETREGS, child, 0, regs);
if(result == -1) return(-errno);
 
-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
ptrace (PTRACE_POKEDATA, debugger-pid,
arg4 + 4 * i, regs[i]);
return(result);
@@ -155,7 +155,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FP_FRAME_SIZE];
int i;
 
-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
regs[i] = ptrace (PTRACE_PEEKDATA, debugger-pid,
  arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETFPREGS, child, 0, regs);
@@ -171,7 +171,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FPX_FRAME_SIZE];
int i;
 
-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE

[PATCH] use array_size macro

2007-09-28 Thread Roel Kluin
This patch changes code to use the ARRAY_SIZE macro. This patch is the result 
of:
find -name *.[chsS] | xargs sed -i s/sizeof(\(\w*\))[ \t]*\/[ 
\t]*sizeof(\1\[0\])/ARRAY_SIZE(\1)/g

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c
index 0a3e9ad..2f080a3 100644
--- a/arch/arm/kernel/dma-isa.c
+++ b/arch/arm/kernel/dma-isa.c
@@ -216,7 +216,7 @@ void __init isa_init_dma(dma_t *dma)
 
request_dma(DMA_ISA_CASCADE, cascade);
 
-   for (i = 0; i  sizeof(dma_resources) / 
sizeof(dma_resources[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(dma_resources); i++)
request_resource(ioport_resource, dma_resources + i);
}
 }
diff --git a/arch/powerpc/platforms/celleb/scc_sio.c 
b/arch/powerpc/platforms/celleb/scc_sio.c
index bcd25f5..457651d 100644
--- a/arch/powerpc/platforms/celleb/scc_sio.c
+++ b/arch/powerpc/platforms/celleb/scc_sio.c
@@ -52,7 +52,7 @@ static int txx9_serial_init(void)
if (!node)
return 0;
 
-   for(i = 0; i  sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) {
+   for(i = 0; i  ARRAY_SIZE(txx9_scc_tab); i++) {
if (!(txx9_serial_bitmap  (1i)))
continue;
 
diff --git a/arch/um/kernel/tt/ptproxy/ptrace.c 
b/arch/um/kernel/tt/ptproxy/ptrace.c
index 4b4f617..5b526c4 100644
--- a/arch/um/kernel/tt/ptproxy/ptrace.c
+++ b/arch/um/kernel/tt/ptproxy/ptrace.c
@@ -77,7 +77,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t 
arg2,
result = ptrace(PTRACE_GETFPREGS, child, 0, regs);
if(result == -1) return(-errno);

-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
ptrace(PTRACE_POKEDATA, debugger-pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -93,7 +93,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t 
arg2,
result = ptrace(PTRACE_GETFPXREGS, child, 0, regs);
if(result == -1) return(-errno);

-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
ptrace(PTRACE_POKEDATA, debugger-pid, arg4 + 4 * i,
   regs[i]);
return(result);
@@ -109,7 +109,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
result = ptrace(PTRACE_GETREGS, child, 0, regs);
if(result == -1) return(-errno);
 
-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
ptrace (PTRACE_POKEDATA, debugger-pid,
arg4 + 4 * i, regs[i]);
return(result);
@@ -155,7 +155,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FP_FRAME_SIZE];
int i;
 
-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
regs[i] = ptrace (PTRACE_PEEKDATA, debugger-pid,
  arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETFPREGS, child, 0, regs);
@@ -171,7 +171,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FPX_FRAME_SIZE];
int i;
 
-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
regs[i] = ptrace (PTRACE_PEEKDATA, debugger-pid,
  arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETFPXREGS, child, 0, regs);
@@ -187,7 +187,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, 
pid_t arg2,
long regs[FRAME_SIZE];
int i;
 
-   for (i = 0; i  sizeof(regs)/sizeof(regs[0]); i++)
+   for (i = 0; i  ARRAY_SIZE(regs); i++)
regs[i] = ptrace(PTRACE_PEEKDATA, debugger-pid,
 arg4 + 4 * i, 0);
result = ptrace(PTRACE_SETREGS, child, 0, regs);
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 2f97d2f..d27001a 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -4717,7 +4717,7 @@ static int register_test(struct slgt_info *info)
 {
static unsigned short patterns[] =
{0x, 0x, 0x, 0x, 0x6969, 0x9696};
-   static unsigned int count = sizeof(patterns)/sizeof(patterns[0]);
+   static unsigned int count = ARRAY_SIZE(patterns);
unsigned int i;
int rc = 0;
 
diff --git a/drivers/net/apne.c b/drivers/net/apne.c
index 9541911..8806151 100644
--- a/drivers/net/apne.c
+++ b

Re: [PATCH] use array_size macro

2007-09-28 Thread Roel Kluin
Jeff Dike wrote:
 On Fri, Sep 28, 2007 at 12:56:31PM +0200, Roel Kluin wrote:
 arch/um/kernel/tt/ptproxy/ptrace.c  |   12 ++--
 
 I don't know what you're diffing against, but this file is history in
  -mm, and will be gone in mainline after 2.6.23.
 
 Jeff
 
Thanks for noting me. I usually pull the masters branch, so my previously 
submitted
patches are against that. Apparently I have to apply the -mm patchset before 
sending
patches. Is there a git branch to pull from for that?

Roel
-
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] removes array_size duplicates

2007-09-27 Thread roel
This patch removes some ARRAY_SIZE macro duplicates. There is also one in
arch/um/include/user.h, which isn't fixed here because comments in that file
explicitly state a preference for the 'less fancy' version. If that's the
case as well for any of the other replacements please comment.

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---

 Documentation/spi/spidev_test.c|2 --
 arch/i386/boot/compressed/relocs.c |1 -
 arch/m68k/amiga/amisound.c |3 +--
 arch/powerpc/boot/types.h  |2 --
 arch/sparc64/kernel/pci.c  |6 ++
 drivers/acpi/utilities/uteval.c|4 ++--
 drivers/net/irda/actisys-sir.c |6 ++
 drivers/net/lp486e.c   |4 +---
 drivers/net/sk98lin/skgemib.c  |5 -
 drivers/net/skfp/smt.c |4 +---
 drivers/net/skfp/srf.c |   18 +++---
 drivers/net/wireless/ipw2100.c |   13 -
 drivers/serial/68328serial.c   |6 ++
 drivers/video/sgivwfb.c|4 ++--
 include/acpi/acmacros.h|2 --
 include/linux/netfilter/xt_sctp.h  |   12 +---
 include/net/ip_vs.h|1 -
 include/video/sgivw.h  |1 -
 net/ipv4/ipvs/ip_vs_proto_tcp.c|2 +-
 scripts/mod/file2alias.c   |2 --
 20 files changed, 30 insertions(+), 68 deletions(-)

diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c
index 218e862..0f23aac 100644
--- a/Documentation/spi/spidev_test.c
+++ b/Documentation/spi/spidev_test.c
@@ -21,8 +21,6 @@
 #include 
 #include 
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-
 static void pabort(const char *s)
 {
perror(s);
diff --git a/arch/i386/boot/compressed/relocs.c 
b/arch/i386/boot/compressed/relocs.c
index 2d77ee7..5d8dbff 100644
--- a/arch/i386/boot/compressed/relocs.c
+++ b/arch/i386/boot/compressed/relocs.c
@@ -11,7 +11,6 @@
 #include 
 
 #define MAX_SHDRS 100
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 static Elf32_Ehdr ehdr;
 static Elf32_Shdr shdr[MAX_SHDRS];
 static Elf32_Sym  *symtab[MAX_SHDRS];
diff --git a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c
index 1f5bfb5..8d013a1 100644
--- a/arch/m68k/amiga/amisound.c
+++ b/arch/m68k/amiga/amisound.c
@@ -21,7 +21,6 @@ static const signed char sine_data[] = {
0,  39,  75,  103,  121,  127,  121,  103,  75,  39,
0, -39, -75, -103, -121, -127, -121, -103, -75, -39
 };
-#define DATA_SIZE  (sizeof(sine_data)/sizeof(sine_data[0]))
 
 #define custom amiga_custom
 
@@ -55,7 +54,7 @@ void __init amiga_init_sound(void)
memcpy (snd_data, sine_data, sizeof(sine_data));
 
/* setup divisor */
-   clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE;
+   clock_constant = (amiga_colorclock + ARRAY_SIZE(sine_data) /2) / 
ARRAY_SIZE(sine_data);
 
/* without amifb, turn video off and enable high quality sound */
 #ifndef CONFIG_FB_AMIGA
diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h
index 31393d1..733622a 100644
--- a/arch/powerpc/boot/types.h
+++ b/arch/powerpc/boot/types.h
@@ -1,8 +1,6 @@
 #ifndef _TYPES_H_
 #define _TYPES_H_
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 typedef unsigned char  u8;
 typedef unsigned short u16;
 typedef unsigned int   u32;
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index e8dac81..5c8c433 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -209,14 +209,12 @@ static struct {
{ "SUNW,sun4v-pci", sun4v_pci_init },
{ "pciex108e,80f0", fire_pci_init },
 };
-#define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \
- sizeof(pci_controller_table[0]))
 
 static int __init pci_controller_init(const char *model_name, int namelen, 
struct device_node *dp)
 {
int i;
 
-   for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) {
+   for (i = 0; i < ARRAY_SIZE(pci_controller_table); i++) {
if (!strncmp(model_name,
 pci_controller_table[i].model_name,
 namelen)) {
@@ -232,7 +230,7 @@ static int __init pci_is_controller(const char *model_name, 
int namelen, struct
 {
int i;
 
-   for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) {
+   for (i = 0; i < ARRAY_SIZE(pci_controller_table); i++) {
if (!strncmp(model_name,
 pci_controller_table[i].model_name,
 namelen)) {
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index 0042b7e..5da86d5 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -122,7 +122,7 @@ acpi_status acpi_ut_osi_implementation(struct 
acpi_walk_state *walk_state)
 
/* Compare input string to static table of supported interfaces */
 
-   for (i = 0; i < ACPI_A

[PATCH] spin_lock_unlocked cleanups

2007-09-27 Thread roel
Replace some SPIN_LOCK_UNLOCKED with DEFINE_SPINLOCK

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
---
diff --git a/arch/mips/pci/ops-pmcmsp.c b/arch/mips/pci/ops-pmcmsp.c
index 09fa007..059eade 100644
--- a/arch/mips/pci/ops-pmcmsp.c
+++ b/arch/mips/pci/ops-pmcmsp.c
@@ -206,7 +206,7 @@ static void pci_proc_init(void)
 }
 #endif /* CONFIG_PROC_FS && PCI_COUNTERS */
 
-spinlock_t bpci_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(bpci_lock);
 
 /*
  *
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index d5fd390..cd2766e 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -34,7 +34,7 @@
 #include 
 #include 
 
-static spinlock_t slice_convert_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(slice_convert_lock);
 
 
 #ifdef DEBUG
diff --git a/drivers/char/watchdog/bfin_wdt.c b/drivers/char/watchdog/bfin_wdt.c
index 309d279..31dc7a6 100644
--- a/drivers/char/watchdog/bfin_wdt.c
+++ b/drivers/char/watchdog/bfin_wdt.c
@@ -71,7 +71,7 @@ static int nowayout = WATCHDOG_NOWAYOUT;
 static struct watchdog_info bfin_wdt_info;
 static unsigned long open_check;
 static char expect_close;
-static spinlock_t bfin_wdt_spinlock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(bfin_wdt_spinlock);
 
 /**
  * bfin_wdt_keepalive - Keep the Userspace Watchdog Alive
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 98fd985..36c747b 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -488,7 +488,7 @@ void hpsb_selfid_complete(struct hpsb_host *host, int 
phyid, int isroot)
highlevel_host_reset(host);
 }
 
-static spinlock_t pending_packets_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(pending_packets_lock);
 
 /**
  * hpsb_packet_sent - notify core of sending a packet
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 83e76b3..94fd78f 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -15,9 +15,9 @@
 #include "sysfs.h"
 
 DEFINE_MUTEX(sysfs_mutex);
-spinlock_t sysfs_assoc_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(sysfs_assoc_lock);
 
-static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(sysfs_ino_lock);
 static DEFINE_IDA(sysfs_ino_ida);
 
 /**
-
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: [RFC] QoS params patch

2007-09-27 Thread roel
Mark Gross wrote:
> On Wed, Sep 26, 2007 at 04:41:59PM -0700, Randy Dunlap wrote:
>> On Wed, 26 Sep 2007 15:40:26 -0700 Mark Gross wrote:
>>
>>> The following is the qos_param patch that implements a genralization of
>>> latency.c.
>>>
>> Just some general comments (as on irc):
>>
>> - use 'diffstat -p1 -w70' to summarize each patch
>> - use checkpatch.pl to check for coding style and other buglets
> 
> done
> 
>> - has no API docs  :(
> not done yet.
>>
>>
>>
>>> +/* assumes qos_lock is held */
>>> +static void update_target(int i)
>> I'd prefer a better arg name than 'i'.
> 
> I do too, but i in this case is an Index.

I think in many cases you could use a pointer to qos_array[i] instead of 
passing this index 'i' as a function argument.

Roel
-
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: [RFC] QoS params patch

2007-09-27 Thread roel
Mark Gross wrote:
 On Wed, Sep 26, 2007 at 04:41:59PM -0700, Randy Dunlap wrote:
 On Wed, 26 Sep 2007 15:40:26 -0700 Mark Gross wrote:

 The following is the qos_param patch that implements a genralization of
 latency.c.

 Just some general comments (as on irc):

 - use 'diffstat -p1 -w70' to summarize each patch
 - use checkpatch.pl to check for coding style and other buglets
 
 done
 
 - has no API docs  :(
 not done yet.



 +/* assumes qos_lock is held */
 +static void update_target(int i)
 I'd prefer a better arg name than 'i'.
 
 I do too, but i in this case is an Index.

I think in many cases you could use a pointer to qos_array[i] instead of 
passing this index 'i' as a function argument.

Roel
-
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] spin_lock_unlocked cleanups

2007-09-27 Thread roel
Replace some SPIN_LOCK_UNLOCKED with DEFINE_SPINLOCK

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---
diff --git a/arch/mips/pci/ops-pmcmsp.c b/arch/mips/pci/ops-pmcmsp.c
index 09fa007..059eade 100644
--- a/arch/mips/pci/ops-pmcmsp.c
+++ b/arch/mips/pci/ops-pmcmsp.c
@@ -206,7 +206,7 @@ static void pci_proc_init(void)
 }
 #endif /* CONFIG_PROC_FS  PCI_COUNTERS */
 
-spinlock_t bpci_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(bpci_lock);
 
 /*
  *
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index d5fd390..cd2766e 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -34,7 +34,7 @@
 #include asm/mmu.h
 #include asm/spu.h
 
-static spinlock_t slice_convert_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(slice_convert_lock);
 
 
 #ifdef DEBUG
diff --git a/drivers/char/watchdog/bfin_wdt.c b/drivers/char/watchdog/bfin_wdt.c
index 309d279..31dc7a6 100644
--- a/drivers/char/watchdog/bfin_wdt.c
+++ b/drivers/char/watchdog/bfin_wdt.c
@@ -71,7 +71,7 @@ static int nowayout = WATCHDOG_NOWAYOUT;
 static struct watchdog_info bfin_wdt_info;
 static unsigned long open_check;
 static char expect_close;
-static spinlock_t bfin_wdt_spinlock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(bfin_wdt_spinlock);
 
 /**
  * bfin_wdt_keepalive - Keep the Userspace Watchdog Alive
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 98fd985..36c747b 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -488,7 +488,7 @@ void hpsb_selfid_complete(struct hpsb_host *host, int 
phyid, int isroot)
highlevel_host_reset(host);
 }
 
-static spinlock_t pending_packets_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(pending_packets_lock);
 
 /**
  * hpsb_packet_sent - notify core of sending a packet
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 83e76b3..94fd78f 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -15,9 +15,9 @@
 #include sysfs.h
 
 DEFINE_MUTEX(sysfs_mutex);
-spinlock_t sysfs_assoc_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(sysfs_assoc_lock);
 
-static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(sysfs_ino_lock);
 static DEFINE_IDA(sysfs_ino_ida);
 
 /**
-
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] removes array_size duplicates

2007-09-27 Thread roel
This patch removes some ARRAY_SIZE macro duplicates. There is also one in
arch/um/include/user.h, which isn't fixed here because comments in that file
explicitly state a preference for the 'less fancy' version. If that's the
case as well for any of the other replacements please comment.

Signed-off-by: Roel Kluin [EMAIL PROTECTED]
---

 Documentation/spi/spidev_test.c|2 --
 arch/i386/boot/compressed/relocs.c |1 -
 arch/m68k/amiga/amisound.c |3 +--
 arch/powerpc/boot/types.h  |2 --
 arch/sparc64/kernel/pci.c  |6 ++
 drivers/acpi/utilities/uteval.c|4 ++--
 drivers/net/irda/actisys-sir.c |6 ++
 drivers/net/lp486e.c   |4 +---
 drivers/net/sk98lin/skgemib.c  |5 -
 drivers/net/skfp/smt.c |4 +---
 drivers/net/skfp/srf.c |   18 +++---
 drivers/net/wireless/ipw2100.c |   13 -
 drivers/serial/68328serial.c   |6 ++
 drivers/video/sgivwfb.c|4 ++--
 include/acpi/acmacros.h|2 --
 include/linux/netfilter/xt_sctp.h  |   12 +---
 include/net/ip_vs.h|1 -
 include/video/sgivw.h  |1 -
 net/ipv4/ipvs/ip_vs_proto_tcp.c|2 +-
 scripts/mod/file2alias.c   |2 --
 20 files changed, 30 insertions(+), 68 deletions(-)

diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c
index 218e862..0f23aac 100644
--- a/Documentation/spi/spidev_test.c
+++ b/Documentation/spi/spidev_test.c
@@ -21,8 +21,6 @@
 #include linux/types.h
 #include linux/spi/spidev.h
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-
 static void pabort(const char *s)
 {
perror(s);
diff --git a/arch/i386/boot/compressed/relocs.c 
b/arch/i386/boot/compressed/relocs.c
index 2d77ee7..5d8dbff 100644
--- a/arch/i386/boot/compressed/relocs.c
+++ b/arch/i386/boot/compressed/relocs.c
@@ -11,7 +11,6 @@
 #include endian.h
 
 #define MAX_SHDRS 100
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 static Elf32_Ehdr ehdr;
 static Elf32_Shdr shdr[MAX_SHDRS];
 static Elf32_Sym  *symtab[MAX_SHDRS];
diff --git a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c
index 1f5bfb5..8d013a1 100644
--- a/arch/m68k/amiga/amisound.c
+++ b/arch/m68k/amiga/amisound.c
@@ -21,7 +21,6 @@ static const signed char sine_data[] = {
0,  39,  75,  103,  121,  127,  121,  103,  75,  39,
0, -39, -75, -103, -121, -127, -121, -103, -75, -39
 };
-#define DATA_SIZE  (sizeof(sine_data)/sizeof(sine_data[0]))
 
 #define custom amiga_custom
 
@@ -55,7 +54,7 @@ void __init amiga_init_sound(void)
memcpy (snd_data, sine_data, sizeof(sine_data));
 
/* setup divisor */
-   clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE;
+   clock_constant = (amiga_colorclock + ARRAY_SIZE(sine_data) /2) / 
ARRAY_SIZE(sine_data);
 
/* without amifb, turn video off and enable high quality sound */
 #ifndef CONFIG_FB_AMIGA
diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h
index 31393d1..733622a 100644
--- a/arch/powerpc/boot/types.h
+++ b/arch/powerpc/boot/types.h
@@ -1,8 +1,6 @@
 #ifndef _TYPES_H_
 #define _TYPES_H_
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 typedef unsigned char  u8;
 typedef unsigned short u16;
 typedef unsigned int   u32;
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index e8dac81..5c8c433 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -209,14 +209,12 @@ static struct {
{ SUNW,sun4v-pci, sun4v_pci_init },
{ pciex108e,80f0, fire_pci_init },
 };
-#define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \
- sizeof(pci_controller_table[0]))
 
 static int __init pci_controller_init(const char *model_name, int namelen, 
struct device_node *dp)
 {
int i;
 
-   for (i = 0; i  PCI_NUM_CONTROLLER_TYPES; i++) {
+   for (i = 0; i  ARRAY_SIZE(pci_controller_table); i++) {
if (!strncmp(model_name,
 pci_controller_table[i].model_name,
 namelen)) {
@@ -232,7 +230,7 @@ static int __init pci_is_controller(const char *model_name, 
int namelen, struct
 {
int i;
 
-   for (i = 0; i  PCI_NUM_CONTROLLER_TYPES; i++) {
+   for (i = 0; i  ARRAY_SIZE(pci_controller_table); i++) {
if (!strncmp(model_name,
 pci_controller_table[i].model_name,
 namelen)) {
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index 0042b7e..5da86d5 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -122,7 +122,7 @@ acpi_status acpi_ut_osi_implementation(struct 
acpi_walk_state *walk_state)
 
/* Compare input string to static table of supported interfaces */
 
-   for (i = 0; i  ACPI_ARRAY_LENGTH

Re: [PATCH 13/25] Unionfs: add un/likely conditionals on dir ops

2007-09-26 Thread roel
Erez Zadok wrote:

> @@ -194,7 +194,7 @@ int check_empty(struct dentry *dentry, struct 
> unionfs_dir_state **namelist)
>  
>   BUG_ON(!S_ISDIR(dentry->d_inode->i_mode));
>  
> - if ((err = unionfs_partial_lookup(dentry)))
> + if (unlikely((err = unionfs_partial_lookup(dentry
>   goto out;
>  
>   bstart = dbstart(dentry);

Is it bad to leave this assignment within the unlikely()?
-
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 11/25] Unionfs: add un/likely conditionals on debug ops

2007-09-26 Thread roel
Erez Zadok wrote:
> Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>
> ---
>  fs/unionfs/debug.c |  108 +++
>  1 files changed, 57 insertions(+), 51 deletions(-)
> 
> diff --git a/fs/unionfs/debug.c b/fs/unionfs/debug.c
> index 9546a41..09b52ce 100644
> --- a/fs/unionfs/debug.c
> +++ b/fs/unionfs/debug.c
> @@ -56,19 +56,19 @@ void __unionfs_check_inode(const struct inode *inode,
>   sb = inode->i_sb;
>   istart = ibstart(inode);
>   iend = ibend(inode);
> - if (istart > iend) {
> + if (unlikely(istart > iend)) {
>   PRINT_CALLER(fname, fxn, line);
>   printk(" Ci0: inode=%p istart/end=%d:%d\n",
>  inode, istart, iend);
>   }
> - if ((istart == -1 && iend != -1) ||
> - (istart != -1 && iend == -1)) {
> + if (unlikely((istart == -1 && iend != -1) ||
> +  (istart != -1 && iend == -1))) {

you could also do
if (unlikely((istart == -1 || iend == -1) && istart != iend)) {

[...]

> @@ -138,8 +139,8 @@ void __unionfs_check_dentry(const struct dentry *dentry,
>   dend = dbend(dentry);
>   BUG_ON(dstart > dend);
>  
> - if ((dstart == -1 && dend != -1) ||
> - (dstart != -1 && dend == -1)) {
> + if (unlikely((dstart == -1 && dend != -1) ||
> +  (dstart != -1 && dend == -1))) {

[...]

the same here

> @@ -223,30 +224,30 @@ void __unionfs_check_dentry(const struct dentry *dentry,
>   istart = ibstart(inode);
>   iend = ibend(inode);
>   BUG_ON(istart > iend);
> - if ((istart == -1 && iend != -1) ||
> - (istart != -1 && iend == -1)) {
> + if (unlikely((istart == -1 && iend != -1) ||
> +  (istart != -1 && iend == -1))) {

and here

[...]

> @@ -350,30 +354,30 @@ void __unionfs_check_file(const struct file *file,
>   fend = fbend(file);
>   BUG_ON(fstart > fend);
>  
> - if ((fstart == -1 && fend != -1) ||
> - (fstart != -1 && fend == -1)) {
> + if (unlikely((fstart == -1 && fend != -1) ||
> +  (fstart != -1 && fend == -1))) {

and here

[...]
-
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 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread roel
Matthew Wilcox wrote:
> On Wed, Sep 26, 2007 at 09:47:41PM +0200, roel wrote:
>> The brackets in the first if/else are not required, and you could combine 
>> the two statements:
> 
> You mean braces, not brackets.  And I find this little fetish of yours
> highly disturbing.  I prefer to use braces, and will continue to do so,
> regardless of your nitpicking.

Well as you say it, you like the braces, so it appears to be your fetish. Of 
course you don't 
have to make any changes, I am just reporting them cause they aren't needed. No 
need for the
offensive tone either.

Roel
-
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 7/8] taskstats: fix stats->ac_exitcode to work on threads and use group_exit_code

2007-09-26 Thread roel
Guillaume Chazarain wrote:

[...]

> @@ -65,13 +65,15 @@ void bacct_add_tsk(struct taskstats *stats, struct 
> task_struct *tsk)
>  void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *tsk,
>   bool tg_stats)
>  {
> + int group_exit_code;
> +
>   fill_wall_times(stats, tsk);
>  
> - if (thread_group_leader(tsk)) {
> - stats->ac_exitcode = tsk->exit_code;
> - if (tsk->flags & PF_FORKNOEXEC)
> - stats->ac_flag |= AFORK;
> - }
> + if (thread_group_leader(tsk) && ((tsk->flags & PF_FORKNOEXEC)))

if (thread_group_leader(tsk) && (tsk->flags & PF_FORKNOEXEC))

> + stats->ac_flag |= AFORK;
> +
> + group_exit_code = tg_stats ? tsk->signal->group_exit_code : 0;
> + stats->ac_exitcode = group_exit_code ? : tsk->exit_code;

Isn't this just confusing? why not

if (tg_stats) {
group_exit_code = tsk->signal->group_exit_code;
stats->ac_exitcode = group_exit_code;

} else {
group_exit_code = 0;
stats->ac_exitcode = tsk->exit_code;
}
-
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 4/4] dmapool: Improve memory usage for devices which can't cross boundaries

2007-09-26 Thread roel
Matthew Wilcox wrote:

[...]

> @@ -142,14 +144,13 @@ struct dma_pool *dma_pool_create(const char *name, 
> struct device *dev,
>   if ((size % align) != 0)
>   size = ALIGN(size, align);
>  
> - if (allocation == 0) {
> - if (PAGE_SIZE < size)
> - allocation = size;
> - else
> - allocation = PAGE_SIZE;
> - // FIXME: round up for less fragmentation
> - } else if (allocation < size)
> + allocation = max_t(size_t, size, PAGE_SIZE);
> +
> + if (!boundary) {
> + boundary = allocation;
> + } else if ((boundary < size) || (boundary & (boundary - 1))) {
>   return NULL;
> + }

if (!boundary)
boundary = allocation;
else if (boundary < size || boundary & (boundary - 1))
return NULL;

[...]

> @@ -190,11 +192,14 @@ struct dma_pool *dma_pool_create(const char *name, 
> struct device *dev,
>  static void pool_initialise_page(struct dma_pool *pool, struct dma_page 
> *page)
>  {
>   unsigned int offset = 0;
> + unsigned int next_boundary = pool->boundary;
>  
>   do {
>   unsigned int next = offset + pool->size;
> - if (unlikely((next + pool->size) >= pool->allocation))
> - next = pool->allocation;
> + if (unlikely((next + pool->size) >= next_boundary)) {

if (unlikely(next + pool->size >= next_boundary)) {

[...]
-
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 3/4] Change dmapool free block management

2007-09-26 Thread roel
Matthew Wilcox wrote:

[...]

> @@ -113,9 +133,12 @@ struct dma_pool *dma_pool_create(const char *name, 
> struct device *dev,
>   return NULL;
>   }
>  
> - if (size == 0)
> + if (size == 0) {
>   return NULL;
> -
> + } else if (size < 4) {
> + size = 4;
> + }

you could do without brackets

[...]

> @@ -263,34 +288,21 @@ void dma_pool_destroy(struct dma_pool *pool)
>   *
>   * This returns the kernel virtual address of a currently unused block,
>   * and reports its dma address through the handle.
> - * If such a memory block can't be allocated, null is returned.
> + * If such a memory block can't be allocated, %NULL is returned.
>   */
>  void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
>dma_addr_t * handle)
>  {
>   unsigned long flags;
>   struct dma_page *page;
> - int map, block;
>   size_t offset;
>   void *retval;
>  
>   spin_lock_irqsave(>lock, flags);
>   restart:
>   list_for_each_entry(page, >page_list, page_list) {
> - int i;
> - /* only cachable accesses here ... */
> - for (map = 0, i = 0;
> -  i < pool->blocks_per_page; i += BITS_PER_LONG, map++) {
> - if (page->bitmap[map] == 0)
> - continue;
> - block = ffz(~page->bitmap[map]);
> - if ((i + block) < pool->blocks_per_page) {
> - clear_bit(block, >bitmap[map]);
> - offset = (BITS_PER_LONG * map) + block;
> - offset *= pool->size;
> - goto ready;
> - }
> - }
> + if (page->offset < pool->allocation)
> + goto ready;
>   }
>   if (!(page = pool_alloc_page(pool, GFP_ATOMIC))) {

page = pool_alloc_page(pool, GFP_ATOMIC);
if(!page) {

[...]

> @@ -355,7 +366,7 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, 
> dma_addr_t dma)
>  {
>   struct dma_page *page;
>   unsigned long flags;
> - int map, block;
> + unsigned int offset;
>  
>   if ((page = pool_find_page(pool, dma)) == 0) {

page = pool_find_page(pool, dma);
if (page == 0) {

>   if (pool->dev)
> @@ -368,13 +379,9 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, 
> dma_addr_t dma)
>   return;
>   }
>  
> - block = dma - page->dma;
> - block /= pool->size;
> - map = block / BITS_PER_LONG;
> - block %= BITS_PER_LONG;
> -
> + offset = vaddr - page->vaddr;
>  #ifdef   CONFIG_DEBUG_SLAB
> - if (((dma - page->dma) + (void *)page->vaddr) != vaddr) {
> + if ((dma - page->dma) != offset) {

if (dma - page->dma != offset) {
[...]
-
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 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread roel
Matthew Wilcox wrote:
> Check that 'align' is a power of two, like the API specifies.
> Align 'size' to 'align' correctly -- the current code has an off-by-one.
> The ALIGN macro in kernel.h doesn't.
> 
> Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
> ---
>  mm/dmapool.c |   15 ---
>  1 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/dmapool.c b/mm/dmapool.c
> index a359b5e..f5d12a7 100644
> --- a/mm/dmapool.c
> +++ b/mm/dmapool.c
> @@ -107,17 +107,18 @@ struct dma_pool *dma_pool_create(const char *name, 
> struct device *dev,
>  {
>   struct dma_pool *retval;
>  
> - if (align == 0)
> + if (align == 0) {
>   align = 1;
> - if (size == 0)
> + } else if (align & (align - 1)) {
>   return NULL;
> - else if (size < align)
> - size = align;
> - else if ((size % align) != 0) {
> - size += align + 1;
> - size &= ~(align - 1);
>   }
>  
> + if (size == 0)
> + return NULL;

The brackets in the first if/else are not required, and you could combine the 
two statements:

if (align == 0)
align = 1;
else if (align & (align - 1) || size == 0)
return NULL;
> +
> + if ((size % align) != 0)
> + size = ALIGN(size, align);
> +
>   if (allocation == 0) {
>   if (PAGE_SIZE < size)
>   allocation = size;

-
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] Add iSCSI iBFT support.

2007-09-26 Thread roel
Konrad Rzeszutek wrote:

[...]

> +static ssize_t
> +ibft_read_binary(struct kobject *kobj, struct bin_attribute *attr, char *buf,
> +  loff_t off, size_t count)
> +{
> +
> + struct ibft_device *ibft = container_of(kobj, struct ibft_device, kobj);
> + ssize_t len = ibft->hdr->length;
> +
> + if (off > len)
> + return 0;
> +
> + if (off + count > len)
> + count = len - off;

maybe you want to use:

count = min(count, len - off)

> +
> + memcpy(buf, ibft->hdr + off, count);
> +
> + return count;
> +}

[...]

> +static struct ibft_device *ibft_idev;
> +/*
> + * ibft_init() - creates  sysfs tree entry for ibft data
> + */
> +static int __init ibft_init(void)
> +{
> + int rc = 0;
> +
> + printk(KERN_INFO "BIOS iBFT facility v%s %s\n", ISCSI_IBFT_VERSION,
> +ISCSI_IBFT_DATE);
> +
> + if (!ibft_phys)
> + find_ibft();
> +
> + /* What if the ibft_subsys is underneath another struct? */
> + rc = firmware_register(_subsys);
> + if (rc)
> + return rc;
> +
> + if (ibft_phys) {
> + printk(KERN_INFO "iBFT detected at 0x%lx.\n",
> +(unsigned long)ibft_phys);
> + ibft_idev = kzalloc(sizeof(*ibft_idev), GFP_KERNEL);
> + if (!ibft_idev)
> + return -ENOMEM;
> +
> + rc = ibft_device_register(ibft_idev);
> + if (rc) {
> + kfree(ibft_idev);
> + return rc;
> + }

you could do without this return statement (and the brackets) since rc is 
returned anyway...

> + } else {
> + printk(KERN_INFO "No iBFT detected.\n");
> + }

these brackets are not required either

> + return rc;

... here

> +}

[...]

Roel
-
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/


forcedeth question

2007-09-26 Thread roel
in file ./drivers/net/forcedeth.c
line 2142 of current git I have a
for (i=0;i<=np->register_size;i+= 32) {
   ^
shouldn't this be a '<'

In the same file on line 4015:
for (i = 0;i <= np->register_size/sizeof(u32); i++)

shouldn't the "<=" be a '<'?

Roel
-
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/


<    1   2   3   4   >