1. 27 1月, 2012 1 次提交
    • J
      [media] imon: don't wedge hardware after early callbacks · 8791d63a
      Jarod Wilson 提交于
      This patch is just a minor update to one titled "imon: Input from ffdc
      device type ignored" from Corinna Vinschen. An earlier patch to prevent
      an oops when we got early callbacks also has the nasty side-effect of
      wedging imon hardware, as we don't acknowledge the urb. Rework the check
      slightly here to bypass processing the packet, as the driver isn't yet
      fully initialized, but still acknowlege the urb and submit a new rx_urb.
      Do this for both interfaces -- irrelevant for ffdc hardware, but
      relevant for newer hardware, though newer hardware doesn't spew the
      constant stream of data as soon as the hardware is initialized like the
      older ffdc devices, so they'd be less likely to trigger this anyway...
      
      Tested with both an ffdc device and an 0042 device.
      Reported-by: NCorinna Vinschen <vinschen@redhat.com>
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      CC: stable@vger.kernel.org
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      8791d63a
  2. 19 11月, 2011 1 次提交
    • G
      USB: convert drivers/media/* to use module_usb_driver() · ecb3b2b3
      Greg Kroah-Hartman 提交于
      This converts the drivers in drivers/media/* to use the
      module_usb_driver() macro which makes the code smaller and a bit
      simpler.
      
      Added bonus is that it removes some unneeded kernel log messages about
      drivers loading and/or unloading.
      
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Cc: Luca Risolia <luca.risolia@studio.unibo.it>
      Cc: Jean-Francois Moine <moinejf@free.fr>
      Cc: Frank Zago <frank@zago.net>
      Cc: Olivier Lorin <o.lorin@laposte.net>
      Cc: Erik Andren <erik.andren@gmail.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Brian Johnson <brijohn@gmail.com>
      Cc: Leandro Costantino <lcostantino@gmail.com>
      Cc: Antoine Jacquet <royale@zerezo.com>
      Cc: Jarod Wilson <jarod@redhat.com>
      Cc: Florian Mickler <florian@mickler.org>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Michael Krufky <mkrufky@kernellabs.com>
      Cc: "David Härdeman" <david@hardeman.nu>
      Cc: Florent Audebert <florent.audebert@anevia.com>
      Cc: Sam Doshi <sam@metal-fish.co.uk>
      Cc: Manu Abraham <manu@linuxtv.org>
      Cc: Olivier Grenie <olivier.grenie@dibcom.fr>
      Cc: Patrick Boettcher <patrick.boettcher@dibcom.fr>
      Cc: "Igor M. Liplianin" <liplianin@me.by>
      Cc: Derek Kelly <user.vdr@gmail.com>
      Cc: Malcolm Priestley <tvboxspy@gmail.com>
      Cc: Steven Toth <stoth@kernellabs.com>
      Cc: "André Weidemann" <Andre.Weidemann@web.de>
      Cc: Martin Wilks <m.wilks@technisat.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Jose Alberto Reguero <jareguero@telefonica.net>
      Cc: David Henningsson <david.henningsson@canonical.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Jesper Juhl <jj@chaosbits.net>
      Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
      Cc: Hans Verkuil <hans.verkuil@cisco.com>
      Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>
      Cc: Anssi Hannula <anssi.hannula@iki.fi>
      Cc: Rafi Rubin <rafi@seas.upenn.edu>
      Cc: Dan Carpenter <error27@gmail.com>
      Cc: Paul Bender <pebender@gmail.com>
      Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
      Cc: "Márcio A Alves" <froooozen@gmail.com>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Chris Rankin <rankincj@yahoo.com>
      Cc: Lee Jones <lee.jones@canonical.com>
      Cc: Andy Walls <awalls@md.metrocast.net>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Mike Frysinger <vapier@gentoo.org>
      Cc: Dean Anderson <linux-dev@sensoray.com>
      Cc: Pete Eberlein <pete@sensoray.com>
      Cc: Arvydas Sidorenko <asido4@gmail.com>
      Cc: Andrea Anacleto <andreaanacleto@libero.it>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ecb3b2b3
  3. 22 9月, 2011 1 次提交
    • J
      [media] imon: don't parse scancodes until intf configured · 6f6b90c9
      Jarod Wilson 提交于
      The imon devices have either 1 or 2 usb interfaces on them, each wired
      up to its own urb callback. The interface 0 urb callback is wired up
      before the imon context's rc_dev pointer is filled in, which is
      necessary for imon 0xffdc device auto-detection to work properly, but we
      need to make sure we don't actually run the callback routines until
      we've entirely filled in the necessary bits for each given interface,
      lest we wind up oopsing. Technically, any imon device could have hit
      this, but the issue is exacerbated on the 0xffdc devices, which send a
      constant stream of interrupts, even when they have no valid key data.
      
      CC: Andy Walls <awalls@md.metrocast.net>
      CC: Chris W <lkml@psychogeeks.com>
      Reported-by: NChris W <lkml@psychogeeks.com>
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      6f6b90c9
  4. 06 8月, 2011 1 次提交
  5. 02 7月, 2011 2 次提交
  6. 11 6月, 2011 2 次提交
  7. 21 5月, 2011 2 次提交
  8. 29 4月, 2011 1 次提交
    • J
      [media] imon: add conditional locking in change_protocol · 23ef710e
      Jarod Wilson 提交于
      The imon_ir_change_protocol function gets called two different ways, one
      way is from rc_register_device, for initial protocol selection/setup,
      and the other is via a userspace-initiated protocol change request,
      either by direct sysfs prodding or by something like ir-keytable.
      
      In the rc_register_device case, the imon context lock is already held,
      but when initiated from userspace, it is not, so we must acquire it,
      prior to calling send_packet, which requires that the lock is held.
      
      Without this change, there's an easily reproduceable deadlock when
      another function calls send_packet (such as either of the display write
      fops) after a userspace-initiated change_protocol.
      
      With a lock-debugging-enabled kernel, I was getting this:
      
      [   15.014153] =====================================
      [   15.015048] [ BUG: bad unlock balance detected! ]
      [   15.015048] -------------------------------------
      [   15.015048] ir-keytable/773 is trying to release lock (&ictx->lock) at:
      [   15.015048] [<ffffffff814c6297>] mutex_unlock+0xe/0x10
      [   15.015048] but there are no more locks to release!
      [   15.015048]
      [   15.015048] other info that might help us debug this:
      [   15.015048] 2 locks held by ir-keytable/773:
      [   15.015048]  #0:  (&buffer->mutex){+.+.+.}, at: [<ffffffff8119d400>] sysfs_write_file+0x3c/0x144
      [   15.015048]  #1:  (s_active#87){.+.+.+}, at: [<ffffffff8119d4ab>] sysfs_write_file+0xe7/0x144
      [   15.015048]
      [   15.015048] stack backtrace:
      [   15.015048] Pid: 773, comm: ir-keytable Not tainted 2.6.38.4-20.fc15.x86_64.debug #1
      [   15.015048] Call Trace:
      [   15.015048]  [<ffffffff81089715>] ? print_unlock_inbalance_bug+0xca/0xd5
      [   15.015048]  [<ffffffff8108b35c>] ? lock_release_non_nested+0xc1/0x263
      [   15.015048]  [<ffffffff814c6297>] ? mutex_unlock+0xe/0x10
      [   15.015048]  [<ffffffff814c6297>] ? mutex_unlock+0xe/0x10
      [   15.015048]  [<ffffffff8108b67b>] ? lock_release+0x17d/0x1a4
      [   15.015048]  [<ffffffff814c6229>] ? __mutex_unlock_slowpath+0xc5/0x125
      [   15.015048]  [<ffffffff814c6297>] ? mutex_unlock+0xe/0x10
      [   15.015048]  [<ffffffffa02964b6>] ? send_packet+0x1c9/0x264 [imon]
      [   15.015048]  [<ffffffff8108b376>] ? lock_release_non_nested+0xdb/0x263
      [   15.015048]  [<ffffffffa0296731>] ? imon_ir_change_protocol+0x126/0x15e [imon]
      [   15.015048]  [<ffffffffa024a334>] ? store_protocols+0x1c3/0x286 [rc_core]
      [   15.015048]  [<ffffffff81326e4e>] ? dev_attr_store+0x20/0x22
      [   15.015048]  [<ffffffff8119d4cc>] ? sysfs_write_file+0x108/0x144
      ...
      
      The original report that led to the investigation was the following:
      
      [ 1679.457305] INFO: task LCDd:8460 blocked for more than 120 seconds.
      [ 1679.457307] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [ 1679.457309] LCDd            D ffff88010fcd89c8     0  8460      1 0x00000000
      [ 1679.457312]  ffff8800d5a03b48 0000000000000082 0000000000000000 ffff8800d5a03fd8
      [ 1679.457314]  00000000012dcd30 fffffffffffffffd ffff8800d5a03fd8 ffff88010fcd86f0
      [ 1679.457316]  ffff8800d5a03fd8 ffff8800d5a03fd8 ffff88010fcd89d0 ffff8800d5a03fd8
      [ 1679.457319] Call Trace:
      [ 1679.457324]  [<ffffffff810ff1a5>] ? zone_statistics+0x75/0x90
      [ 1679.457327]  [<ffffffff810ea907>] ? get_page_from_freelist+0x3c7/0x820
      [ 1679.457330]  [<ffffffff813b0a49>] __mutex_lock_slowpath+0x139/0x320
      [ 1679.457335]  [<ffffffff813b0c41>] mutex_lock+0x11/0x30
      [ 1679.457338]  [<ffffffffa0d54216>] display_open+0x66/0x130 [imon]
      [ 1679.457345]  [<ffffffffa01d06c0>] usb_open+0x180/0x310 [usbcore]
      [ 1679.457349]  [<ffffffff81143b3b>] chrdev_open+0x1bb/0x2d0
      [ 1679.457350]  [<ffffffff8113d93d>] __dentry_open+0x10d/0x370
      [ 1679.457352]  [<ffffffff81143980>] ? chrdev_open+0x0/0x2d0
      ...
      
      Bump the driver version here so its easier to tell if people have this
      locking fix or not, and also make locking during probe easier to follow.
      
      CC: stable@kernel.org
      Reported-by: NBenjamin Hodgetts <ben@xnode.org>
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      23ef710e
  9. 31 3月, 2011 1 次提交
  10. 23 3月, 2011 1 次提交
  11. 19 1月, 2011 3 次提交
  12. 29 12月, 2010 7 次提交
  13. 24 10月, 2010 3 次提交
  14. 23 10月, 2010 1 次提交
  15. 21 10月, 2010 3 次提交
  16. 15 10月, 2010 1 次提交
    • A
      llseek: automatically add .llseek fop · 6038f373
      Arnd Bergmann 提交于
      All file_operations should get a .llseek operation so we can make
      nonseekable_open the default for future file operations without a
      .llseek pointer.
      
      The three cases that we can automatically detect are no_llseek, seq_lseek
      and default_llseek. For cases where we can we can automatically prove that
      the file offset is always ignored, we use noop_llseek, which maintains
      the current behavior of not returning an error from a seek.
      
      New drivers should normally not use noop_llseek but instead use no_llseek
      and call nonseekable_open at open time.  Existing drivers can be converted
      to do the same when the maintainer knows for certain that no user code
      relies on calling seek on the device file.
      
      The generated code is often incorrectly indented and right now contains
      comments that clarify for each added line why a specific variant was
      chosen. In the version that gets submitted upstream, the comments will
      be gone and I will manually fix the indentation, because there does not
      seem to be a way to do that using coccinelle.
      
      Some amount of new code is currently sitting in linux-next that should get
      the same modifications, which I will do at the end of the merge window.
      
      Many thanks to Julia Lawall for helping me learn to write a semantic
      patch that does all this.
      
      ===== begin semantic patch =====
      // This adds an llseek= method to all file operations,
      // as a preparation for making no_llseek the default.
      //
      // The rules are
      // - use no_llseek explicitly if we do nonseekable_open
      // - use seq_lseek for sequential files
      // - use default_llseek if we know we access f_pos
      // - use noop_llseek if we know we don't access f_pos,
      //   but we still want to allow users to call lseek
      //
      @ open1 exists @
      identifier nested_open;
      @@
      nested_open(...)
      {
      <+...
      nonseekable_open(...)
      ...+>
      }
      
      @ open exists@
      identifier open_f;
      identifier i, f;
      identifier open1.nested_open;
      @@
      int open_f(struct inode *i, struct file *f)
      {
      <+...
      (
      nonseekable_open(...)
      |
      nested_open(...)
      )
      ...+>
      }
      
      @ read disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      <+...
      (
         *off = E
      |
         *off += E
      |
         func(..., off, ...)
      |
         E = *off
      )
      ...+>
      }
      
      @ read_no_fpos disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ write @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      <+...
      (
        *off = E
      |
        *off += E
      |
        func(..., off, ...)
      |
        E = *off
      )
      ...+>
      }
      
      @ write_no_fpos @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ fops0 @
      identifier fops;
      @@
      struct file_operations fops = {
       ...
      };
      
      @ has_llseek depends on fops0 @
      identifier fops0.fops;
      identifier llseek_f;
      @@
      struct file_operations fops = {
      ...
       .llseek = llseek_f,
      ...
      };
      
      @ has_read depends on fops0 @
      identifier fops0.fops;
      identifier read_f;
      @@
      struct file_operations fops = {
      ...
       .read = read_f,
      ...
      };
      
      @ has_write depends on fops0 @
      identifier fops0.fops;
      identifier write_f;
      @@
      struct file_operations fops = {
      ...
       .write = write_f,
      ...
      };
      
      @ has_open depends on fops0 @
      identifier fops0.fops;
      identifier open_f;
      @@
      struct file_operations fops = {
      ...
       .open = open_f,
      ...
      };
      
      // use no_llseek if we call nonseekable_open
      ////////////////////////////////////////////
      @ nonseekable1 depends on !has_llseek && has_open @
      identifier fops0.fops;
      identifier nso ~= "nonseekable_open";
      @@
      struct file_operations fops = {
      ...  .open = nso, ...
      +.llseek = no_llseek, /* nonseekable */
      };
      
      @ nonseekable2 depends on !has_llseek @
      identifier fops0.fops;
      identifier open.open_f;
      @@
      struct file_operations fops = {
      ...  .open = open_f, ...
      +.llseek = no_llseek, /* open uses nonseekable */
      };
      
      // use seq_lseek for sequential files
      /////////////////////////////////////
      @ seq depends on !has_llseek @
      identifier fops0.fops;
      identifier sr ~= "seq_read";
      @@
      struct file_operations fops = {
      ...  .read = sr, ...
      +.llseek = seq_lseek, /* we have seq_read */
      };
      
      // use default_llseek if there is a readdir
      ///////////////////////////////////////////
      @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier readdir_e;
      @@
      // any other fop is used that changes pos
      struct file_operations fops = {
      ... .readdir = readdir_e, ...
      +.llseek = default_llseek, /* readdir is present */
      };
      
      // use default_llseek if at least one of read/write touches f_pos
      /////////////////////////////////////////////////////////////////
      @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read.read_f;
      @@
      // read fops use offset
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = default_llseek, /* read accesses f_pos */
      };
      
      @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ... .write = write_f, ...
      +	.llseek = default_llseek, /* write accesses f_pos */
      };
      
      // Use noop_llseek if neither read nor write accesses f_pos
      ///////////////////////////////////////////////////////////
      
      @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      identifier write_no_fpos.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ...
       .write = write_f,
       .read = read_f,
      ...
      +.llseek = noop_llseek, /* read and write both use no f_pos */
      };
      
      @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write_no_fpos.write_f;
      @@
      struct file_operations fops = {
      ... .write = write_f, ...
      +.llseek = noop_llseek, /* write uses no f_pos */
      };
      
      @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      @@
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = noop_llseek, /* read uses no f_pos */
      };
      
      @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      @@
      struct file_operations fops = {
      ...
      +.llseek = noop_llseek, /* no read or write fn */
      };
      ===== End semantic patch =====
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Christoph Hellwig <hch@infradead.org>
      6038f373
  17. 09 8月, 2010 2 次提交
  18. 03 8月, 2010 3 次提交
  19. 01 6月, 2010 2 次提交
  20. 19 5月, 2010 2 次提交
    • J
      V4L/DVB: IR/imon: remove dead IMON_KEY_RELEASE_OFFSET · 083e4721
      Jarod Wilson 提交于
      On Tue, May 04, 2010 at 06:06:41PM +0200, Dan Carpenter wrote:
      > On Tue, May 04, 2010 at 10:03:18AM -0400, Jarod Wilson wrote:
      > > @@ -1205,7 +1204,7 @@ static u32 imon_panel_key_lookup(u64 hw_code)
      > >  		if (imon_panel_key_table[i].hw_code == (code | 0xffee))
      > >  			break;
      > >
      > > -	keycode = imon_panel_key_table[i % IMON_KEY_RELEASE_OFFSET].keycode;
      > > +	keycode = imon_panel_key_table[i].keycode;
      > >
      > >  	return keycode;
      > >  }
      >
      > There is still potentially a problem here because if we don't hit the
      > break statement, then we're one past the end of the array.
      
      D'oh. Okay, here's v2, should fix that buglet too.
      
      This hack was used when the imon driver was using internal key lookup
      routines, but became dead weight when the driver was converted to use
      ir-core's key lookup routines. These bits simply didn't get removed,
      drop 'em now.
      
      Pointed out by Dan Carpenter.
      
      v2: fix possible attempt to access beyond end of key table array,
      also pointed out by Dan.
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      083e4721
    • D
      V4L/DVB: media/IR/imon: potential double unlock on error · 9723dbb0
      Dan Carpenter 提交于
      If there is an error here we should unlock in the caller (which is
      imon_init_intf1()).  We can remove this stray unlock.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Acked-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      9723dbb0