re: staging: drm/imx: add i.MX IPUv3 base driver

2013-11-08 Thread Dan Carpenter
Hello Sascha Hauer, The patch aecfbdb1803b: "staging: drm/imx: add i.MX IPUv3 base driver" from Sep 21, 2012, leads to the following static checker warning: "drivers/staging/imx-drm/ipu-v3/ipu-common.c:110 ipu_ch_param_write_field() warn: buffer overflow 'base->word[word]->data' 5 <= 5

re: staging: drm/imx: add i.MX IPUv3 base driver

2013-11-08 Thread Dan Carpenter
Hello Sascha Hauer, This is a semi-automatic email about new static checker warnings. The patch aecfbdb1803b: "staging: drm/imx: add i.MX IPUv3 base driver" from Sep 21, 2012, leads to the following Smatch complaint: drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c:164 ipu_dmfc_setup_channel()

Re: [PATCH] mfd: rtsx: add card reader rtl8402

2013-11-08 Thread Lee Jones
On Fri, 01 Nov 2013, micky_ch...@realsil.com.cn wrote: > From: Micky Ching > > Add card reader rtl8042, rtl8402 is much like rtl8411, so just add it to > rtl8411.c > > Signed-off-by: Micky Ching > --- > drivers/mfd/rtl8411.c | 62 > > drive

[PATCH 2/2] VME: Rename vme_slot_get to avoid confusion with reference counting

2013-11-08 Thread Martyn Welch
Traditionally the "get" functions increment the reference count of the object that is returned, which does not happen with vme_slot_get. The function vme_slot_get returns the physical VME slot associated with a particular struct vme_dev. Rename vme_slot_num to avoid any confusion. Signed-off-by: M

[PATCH 1/2] VME: Provide access to VME bus enumeration and fix vme_user match function

2013-11-08 Thread Martyn Welch
The match function for vme_user is completely wrong. It will blindly bind against the first VME slot on each bus (at this point that would be just the first bus as the driver can only handle one bus). The original intention (before some major subsystem changes) was that the driver bind against the

Re: [PATCH 1/2] VME: Provide access to VME bus enumeration and fix vme_user match function

2013-11-08 Thread Martyn Welch
My appologies - the script I had to send patches had got a bit broken and I'd completely forgotten... Martyn On 08/11/13 11:55, y wrote: > From: Martyn Welch > > The match function for vme_user is completely wrong. It will blindly bind > against the first VME slot on each bus (at this point tha

[PATCH 2/2] VME: Rename vme_slot_get to avoid confusion with reference counting

2013-11-08 Thread Martyn Welch
Traditionally the "get" functions increment the reference count of the object that is returned, which does not happen with vme_slot_get. The function vme_slot_get returns the physical VME slot associated with a particular struct vme_dev. Rename vme_slot_num to avoid any confusion. Signed-off-by: M

Treat as Urgent and Read Carefully.

2013-11-08 Thread Mr. Luis Elmer
Good Day, My name is Mr. Luis Elmer, i am the credit officer in Banco Santander Plc, London, UK. I have a business proposal of $28,800,000, for you from my bank. There were no beneficiaries stated concerning these funds which means no one would ever come forward to claim it. I want us to work

Treat as Urgent and Read Carefully.

2013-11-08 Thread Mr. Luis Elmer
Good Day, My name is Mr. Luis Elmer, i am the credit officer in Banco Santander Plc, London, UK. I have a business proposal of $28,800,000, for you from my bank. There were no beneficiaries stated concerning these funds which means no one would ever come forward to claim it. I want us to work

[PATCH 04/22] staging: comedi: use attach_lock semaphore during attach and detach

2013-11-08 Thread Ian Abbott
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 mu

[PATCH 00/22] staging: comedi: protect operations from device removal

2013-11-08 Thread Ian Abbott
Calls to `comedi_auto_unconfig()` from low-level comedi drivers result in the `struct comedi_device` being freed along with any comedi data buffers. That's bad news for the 'read' and 'write' file operations that currently have no protection from this (they don't use the main mutex in the `struct

[PATCH 11/22] staging: comedi: add a kref to comedi device

2013-11-08 Thread Ian Abbott
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 pat

[PATCH 07/22] staging: comedi: cancel commands before detaching device

2013-11-08 Thread Ian Abbott
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

[PATCH 08/22] staging: comedi: add detachment counter for validity checks

2013-11-08 Thread Ian Abbott
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: Ian Abbott --- drivers/staging/comedi/come

[PATCH 09/22] staging: comedi: protect against detach during write operation

2013-11-08 Thread Ian Abbott
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 `struc

[PATCH 13/22] staging: comedi: increment reference while file open

2013-11-08 Thread Ian Abbott
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 refe

[PATCH 16/22] staging: comedi: use refcount in sysfs attribute handlers

2013-11-08 Thread Ian Abbott
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: Ian Abbott --- drivers/st

[PATCH 12/22] staging: comedi: add comedi_dev_get_from_minor()

2013-11-08 Thread Ian Abbott
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 p

[PATCH 15/22] staging: comedi: use refcount while reading /proc/comedi

2013-11-08 Thread Ian Abbott
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 re

[PATCH 14/22] staging: comedi: use refcount in comedi_driver_unregister()

2013-11-08 Thread Ian Abbott
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 `com

[PATCH 10/22] staging: comedi: protect against detach during read operation

2013-11-08 Thread Ian Abbott
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

[PATCH 19/22] staging: comedi: use file->private_data in file operations

2013-11-08 Thread Ian Abbott
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()`

[PATCH 02/22] staging: comedi: add a couple of #includes to comedidev.h

2013-11-08 Thread Ian Abbott
Two structures defined in "comedidev.h" have an element of type `spinlock_t`, so add `#include ` to declare it. One structure has an element of type `struct mutex` so add `#include ` to declare it. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedidev.h | 2 ++ 1 file changed, 2 inserti

[PATCH 06/22] staging: comedi: wake up async waiters when become non-busy

2013-11-08 Thread Ian Abbott
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 interrup

[PATCH 18/22] staging: comedi: kcomedilib: protect against device detachment

2013-11-08 Thread Ian Abbott
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 th

[PATCH 05/22] staging: comedi: cleanup_device() -> comedi_device_detach_cleanup()

2013-11-08 Thread Ian Abbott
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: Ian Abbott ---

[PATCH 22/22] staging: comedi: protect buffer from being freed while mmapped

2013-11-08 Thread Ian Abbott
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 `str

[PATCH 21/22] staging: comedi: make determination of read or write subdevice safer

2013-11-08 Thread Ian Abbott
`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

[PATCH 20/22] staging: comedi: remove comedi_dev_from_minor()

2013-11-08 Thread Ian Abbott
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: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 28 -

[PATCH 17/22] staging: comedi: kcomedilib: increment reference while device in use

2013-11-08 Thread Ian Abbott
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

[PATCH 03/22] staging: comedi: add rw_semaphore to protect against device detachment

2013-11-08 Thread Ian Abbott
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 `

[PATCH 01/22] staging: comedi: remove unused command callback support

2013-11-08 Thread Ian Abbott
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 `c