1. 12 Nov, 2013 27 commits
    • Aldo Iljazi's avatar
      Staging: ft1000: boot.h: fixed a few styling issues · c766d23b
      Aldo Iljazi authored
      Fixed the following styling issues:
      
      Line 30:
      Removed space before open square bracket '['
      
      Lines 31 to 155:
      Moved the commas that were in the start of the lines, to the end of the lines.
      Inserted spaces after the commas.
      Inserted a one tab indentation to each line.
      Signed-off-by: default avatarAldo Iljazi <mail@aldo.io>
      Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c766d23b
    • Masanari Iida's avatar
      staging: android: Fix typo in android/sync.h · 4e20effa
      Masanari Iida authored
      Correct spelling typo in android/sync.h
      Signed-off-by: default avatarMasanari Iida <standby24x7@gmail.com>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e20effa
    • Chen Gang's avatar
      drivers: staging: speakup: serialio: only use platform specific SERIAL_PORT_DFNS. · 5e6dc548
      Chen Gang authored
      If SERIAL_PORT_DFNS isn't present by platform, it need be defined to
      "nothing", like the 8250 serial driver does it.
      
      All related macros also need be removed: IRQF_SHARED is defined in
      "linux/interrupt.h", others will be defined when related architecture
      has SERIAL_PORT_DFNS.
      
      Or it will cause issue (for arc, with allmodconfig):
      
          CC [M]  drivers/staging/speakup/serialio.o
        drivers/staging/speakup/serialio.c:12:2: error: initializer element is not constant
          SERIAL_PORT_DFNS
          ^
        drivers/staging/speakup/serialio.c:12:2: error: (near initialization for 'rs_table[0].baud_base')
        drivers/staging/speakup/serialio.c:12:2: error: initializer element is not constant
        drivers/staging/speakup/serialio.c:12:2: error: (near initialization for 'rs_table[1].baud_base')
        drivers/staging/speakup/serialio.c:12:2: error: initializer element is not constant
        drivers/staging/speakup/serialio.c:12:2: error: (near initialization for 'rs_table[2].baud_base')
        drivers/staging/speakup/serialio.c:12:2: error: initializer element is not constant
        drivers/staging/speakup/serialio.c:12:2: error: (near initialization for 'rs_table[3].baud_base')
      Signed-off-by: default avatarChen Gang <gang.chen@asianux.com>
      Acked-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e6dc548
    • Duan Jiong's avatar
      lustre/fld: replace IS_ERR and PTR_ERR with PTR_ERR_OR_ZERO · 95bcc666
      Duan Jiong authored
      This patch fixes coccinelle error regarding usage of IS_ERR and
      PTR_ERR instead of PTR_ERR_OR_ZERO.
      Signed-off-by: default avatarDuan Jiong <duanj.fnst@cn.fujitsu.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95bcc666
    • Ian Abbott's avatar
      staging: comedi: protect buffer from being freed while mmapped · af93da31
      Ian Abbott authored
      If a comedi device is automatically detached by `comedi_auto_unconfig()`
      any data buffers associated with subdevices that support asynchronous
      commands will be freed.  If the buffer is mmapped at the time, bad
      things are likely to happen!  Prevent this by moving some of the buffer
      details from `struct comedi_async` into a new, dynamically allocated,
      and kref-counted `struct comedi_buf_map`.  This holds a list of pages, a
      reference count, and enough information to free the pages.  The new
      member `buf_map` of `struct comedi_async` points to a `struct
      comedi_buf_map` when the buffer size is non-zero.
      
      Provide a new helper function `comedi_buf_is_mapped()` to check whether
      an a buffer is mmapped.  If it is mmapped, the buffer is not allowed to
      be resized and the device is not allowed to be manually detached by the
      `COMEDI_DEVCONFIG` ioctl.  Provide helper functions
      `comedi_buf_map_get()` and `comedi_buf_map_put()` to manipulate the
      reference count of the `struct comedi_buf_map`, which will be freed
      along with its contents via the 'release' callback of the `kref_put()`
      call.  The reference count is manipulated by the vma operations and the
      mmap file operation.
      
      Now, when the comedi device is automatically detached, the buffer will
      be effectively freed by calling `comedi_buf_alloc()` with a new buffer
      size of 0.  That calls local function `__comedi_buf_free()` which calls
      `comedi_buf_map_put()` on the `buf_map` member to free it.  It won't
      actually be freed until the final 'put'.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af93da31
    • Ian Abbott's avatar
      staging: comedi: make determination of read or write subdevice safer · 63ab0395
      Ian Abbott authored
      `comedi_read_subdevice()` and `comedi_write_subdevice()` respectively
      determine the read and write subdevice to use for a comedi device,
      depending on a minor device number passed in.  The comedi device has a
      main "board" minor device number and may also have dynamically assigned,
      subdevice-specific minor device numbers, in a range of numbers shared by
      all comedi devices.  If the minor device number is within the range of
      subdevice-specific minor device numbers, both functions call
      `comedi_subdevice_from_minor()` to determine what subdevice is
      associated with the minor device number (if any) and then check the
      subdevice belongs to the comedi device.  Since the subdevice might
      belong to a different comedi device, the check is not protected against
      the subdevice being freed.  Perform the check in
      `comedi_subdevice_from_minor()` instead, where it is protected against
      the subdevice being freed.  Make it return `NULL` if the subdevice does
      not belong to the device.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63ab0395
    • Ian Abbott's avatar
      staging: comedi: remove comedi_dev_from_minor() · 49445b91
      Ian Abbott authored
      The `comedi_dev_from_minor()` function is no longer used, so remove it.
      Calls to it have either been replaced by calls to
      `comedi_dev_get_from_minor()` or by using the `private_data` member of
      the open file object.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49445b91
    • Ian Abbott's avatar
      staging: comedi: use file->private_data in file operations · e5d670dc
      Ian Abbott authored
      Since the `struct comedi_device` should now be protected from being
      freed while an open file object is using it, use the `private_data`
      member of the `struct file` to point to it.  Set it in `comedi_open()`
      and use it in the other file operation handlers instead of calling
      `comedi_dev_from_minor()` and checking the result.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e5d670dc
    • Ian Abbott's avatar
      staging: comedi: kcomedilib: protect against device detachment · 69e2387f
      Ian Abbott authored
      The functions in "kcomedilib" need to prevent the comedi device being
      detached during their operation.  This can be done by acquiring either
      the main mutex or the "attach lock" semaphore in the `struct
      comedi_device`.  Use the attach lock when merely checking whether the
      device is attached.  Use the mutex when processing a comedi instruction.
      
      Also, don't bother trying to manipulate the module use count of
      low-level comedi driver in `comedi_open()` and `comedi_close()`.  If the
      device gets detached while it is "open", we wouldn't be able to
      decrement the module use count anyway.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      69e2387f
    • Ian Abbott's avatar
      staging: comedi: kcomedilib: increment reference while device in use · 799a66ba
      Ian Abbott authored
      Low-level comedi drivers that use the "kcomedilib" module (currently only
      the "comedi_bond" driver) call `comedi_open()` to "open" another comedi
      device (not as a file) and `comedi_close()` to "close" it.  (Note: these
      are the functions exported by the "kcomedilib" module, not the
      identically named, statically linked functions in the core "comedi"
      module.)
      
      In `comedi_open()`, call `comedi_dev_get_from_minor()` instead of
      `comedi_dev_from_minor()` to get the pointer to the `struct
      comedi_device` being "opened".  This increments its reference count to
      prevent it being freed.  Call `comedi_dev_put()` if `comedi_open()`
      returns `NULL`, and also call it from `comedi_close()`.  This decrements
      the reference count.
      
      Note that although we now protect against the `struct comedi_device`
      being freed, we do not yet protect against it being "detached" while it
      is being used.  This will be addressed by a later patch.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      799a66ba
    • Ian Abbott's avatar
      staging: comedi: use refcount in sysfs attribute handlers · be535c9a
      Ian Abbott authored
      Call `comedi_dev_get_from_minor()` instead of `comedi_dev_from_minor()`
      in the sysfs attribute handler functions to increment the reference of
      the `struct comedi_device` during the operation.  Call
      `comedi_dev_put()` to decrement the reference afterwards.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be535c9a
    • Ian Abbott's avatar
      staging: comedi: use refcount while reading /proc/comedi · 616a3548
      Ian Abbott authored
      In the seq_file 'show' handler for "/proc/comedi" - `comedi_read()` in
      "comedi/proc.c",  call `comedi_dev_get_from_minor()` instead of
      `comedi_dev_from_minor()` to increment the reference counter for the
      `struct comedi_device` while it is being examined.  Call
      `comedi_dev_put()` to decrement the reference afterwards.  Also acquire
      the `attach_lock` rwsem while checking whether the device is attached.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      616a3548
    • Ian Abbott's avatar
      staging: comedi: use refcount in comedi_driver_unregister() · a200fadc
      Ian Abbott authored
      Change `comedi_driver_unregister()` to call
      `comedi_dev_get_from_minor()` instead of `comedi_dev_from_minor()` when
      finding devices using the driver.  This increments the reference count
      to prevent the device being removed while it is being checked to see if
      it is attached to the driver.  Call `comedi_dev_put()` to decrement the
      reference afterwards.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a200fadc
    • Ian Abbott's avatar
      staging: comedi: increment reference while file open · fc406986
      Ian Abbott authored
      In the 'open' file operation handler `comedi_open()` in "comedi_fops.c",
      call `comedi_dev_get_from_minor()` instead of `comedi_dev_from_minor()`
      to get the pointer to the `struct comedi_device`.  This increments the
      reference to prevent it being freed.  Call `comedi_dev_put()` to
      decrement the reference  on failure, and also call it from the 'release'
      file operation handler `comedi_close()`.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc406986
    • Ian Abbott's avatar
      staging: comedi: add comedi_dev_get_from_minor() · b449c1ca
      Ian Abbott authored
      Add function `struct comedi_device *comedi_dev_get_from_minor(unsigned
      minor)`.  This behaves like the existing `comedi_dev_from_minor()`
      except that it also increments the `struct kref refcount` member (via
      new helper function `comedi_dev_get()`) to prevent it being freed.  If
      it returns a valid pointer, the caller is responsible for calling
      `comedi_dev_put()` to decrement the reference count.
      
      Export `comedi_dev_get_from_minor()` and `comedi_dev_put()` as they will
      be used by the "kcomedilib" module in addition to the "comedi" module
      itself.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b449c1ca
    • Ian Abbott's avatar
      staging: comedi: add a kref to comedi device · 5b13ed94
      Ian Abbott authored
      Add a `struct kref refcount` member to `struct comedi_device` to allow
      safe destruction of the comedi device.  Only free the comedi device via
      the 'release' callback `kref_put()`.  Currently, nothing calls
      `kref_put()`, so the safe destruction is ineffective, but this will be
      addressed by later patches.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b13ed94
    • Ian Abbott's avatar
      staging: comedi: protect against detach during read operation · 45c2bc55
      Ian Abbott authored
      The 'read' file operation for comedi devices does not use the main mutex
      in the `struct comedi_device` to avoid contention with some ioctls that
      may take a while to complete.  Use the `attach_lock` semaphore to
      protect against detachment while the 'read' operation is in progress.
      This is a `struct rw_semaphore` and we read-lock it to protect against
      device detachment.
      
      Note that `comedi_device_cancel_all()` is called during device
      detachment, which cancels any ongoing asynchronous commands.  This will
      wake up any blocked readers which will then release the `attach_lock`
      semaphore and complete the 'read' operation early.
      
      The only time the 'read' file operation does use the main mutex is at
      the end of the command when it has to call `do_become_nonbusy()` to mark
      the subdevice as no longer busy handling an asynchronous command.  To
      avoid deadlock, it has to remove the task from the wait queue and
      release the `attach_lock` semaphore before acquiring the main mutex.  It
      then needs to confirm the device is still attached.  Unfortunately, we
      do not yet protect against a dynamically allocated `struct
      comedi_device` being deleted during the operation.  This will be
      addressed by a later patch.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45c2bc55
    • Ian Abbott's avatar
      staging: comedi: protect against detach during write operation · 9329f139
      Ian Abbott authored
      The 'write' file operation for comedi devices does not use the main
      mutex in the `struct comedi_device` to avoid contention with some ioctls
      that may take a while to complete.  Use the `attach_lock` semaphore to
      protect against detachment while the 'write' operation is in progress.
      This is a `struct rw_semaphore` and we read-lock it to protect against
      device detachment.
      
      Note that `comedi_device_cancel_all()` is called during device
      detachment, which cancels any ongoing asynchronous commands.  This will
      wake up any blocked writers which will then release the `attach_lock`
      semaphore and complete the 'write' operation early.
      
      The only time the 'write' file operation does use the main mutex is at
      the end of the command when it has to call `do_become_nonbusy()` to mark
      the subdevice as no longer busy handling an asynchronous command.  To
      avoid deadlock, it has to remove the task from the wait queue and
      release the `attach_lock` semaphore before acquiring the main mutex.  It
      then needs to confirm that the device is still attached.  Unfortunately,
      we do not yet protect against a dynamically allocated `struct
      comedi_device` being deleted during the operation.  This will be
      addressed by a later patch.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9329f139
    • Ian Abbott's avatar
      staging: comedi: add detachment counter for validity checks · ef77c0b2
      Ian Abbott authored
      Add a member `detach_count` to `struct comedi_device` that is
      incremented every time the device gets detached.  This will be used in
      some validity checks in the 'read' and 'write' file operations to make
      sure the attachment remains valid.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef77c0b2
    • Ian Abbott's avatar
      staging: comedi: cancel commands before detaching device · d19db51a
      Ian Abbott authored
      The comedi core module's handling of the `COMEDI_DEVCONFIG` ioctl will
      not allow a device to be detached if it is busy.  However, comedi
      devices can also be auto-detached due to a removal of a hardware device.
      One of the things we should do in that case is cancel any asynchronous
      commands that are running.  Add a new function
      `comedi_device_cancel_all()` to do that and call it from
      `comedi_device_detach()`.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d19db51a
    • Ian Abbott's avatar
      staging: comedi: wake up async waiters when become non-busy · 8da8c86f
      Ian Abbott authored
      Wake up all waiters on the comedi subdevice's async wait queue whenever
      the subdevice is marked "non-busy".  This happens when an asynchronous
      command is cancelled or when a command is terminated and all data has
      been read or written.  Note: use `wake_up_interruptible_all()` as we
      only use interruptible waits.
      
      Remove the call to `wake_up_interruptible()` from `do_cancel_ioctl()` as
      it will call `wake_up_interruptible_all()` indirectly via `do_cancel()`
      and `do_become_nonbusy()`.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8da8c86f
    • Ian Abbott's avatar
      staging: comedi: cleanup_device() -> comedi_device_detach_cleanup() · 3867e20d
      Ian Abbott authored
      Rename the local function `cleanup_device()` to
      `comedi_device_detach_cleanup()`.  It is only called from the
      `comedi_device_detach()` function and that is called from
      `comedi_device_cleanup()` and other places.  The more specific function
      name seems less confusing.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3867e20d
    • Ian Abbott's avatar
      staging: comedi: use attach_lock semaphore during attach and detach · bf11c134
      Ian Abbott authored
      Acquire the `attach_lock` semaphore in the `struct comedi_device` while
      modifying the `attached` flag.  This is a "write" acquire.  Note that
      the main mutex in the `struct comedi_device` is also held at this time.
      Tasks wishing to check the device is attached will need to either
      acquire the main mutex, or "read" acquire the `attach_lock` semaphore,
      or both in that order.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bf11c134
    • Ian Abbott's avatar
      staging: comedi: add rw_semaphore to protect against device detachment · 2f3fdcd7
      Ian Abbott authored
      The 'read' and 'write' file operations on comedi devices do not use the
      main mutex in the `struct comedi_device` to avoid contention with ioctls
      that may take a while to complete.  However, it is necessary to protect
      against the device being detached while the operation is in progress.
      Add member `struct rw_semaphore attach_lock` to `struct comedi_device`
      for this purpose and initialize it on creation.
      
      The actual locking and unlocking will be implemented by subsequent
      patches.  Tasks that are attaching or detaching comedi devices will
      write-acquire the new semaphore whilst also holding the main mutex in
      the `struct comedi_device`.  Tasks that wish to protect against the
      comedi device being detached need to acquire either the main mutex, or
      read-acquire the new semaphore, or both in that order.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f3fdcd7
    • Ian Abbott's avatar
      staging: comedi: add a couple of #includes to comedidev.h · ab3cb2e3
      Ian Abbott authored
      Two structures defined in "comedidev.h" have an element of type
      `spinlock_t`, so add `#include <linux/spinlock_types.h>` to declare it.
      One structure has an element of type `struct mutex` so add `#include
      <linux/mutex.h>` to declare it.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab3cb2e3
    • Ian Abbott's avatar
      staging: comedi: remove unused command callback support · c265be01
      Ian Abbott authored
      The 'kcomedilib' module used to provide functions to allow asynchronous
      comedi commands to be set up from another kernel module, but now
      commands can only be set up by ioctls from user space via the core
      comedi module.  Since support for commands initiated from kernel space
      has been dropped, the `cb_func` and `cb_arg` members of `struct
      comedi_async` are never set (although the `cb_mask` member is still used
      to mask comedi events).  The `SRF_USER` bit of the comedi subdevice
      runflags is no longer needed to distinguish commands from user and
      kernel space since they only come from user space.
      
      Don't bother setting or testing the `SRF_USER` flag, and get rid of it,
      along with the `cb_func` and `cb_arg` members.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c265be01
    • Dulshani Gunawardhana's avatar
      staging: lustre: Fix sparse warning for one-bit signed bitfield · 5fb0a2fa
      Dulshani Gunawardhana authored
      Fix the following sparse warning:
      drivers/staging/lustre/lustre/llite/llite_internal.h:461:49: error:dubious one-bit signed bitfield
      Signed-off-by: default avatarDulshani Gunawardhana <dulshani.gunawardhana89@gmail.com>
      Reviewed-by: default avatarPeter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5fb0a2fa
  2. 11 Nov, 2013 13 commits