Re: Remaining BKL users, what to do

2010-09-21 Thread Petr Vandrovec
I'll try to come up with something for ncpfs.

Trivial lock replacement will open deadlock possibility when someone reads to 
page which is also mmaped from the same filesystem (like grep likes to do). BKL 
with its automated release on sleep helped (or papered over) a lot here.

Petr

Arnd Bergmann a...@arndb.de wrote:

On Thursday 16 September 2010, Anton Altaparmakov wrote:
 On 16 Sep 2010, at 16:04, Jan Kara wrote:
  On Thu 16-09-10 16:32:59, Arnd Bergmann wrote:
  The big kernel lock is gone from almost all code in linux-next, this is
  the status of what I think will happen to the remaining users:
  ...
  fs/ncpfs:
   Should be fixable if Petr still cares about it. Otherwise suggest
   moving to drivers/staging if there are no users left.
   I think some people still use this...
 
 Yes, indeed.  Netware is still alive (unfortunately!) and ncpfs is used in a 
 lot of 
 Universities here in the UK at least (we use it about a thousand 
 workstations and
 servers here at Cambridge University!).

Ok, that means at least when someone gets around to fix it, there will be
people that can test the patches.

If you know someone who would like to help on this, it would be nice to try
out the patch below, unless someone can come up with a better solution.
My naïve understanding of the code tells me that simply using the super block
lock there may work. In fact it makes locking stricter, so if it still works
with that patch, there are probably no subtle regressions.
The patch applies to current linux-next of my bkl/vfs series.

   Arnd

---
ncpfs: replace BKL with lock_super

This mindlessly changes every instance of lock_kernel in ncpfs to
lock_super. I haven't tested this, it may work or may break horribly.
Please test with CONFIG_LOCKDEP enabled.

Signed-off-by: Arnd Bergmann a...@arndb.de

diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 9578cbe..303338d 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -19,7 +19,6 @@
 #include linux/mm.h
 #include asm/uaccess.h
 #include asm/byteorder.h
-#include linux/smp_lock.h
 
 #include linux/ncp_fs.h
 
@@ -339,9 +338,10 @@ static int
 ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd)
 {
   int res;
-  lock_kernel();
+  struct super_block *sb = dentry-d_inode-i_sb;
+  lock_super(sb);
   res = __ncp_lookup_validate(dentry);
-  unlock_kernel();
+  unlock_super(sb);
   return res;
 }
 
@@ -404,6 +404,7 @@ static int ncp_readdir(struct file *filp, void *dirent, 
filldir_t filldir)
 {
   struct dentry *dentry = filp-f_path.dentry;
   struct inode *inode = dentry-d_inode;
+  struct super_block *sb = inode-i_sb;
   struct page *page = NULL;
   struct ncp_server *server = NCP_SERVER(inode);
   union  ncp_dir_cache *cache = NULL;
@@ -411,7 +412,7 @@ static int ncp_readdir(struct file *filp, void *dirent, 
filldir_t filldir)
   int result, mtime_valid = 0;
   time_t mtime = 0;
 
-  lock_kernel();
+  lock_super(sb);
 
   ctl.page  = NULL;
   ctl.cache = NULL;
@@ -546,7 +547,7 @@ finished:
   page_cache_release(ctl.page);
   }
 out:
-  unlock_kernel();
+  unlock_super(sb);
   return result;
 }
 
@@ -794,12 +795,13 @@ out:
 static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, 
 struct nameidata *nd)
 {
   struct ncp_server *server = NCP_SERVER(dir);
+  struct super_block *sb = dir-i_sb;
   struct inode *inode = NULL;
   struct ncp_entry_info finfo;
   int error, res, len;
   __u8 __name[NCP_MAXPATHLEN + 1];
 
-  lock_kernel();
+  lock_super(sb);
   error = -EIO;
   if (!ncp_conn_valid(server))
   goto finished;
@@ -846,7 +848,7 @@ add_entry:
 
 finished:
   PPRINTK(ncp_lookup: result=%d\n, error);
-  unlock_kernel();
+  unlock_super(sb);
   return ERR_PTR(error);
 }
 
@@ -880,6 +882,7 @@ int ncp_create_new(struct inode *dir, struct dentry 
*dentry, int mode,
 {
   struct ncp_server *server = NCP_SERVER(dir);
   struct ncp_entry_info finfo;
+  struct super_block *sb = dir-i_sb;
   int error, result, len;
   int opmode;
   __u8 __name[NCP_MAXPATHLEN + 1];
@@ -888,7 +891,7 @@ int ncp_create_new(struct inode *dir, struct dentry 
*dentry, int mode,
   dentry-d_parent-d_name.name, dentry-d_name.name, mode);
 
   error = -EIO;
-  lock_kernel();
+  lock_super(sb);
   if (!ncp_conn_valid(server))
   goto out;
 
@@ -935,7 +938,7 @@ int ncp_create_new(struct inode *dir, struct dentry 
*dentry, int mode,
 
   error = ncp_instantiate(dir, dentry, finfo);
 out:
-  unlock_kernel();
+  unlock_super(sb);
   return error;
 }
 
@@ -949,6 +952,7 @@ static int ncp_mkdir(struct inode *dir, struct dentry 
*dentry, int mode)
 {
   struct ncp_entry_info finfo;
   struct ncp_server *server = NCP_SERVER(dir);
+  struct super_block *sb = dir-i_sb;
   int error, len;
   __u8 

Re: [resend] radio-sf16fmi: fix mute, add SF16-FMP to texts

2009-12-01 Thread Petr Vandrovec

Ondrej Zary wrote:

Fix completely broken mute handling radio-sf16fmi.
The sound was muted immediately after tuning in KRadio.
Also fix typos and add SF16-FMP to the texts.


I do not have device anymore.  Looks OK to me.


Signed-off-by: Ondrej Zary li...@rainbow-software.org


Acked-by: Petr Vandrovec p...@vandrovec.name

To whom should I forward this (and your second patch), I did not do any 
SF16 work for 10 years (and no LKML for 3).

Thanks,
Petr



diff -urp linux-source-2.6.31-orig/drivers/media/radio/Kconfig 
linux-source-2.6.31/drivers/media/radio/Kconfig
--- linux-source-2.6.31-orig/drivers/media/radio/Kconfig2009-09-10 
00:13:59.0 +0200
+++ linux-source-2.6.31/drivers/media/radio/Kconfig 2009-11-28 
11:51:42.0 +0100
@@ -196,7 +196,7 @@ config RADIO_MAESTRO
  module will be called radio-maestro.
 
 config RADIO_SF16FMI

-   tristate SF16FMI Radio
+   tristate SF16-FMI/SF16-FMP Radio
depends on ISA  VIDEO_V4L2
---help---
  Choose Y here if you have one of these FM radio cards.  If you
diff -urp linux-source-2.6.31-orig/drivers/media/radio/radio-sf16fmi.c 
linux-source-2.6.31/drivers/media/radio/radio-sf16fmi.c
--- linux-source-2.6.31-orig/drivers/media/radio/radio-sf16fmi.c
2009-09-10 00:13:59.0 +0200
+++ linux-source-2.6.31/drivers/media/radio/radio-sf16fmi.c 2009-11-28 
11:39:35.0 +0100
@@ -1,4 +1,4 @@
-/* SF16FMI radio driver for Linux radio support
+/* SF16-FMI and SF16-FMP radio driver for Linux radio support
  * heavily based on rtrack driver...
  * (c) 1997 M. Kirkwood
  * (c) 1998 Petr Vandrovec, vandr...@vc.cvut.cz
@@ -11,7 +11,7 @@
  *
  *  Frequency control is done digitally -- ie out(port,encodefreq(95.8));
  *  No volume control - only mute/unmute - you have to use line volume
- *  control on SB-part of SF16FMI
+ *  control on SB-part of SF16-FMI/SF16-FMP
  *
  * Converted to V4L2 API by Mauro Carvalho Chehab mche...@infradead.org
  */
@@ -30,14 +30,14 @@
 #include media/v4l2-ioctl.h
 
 MODULE_AUTHOR(Petr Vandrovec, vandr...@vc.cvut.cz and M. Kirkwood);

-MODULE_DESCRIPTION(A driver for the SF16MI radio.);
+MODULE_DESCRIPTION(A driver for the SF16-FMI and SF16-FMP radio.);
 MODULE_LICENSE(GPL);
 
 static int io = -1;

 static int radio_nr = -1;
 
 module_param(io, int, 0);

-MODULE_PARM_DESC(io, I/O address of the SF16MI card (0x284 or 0x384));
+MODULE_PARM_DESC(io, I/O address of the SF16-FMI or SF16-FMP card (0x284 or 
0x384));
 module_param(radio_nr, int, 0);
 
 #define RADIO_VERSION KERNEL_VERSION(0, 0, 2)

@@ -47,7 +47,7 @@ struct fmi
struct v4l2_device v4l2_dev;
struct video_device vdev;
int io;
-   int curvol; /* 1 or 0 */
+   bool mute;
unsigned long curfreq; /* freq in kHz */
struct mutex lock;
 };
@@ -105,7 +105,7 @@ static inline int fmi_setfreq(struct fmi
outbits(8, 0xC0, fmi-io);
msleep(143);/* was schedule_timeout(HZ/7) */
mutex_unlock(fmi-lock);
-   if (fmi-curvol)
+   if (!fmi-mute)
fmi_unmute(fmi);
return 0;
 }
@@ -116,7 +116,7 @@ static inline int fmi_getsigstr(struct f
int res;
 
 	mutex_lock(fmi-lock);

-   val = fmi-curvol ? 0x08 : 0x00; /* unmute/mute */
+   val = fmi-mute ? 0x00 : 0x08;   /* mute/unmute */
outb(val, fmi-io);
outb(val | 0x10, fmi-io);
msleep(143);/* was schedule_timeout(HZ/7) */
@@ -204,7 +204,7 @@ static int vidioc_g_ctrl(struct file *fi
 
 	switch (ctrl-id) {

case V4L2_CID_AUDIO_MUTE:
-   ctrl-value = fmi-curvol;
+   ctrl-value = fmi-mute;
return 0;
}
return -EINVAL;
@@ -221,7 +221,7 @@ static int vidioc_s_ctrl(struct file *fi
fmi_mute(fmi);
else
fmi_unmute(fmi);
-   fmi-curvol = ctrl-value;
+   fmi-mute = ctrl-value;
return 0;
}
return -EINVAL;




--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html