Jinshan Xiong [Tue, 19 Nov 2013 13:23:41 +0000 (21:23 +0800)]
staging/lustre/hsm: Implementation of exclusive open
Proposed way to do exclusive open:
0. First of all, we have to perform most of the work in kernel space;
1. Client exclusively opens the file with IT_RELEASE_OPEN.
1.1 exclusive open means the open will fail if the file is being opened by somebody else;
2. the MDT will handle IT_RELEASE as follows:
2.1 Revoke OPEN_LOCK on this file, just request EX mode of MDS_INODELOCK_OPEN lock and
release it;
2.2 Acquire a rwsem, say open_rwsem, with write mode before trying to the file; for the
normal open, it should acquire read mode of open_rwsem;
2.3 Check if the file is already being opened by others, if not return with -EBUSY;
2.4 Check if the file can be released;
2.5 Set a special flag in struct mdt_file_data to mark this open is exclusive;
2.5 Release open rwsem.
>From now on, if the file is opened by others, it will mark mdt_file_data that the
exclusive open is broken.
3. Client: if IT_RELEASE_OPEN is finished successfully, and do followings:
3.1 Acquire full PW or EX extent lock to flush dirty cache;
3.2 Pack the handle of layout lock, data version and other attars;
3.3 Close the file with IT_RELEASE_CLOSE.
4. Back to MDT to handle IT_RELEASE CLOSE:
4.1 Grab the open_rwsem
4.2 Check if the exclusive open has ever been broken, in that case, the RELEASE process
will fail;
4.3 Verify the data version matches archive;
4.4 Grab EX layout lock
4.5 Swap the layout
4.6 Release EX layout lock
4.7 Close the exclusive open
Basically we avoid granting EX layout lock back to client and introduce exclusive open so
that we know it if the file has ever being accessed. I hope this can simplify things
a little bit. Also, exclusive open can be used to implement file lease.
In this patch, a framework of lease is implemented. However,
only exclusive lease is supported right now.
To apply a lease, MDS_OPEN_LEASE must be set to open the file, EX
mode open lock is returned to the client side to hold a lease. From
that time on, if this file is opened again by other processes, the
open lock will be revoked so the client who holds the lease will
know the lease is already broken by checking that open lock.
To release a lease, normal close is used. The client will revoke the
open lock before sending CLOSE request.
Lease can be applied in two ways. ll_lease_open()/close() can be
called directly if the lease holder is in kernel space; or if the
lease holder lives in user space, it has to open the file first and
then use ioctl() with command LL_IOC_SET_LEASE to apply a lease. The
lease holder has to poll the lease status itself.
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2919
Lustre-change: http://review.whamcloud.com/6730 Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com> Signed-off-by: John L. Hammond <john.hammond@intel.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: Peng Tao <bergwolf@gmail.com> Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Himangi Saraogi [Sat, 2 Nov 2013 04:35:30 +0000 (10:05 +0530)]
staging:dwc2:hcd_queue.c : cleanups to the microframe scheduler code
This patch takes up the task mentioned in the TODO file of dwc2 to
cleanup the microframe scheduler code. The while(!done) loops have been
replaced with appropriate for loops and unnecessary variables
like done and ret have been removed.
John L. Hammond [Thu, 14 Nov 2013 16:13:18 +0000 (00:13 +0800)]
staging/lustre/lov: convert magic to host-endian in lov_dump_lmm()
In lov_dump_lmm(), convert the lmm_magic from little-endian to
host-endian byte order before the switch statement, as the other
lov_dump_xxx() and lov_verify_xxx() functions already do. Remove the
unused macro LMM_ASSERT().
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3297
Lustre-change: http://review.whamcloud.com/6290 Signed-off-by: John L. Hammond <john.hammond@intel.com> Reviewed-by: Li Wei <wei.g.li@intel.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Peng Tao <bergwolf@gmail.com> Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Li Xi [Thu, 14 Nov 2013 16:13:17 +0000 (00:13 +0800)]
staging/lustre/llog: fix return value of llog_alloc_handle
llog_open() calls llog_alloc_handle() taking NULL as the error return
value. But llog_alloc_handle() returns ERR_PTR(-ENOMEM) instead when
error.
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3470
Lustre-change: http://review.whamcloud.com/6644 Signed-off-by: Li Xi <pkuelelixi@gmail.com> Reviewed-by: Mike Pershin <mike.pershin@intel.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Peng Tao <bergwolf@gmail.com> Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
John L. Hammond [Thu, 14 Nov 2013 16:13:08 +0000 (00:13 +0800)]
staging/lustre/llite: use correct FID in ll_och_fill()
When ll_intent_file_open() is called on a file with a stale dentry,
ll_och_fill() may incorrectly use the FID from the struct
ll_inode_info rather than the FID from the response body (which is the
correct FID for the close). Fix this, remove the ll_inode_info
parameter from ll_och_fill(), and move the call to ll_ioepoch_open()
from ll_och_fill() to ll_local_open().
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3233
Lustre-change: http://review.whamcloud.com/6695 Signed-off-by: John L. Hammond <john.hammond@intel.com> Reviewed-by: Fan Yong <fan.yong@intel.com> Reviewed-by: Mike Pershin <mike.pershin@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: Peng Tao <bergwolf@gmail.com> Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fix the following checkpatch error:
ERROR: "(foo*)" should be "(foo *)"
Signed-off-by: Kristina Martsenko <kristina.martsenko@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fix the following type of checkpatch warning to comply with coding
style:
WARNING: suspect code indent for conditional statements
Also join a debug string split across lines, as it was on the same lines
as the other changes anyway. And reformat some comments in the kernel
coding style for the same reason.
staging: lustre: ptlrpc: clean up whitespace around parentheses
Fix the following types of checkpatch errors and warnings to comply with
coding style:
ERROR: space required before the open parenthesis '('
ERROR: space prohibited after that open parenthesis '('
ERROR: space prohibited before that close parenthesis ')'
WARNING: space prohibited between function name and open parenthesis '('
staging: lustre: ptlrpc: pack_generic: clean up whitespace around parentheses
Fix the following types of checkpatch errors and warnings in
pack_generic.c to comply with coding style:
ERROR: space required before the open parenthesis '('
ERROR: space prohibited before that close parenthesis ')'
WARNING: space prohibited between function name and open parenthesis '('
Gu Zheng [Thu, 31 Oct 2013 10:33:01 +0000 (18:33 +0800)]
staging/olpc_docn: reorder the lock sequence to avoid potential dead lock
The lock sequence of dcon_blank_fb(fb_info->lock ---> console_lock) is against
with the one of console_callback(console_lock ---> fb_info->lock), it'll
lead to a potential dead lock, so reorder the lock sequence of dcon_blank_fb
to avoid the potential dead lock.
Aldo Iljazi [Mon, 4 Nov 2013 12:15:22 +0000 (14:15 +0200)]
Staging: ft1000: boot.h: fixed a few styling issues
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.
Chen Gang [Thu, 31 Oct 2013 07:27:37 +0000 (15:27 +0800)]
drivers: staging: speakup: serialio: only use platform specific SERIAL_PORT_DFNS.
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: Chen Gang <gang.chen@asianux.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:43 +0000 (15:03 +0000)]
staging: comedi: protect buffer from being freed while mmapped
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:42 +0000 (15:03 +0000)]
staging: comedi: make determination of read or write subdevice safer
`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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:41 +0000 (15:03 +0000)]
staging: comedi: remove comedi_dev_from_minor()
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 <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:40 +0000 (15:03 +0000)]
staging: comedi: use file->private_data in file operations
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:39 +0000 (15:03 +0000)]
staging: comedi: kcomedilib: protect against device detachment
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:38 +0000 (15:03 +0000)]
staging: comedi: kcomedilib: increment reference while device in use
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:37 +0000 (15:03 +0000)]
staging: comedi: use refcount in sysfs attribute handlers
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 <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:36 +0000 (15:03 +0000)]
staging: comedi: use refcount while reading /proc/comedi
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:35 +0000 (15:03 +0000)]
staging: comedi: use refcount in comedi_driver_unregister()
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:34 +0000 (15:03 +0000)]
staging: comedi: increment reference while file open
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:33 +0000 (15:03 +0000)]
staging: comedi: add comedi_dev_get_from_minor()
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:32 +0000 (15:03 +0000)]
staging: comedi: add a kref to comedi device
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:31 +0000 (15:03 +0000)]
staging: comedi: protect against detach during read operation
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:30 +0000 (15:03 +0000)]
staging: comedi: protect against detach during write operation
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:29 +0000 (15:03 +0000)]
staging: comedi: add detachment counter for validity checks
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 <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:28 +0000 (15:03 +0000)]
staging: comedi: cancel commands before detaching device
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:27 +0000 (15:03 +0000)]
staging: comedi: wake up async waiters when become non-busy
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:25 +0000 (15:03 +0000)]
staging: comedi: use attach_lock semaphore during attach and detach
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:24 +0000 (15:03 +0000)]
staging: comedi: add rw_semaphore to protect against device detachment
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:23 +0000 (15:03 +0000)]
staging: comedi: add a couple of #includes to comedidev.h
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 8 Nov 2013 15:03:22 +0000 (15:03 +0000)]
staging: comedi: remove unused command callback support
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: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: lustre: Fix sparse warning for one-bit signed bitfield
Fix the following sparse warning:
drivers/staging/lustre/lustre/llite/llite_internal.h:461:49: error:dubious one-bit signed bitfield
Signed-off-by: Dulshani Gunawardhana <dulshani.gunawardhana89@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fix the following sparse warings in local_storage.c.
drivers/staging/lustre/lustre/obdclass/local_storage.c:269:16:warning:incorrect type in assignment (different base types)
Rashika Kheria [Mon, 11 Nov 2013 06:39:58 +0000 (12:09 +0530)]
Staging: gdm724x: Remove confusing macro gdm_lte_sdu_send in gdm_lte.c
This patch removes confusing macro gdm_lte_sdu_send as stated in TODO list
in file gdm_lte.c. It then fixes the place where the macro is used.
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rashika Kheria [Mon, 11 Nov 2013 06:22:31 +0000 (11:52 +0530)]
Staging: dgrp: Refactor the function dgrp_receive() in drrp_net_ops.c
The function dgrp_receive() in dgrp_net_ops.c is too long and can be
refactored. It uses various switch statements and goto labels. I have
removed a label called data and tried to extract a new function out of
it called as handle_data_in_packet().
This helps to make the code more modularize and simple to read and
understand.
This patch removes the following warning reported by checkpatch.pl
WARNING: line over 80 characters
drivers/staging/media/lirc/lirc_imon.c
Signed-off-by: Matina Maria Trompouki <mtrompou@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Matina Maria Trompouki <mtrompou@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: ozwpan: fixed whitespace before semicolon
This patch removes the following warning reported by checkpatch.pl
WARNING: space prohibited before semicolon
drivers/staging/ozwpan/ozproto.c
Signed-off-by: Matina Maria Trompouki <mtrompou@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Teodora Baluta [Mon, 11 Nov 2013 17:27:07 +0000 (19:27 +0200)]
staging: vt6655: delete explicit comparison to bool
This patch fixes all bool tests by deleting the comparison. Most of
these were detected using coccinelle and silence the following type of
coccinelle warnings for drivers/staging/vt6655/bssdb.c file:
WARNING: Comparison to bool
Signed-off-by: Teodora Baluta <teobaluta@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Teodora Baluta [Mon, 11 Nov 2013 17:27:06 +0000 (19:27 +0200)]
staging: vt6655: delete unnecessary whitespace before a quoted newline
This patch silences the following type of warnings:
WARNING: unnecessary whitespace before a quoted newline
Signed-off-by: Teodora Baluta <teobaluta@gmail.com> Reviewed-by: Lisa Nguyen <lisa@xenapiadmin.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Teodora Baluta [Mon, 11 Nov 2013 17:27:05 +0000 (19:27 +0200)]
staging: vt6655: use netdev_* instead of printk
Checkpatch.pl gave the following warnings
WARNING: printk() should include KERN_ facility level
After fixing these with KERN_INFO facility level, it was suggested to
use netdev_ instead of printk() with KERN_INFO facility.
Used netdev_dbg for the statements inside of PLICE_DEBUG #ifdef, as
debugging shouldn't rely on compile options and netdev_info for one
printk which wasn't inside any #ifdef PLICE_DEBUG.
Signed-off-by: Teodora Baluta <teobaluta@gmail.com> Reviewed-by: Lisa Nguyen <lisa@xenapiadmin.com> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rashika Kheria [Mon, 11 Nov 2013 15:12:35 +0000 (20:42 +0530)]
Staging: keucr: Move the declaration of variable IsXDCompliance in smilsub.c
This patch moves the declaration of variable IsXDCompliance to file
smilsub.c since this is the only file which uses it.
Hence, it also removes extern declaration from the header file smil.h
and unnecessary declaration in smilmain.c
Rashika Kheria [Mon, 11 Nov 2013 15:11:04 +0000 (20:41 +0530)]
Staging: keucr: Move the declaration of variable IsSSFDCCompliance in smilsub.c
This patch moves the declaration of variable IsSSFDCCompliance to file
smilsub.c since this is the only file which uses it. Hence, it also
removes extern declaration from the header file smil.h and unnecessary
declaration in smilmain.c
Rashika Kheria [Mon, 11 Nov 2013 15:09:34 +0000 (20:39 +0530)]
Staging: keucr: Move the declaration of variable ErrCode in smilmain.c
This patch moves the declaration of variable ErrCode to file smilmain.c
since this is the only file which uses it. Hence, it also removes extern
declaration from the header file smil.h.
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rashika Kheria [Mon, 11 Nov 2013 15:08:20 +0000 (20:38 +0530)]
Staging: keucr: Move the declaration of variable ErrXDCode in smilsub.c
This patch moves the declaration of variable ErrXDCode to file smilsub.c
since this is the only file which uses it. Hence, it also removes extern
declaration from the header file smil.h and unnecessary declaration in
smilmain.c
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ebru Akagunduz [Sun, 10 Nov 2013 21:16:58 +0000 (23:16 +0200)]
Staging: rtl8187se: Fix Sparse Warnings
This patch fixes the Sparse Warnings "symbol was
not declared. Should it be static?" so it removes
some extern expressions to r8180.h and it defines
some extern expressions in ieee80211.h
Himangi Saraogi [Thu, 7 Nov 2013 22:42:41 +0000 (04:12 +0530)]
staging:wlags49_h2: Fix sparse warnings in sta_h25.c
This patch fixes sparse warnings "Using plain integer as NULL pointer" in
sta_h25.c
Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rashika Kheria [Fri, 8 Nov 2013 12:39:44 +0000 (18:09 +0530)]
Staging: gdm724x: Use ALIGN() macro for dummy_cnt in gdm_mux.c
As suggested in TODO list, this patch uses ALIGN() macro for variable
dummy_cnt in functions up_to_host() and gdm_mux_send() in file
gdm_mux.c.
The macro has already been defined in include/linux/kernel.h, hence is
not defined again.
staging: ctxt1e1: Fixed sparse warning related to static declaration
Fixed below thrown sparse warning by making the local
variable declaration static:
drivers/staging/cxt1e1/musycc.c:1:14: warning: symbol 'max_intcnt' was
not declared. Should it be static?
drivers/staging/cxt1e1/musycc.c:2:14: warning: symbol 'max_bh' was not
declared. Should it be static?
Teodora Baluta [Mon, 4 Nov 2013 18:13:10 +0000 (20:13 +0200)]
staging: comedi: change bool assignment to true
This is a minor fix that was suggested by coccinelle. When defined as a
bool, a variable should use true/false rather than 1/0.
Signed-off-by: Teodora Baluta <teobaluta@gmail.com> Reviewed-by: Lisa Nguyen <lisa@xenapiadmin.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Teodora Baluta [Mon, 4 Nov 2013 18:13:11 +0000 (20:13 +0200)]
staging: comedi: remove unneeded semicolon
There is no need for ';' after '}'. This minor fix was suggested by
coccinelle.
Signed-off-by: Teodora Baluta <teobaluta@gmail.com> Reviewed-by: Lisa Nguyen <lisa@xenapiadmin.com> Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rashika Kheria [Sun, 10 Nov 2013 13:32:24 +0000 (19:02 +0530)]
Staging: tidspbridge: Prefer dev_info() then printk() in dmm.c
This patch fixes the following checkpatch.pl warning in pmgr/dmm.c-
WARNING: Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ...