Larry Finger [Fri, 20 Dec 2013 20:58:45 +0000 (14:58 -0600)]
staging: r8188eu: Fix unused variable warnings
A previous set of patches were test compiled with one of the configuration
variables not set. As a result, a number of unused variables were left in the
code.
In several instances, declaration of the unused variable was the only statement
inside ifdef .. endif pairs. In those cases, the entire block was removed.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Larry Finger [Fri, 20 Dec 2013 20:58:44 +0000 (14:58 -0600)]
staging: r8188eu: Restore line that was incorrectly removed
A line in the P2P code had been removed in the process of converting the vendor
driver to a form suitable for the kernel. The output of this call was ignored,
and the initial analysis incorrectly determined that the call had no other
effect.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Wenliang Fan [Fri, 20 Dec 2013 11:07:38 +0000 (19:07 +0800)]
drivers/staging/bcm: Integer overflow
The checking condition in 'validateFlash2xReadWrite()' is not
sufficient. A large number invalid would cause an integer overflow and
pass the condition, which could cause further integer overflows in
'Bcmchar.c:bcm_char_ioctl()'.
Signed-off-by: Wenliang Fan <fanwlexca@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The counter->chip_index will always be < counters_per_chip due to the
initialization of the subdevices during the attach of the board.
The dma_selection_counter() helper just does a BUG_ON() check before
returning the original value. Just use the original value directly
in the caller and remove the helper function.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_660x: rename the CamelCase enum NI_660x_Register and labels
As prefered by the CodingStyle, rename this CamelCase enum and its labels.
Also, cleanup the ni_gpct_to_660x_register() helper function. Just return the
ni_660x_register for each ni_gpct_register and remove the unnecessary break
statements after the return statements.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_tiocmd: make ni_tio_cmd() a proper comedi (*do_cmd)
Change the parameters to ni_tio_cmd() to make it a proper comedi
(*do_cmd) function.
The wrappers in the ni_660x and ni_mio_common modules are still needed
to request the mite channel and setup the device before actually doing
the command.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_tiocmd: make ni_tio_cmdtest() a proper comedi (*do_cmdtest)
Change the parameters to ni_tio_cmdtest() to make it a proper comedi
(*do_cmdtest) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_tio: make ni_tio_insn_config() a proper comedi (*insn_config)
Change the parameters to ni_tio_insn_config() to make it a proper comedi
(*insn_config) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_tio: make ni_tio_winsn() a proper comedi (*insn_write)
Change the parameters to ni_tio_winsn() to make it a proper comedi
(*insn_write) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.
For aesthetics, rename the function.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_tio: make ni_tio_rinsn() a proper comedi (*insn_read)
Change the parameters to ni_tio_rinsn() to make is a proper comedi
(*insn_read) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.
For aesthetics, rename the function.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_tio.h: rename the CamelCase enum ni_gpct_register labels
As prefered by the CodingStyle, rename all the CamelCase labels of the
enum ni_gpct_register.
Cleanup all the helper functions in ni_tio_internal.h that used the enum.
The 'counter_index' parameter to all the functions is the ni_gpct_device
'counter_index' which is initialized when the subdevices are setup. This
value is always < 4 so the default: BUG() cases can never happen. For
aesthetics, rename the 'counter_idx' to simply 'idx' and fix the type in
some of the helpers.
Also, remove the unnecessary break statements after the return statements.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Wei Yongjun [Fri, 20 Dec 2013 03:41:11 +0000 (11:41 +0800)]
staging: lustre: fix return value check in capa_hmac()
In case of error, the function crypto_alloc_hash() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().
Andreas Frembs [Fri, 20 Dec 2013 10:29:10 +0000 (11:29 +0100)]
rlt8192e: Removing unused defines in rltlib_endianfree.h
Checkpatch mentioned that these macros should be defined with a 'do {...} while(0)' statement.
So we used grep to find all files using these macros and we found out that these macros were only used
in rtl819x_Qos.h, in the defines we removed before.
Since the macros are not used anywhere else we decided to remove them from the driver.
Michael Hoefler [Fri, 20 Dec 2013 13:51:13 +0000 (14:51 +0100)]
silicom: remaining checkpatch issues in bypass.c
In this patch we fix some "logical" errors in bypass.c of the silicom bypass
driver (in staging).
Checkpatch complains about the following errors:
- unnecessary forward declarations in a source file
- assignment in if condition
In addition to that the __init and __exit macros were missing at the init and
cleanup function.
There are still two warnings left for this file related to too many leadingtabs
at nested blocks. I did not touch this issue becasue the code needs really some
refactoring. And since i do not have the appropriate hardware to test the code,
i do not change the functionality in any way.
Signed-off-by: Michael Hoefler <michael.hoefler@studium.uni-erlangen.de> Signed-off-by: Christoph Kohl <christoph.kohl@t-online.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Michael Hoefler [Fri, 20 Dec 2013 13:51:11 +0000 (14:51 +0100)]
silicom: fix whitespace issues in bypass.c
This patch addresses several problems in bypass.c found by checkpatch.
Furthermore it removes/adds some empty lines to make the code more readable.
The following problems are fixed:
- line over 80 characters
- space after logical operator !
- spaces instead of tabs
- missing empty line after local declarations
- empty line after {
The empty line issues were not discovered by checkpatch but in my opinion these
changes make perfect sense in terms of readability.
Signed-off-by: Michael Hoefler <michael.hoefler@studium.uni-erlangen.de> Signed-off-by: Christoph Kohl <christoph.kohl@t-online.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
John Stultz [Thu, 19 Dec 2013 23:56:23 +0000 (15:56 -0800)]
ion_test: Add compat_ioctl support (v2)
Prior to subitting this, Colin reworked the compat_ioctl support
for the ion_test driver, moving the structure to be the same size
on both 32 and 64 bit architectures.
Two small things were left out. The compat_ioctl ptr assignment,
and the fact that despite having uniform sized types in the
structure, the structure pads out to different sizes on different
arches.
This patch resolves this issue by adding a padding entry after
the write flag, and adding the compat_ioctl ptr.
Changes in v2:
- Add a padding int rather then making write a u64
Acked-by: Colin Cross <ccross@android.com> Cc: Android Kernel Team <kernel-team@android.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Aaron Sierra [Wed, 18 Dec 2013 16:11:09 +0000 (10:11 -0600)]
vme_user: Enable compat_ioctl for mixed environment
Now that the VME userspace API structures compile to a consistent size
in mixed environments (32-bit userspace and 64-bit kernel), enable the
.compat_ioctl to allow ioctls to execute in this environment.
Signed-off-by: Aaron Sierra <asierra@xes-inc.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
John Stultz [Wed, 18 Dec 2013 01:04:29 +0000 (17:04 -0800)]
staging: ion: Avoid using rt_mutexes directly
RT_MUTEXES can be configured out of the kernel, causing compile
problems with ION.
To quote Colin:
"rt_mutexes were added with the deferred freeing feature. Heaps need
to return zeroed memory to userspace, but zeroing the memory on every
allocation was causing performance issues. We added a SCHED_IDLE
thread to zero memory in the background after freeing, but locking the
heap from the SCHED_IDLE thread might block a high priority allocation
thread for a long time.
The lock is only used to protect the heap's free_list and
free_list_size members, and is not held for any long or sleeping
operations. Converting to a spinlock should prevent priority
inversion without using the rt_mutex. I'd also rename it to free_lock
to so it doesn't get used as a general heap lock."
Thus this patch converts the rt_mutex usage to a spinlock and
renames the lock free_lock to be more clear as to its use.
I also had to change a bit of logic in ion_heap_freelist_drain()
to safely avoid list corruption.
Acked-by: Colin Cross <ccross@android.com> Cc: Android Kernel Team <kernel-team@android.com> Reported-by: Jim Davis <jim.epost@gmail.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Aaron Sierra [Mon, 9 Dec 2013 16:05:40 +0000 (10:05 -0600)]
vme_user: Update API to work in mixed environments
This patch updates the vme_master and vme_slave structures to use
types with well defined size and to prevent the compiler from
inserting padding (between enable and vme_addr for one).
The original vme_master and vme_slave structs would be different
sizes and have different layouts depending on whether they were built
for a 32-bit or 64-bit system.
On x86 it is possible to have a 32-bit userspace and a 64-bit kernel.
In this type of environment, the userspace and kernel vme_user APIs
would disagree and prevent ioctls from executing (based on ioctl
signatures from _IOR and _IOW).
Aaron Sierra [Mon, 9 Dec 2013 15:54:42 +0000 (09:54 -0600)]
vme: Convert VME core to register as a subsystem
Previously, VME bridge support was treated as any other driver (using
module_init() macro), but if VME bridge and vme_user (staging) drivers
were compiled into the kernel, then vme_user would attempt to register
itself before the VME core support had been loaded. This would result
in a kernel panic.
The load order of these built-in drivers is based on the order in which
drivers/staging/vme and driver/vme are compiled.
This patch changes the VME core driver to use the subsys_initcall()
macro which ensures that it is loaded before all other VME drivers
regardless of the order in which they are compiled.
Bernd Porr [Wed, 11 Dec 2013 16:06:15 +0000 (16:06 +0000)]
staging: comedi: fix result of memdup_user for user chanlist
If the channel list is not set in userspace we get an error at
PTR_ERR(async->cmd.chanlist). However, do_become_nonbusy(dev, s) cleans
up this pointer which causes a kernel ooops. Setting the channel list in
async to NULL and checking this in do_become_nonbusy prevents the oops.
[Ian Abbott] Also do the same for the chanlist allocated in
do_cmdtest_ioctl().
Ian Abbott [Wed, 11 Dec 2013 14:51:03 +0000 (14:51 +0000)]
staging/comedi: bug fix for module usage count on device removal
When a dynamically created comedi device is being automatically removed
by a call to `comedi_auto_unconfig()` from the lower level driver,
`comedi_device_cleanup()` is called to perform the detachment from the
lower level driver. If the comedi device is open at the time,
`dev->use_count` will be the the number of outstanding opens. The
function currently decrements the the module counts of the "comedi"
module and the low-level driver module by this amount and reduces
`dev->use_count` to zero. There are various problems with this as the
`release` file operation handler `comedi_close()` also decrements
`dev->use_count` and decrements the module usage counts. This means
that `dev->use_count` and the module counts can end up negative.
Also, the assumed one-to-one relationship between the file open count
and the low-level module usage count is invalid and can get screwed up.
We only want to stop the low-level module being unloaded while a comedi
device using the module has an open file object.
Also, there is no need to manipulate the module count of the core
"comedi" module at all since the comedi module is the owner of the file
operations structure and the system will not unload the module while
there are open file objects using it.
Correct the bugs and simplify as follows:
1. Get rid of the module count manipulations of the core "comedi" module
(`THIS_MODULE`) altogether.
2. Don't alter `dev->use_count` in `comedi_device_cleanup()` as it
should only be altered by the `open` and `release` file operation
handlers `comedi_open()` and `comedi_close()`.
3. Increment the low-level module count for the following reasons:
a) In `comedi_open()` if the open count was zero and the comedi device
is attached to the low-level driver.
b) When the `COMEDI_DEVCONFIG` ioctl is used to manually attach an
unattached comedi device to a low-level driver. The open count
will be greater than zero at this time. The actual increment of
the low-level module count is already done by
`comedi_device_attach()`.
4. Decrement the low-level module count for the following reasons:
a) In `comedi_close()` if the open count was 1 and the comedi device
is attached to the low-level driver.
b) In `comedi_device_cleanup()` (called via `comedi_auto_unconfig()`
--> `comedi_release_hardware_device()` -->
`comedi_free_board_dev()` when the comedi device is automatically
unconfigured due to action by the low-level driver) if the device
was attached (which it should be) and open count was non-zero
(greater than zero).
c) When the `COMEDI_DEVCONFIG` ioctl is used to manually detach the
comedi device from the low-level driver. The open count will be
greater than zero at this time.
The open count should never go negative. Parts 3 and 4 ensure that the
low-level module usage count is incremented on entering the state where
the comedi device is attached to the low-level driver AND the open count
is greater than zero, and is decremented on leaving that state.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Wed, 11 Dec 2013 14:51:02 +0000 (14:51 +0000)]
staging/comedi: keep reference to class device after destroyed
When a dynamically allocated `struct comedi_device` gets automatically
unconfigured by a call to `comedi_auto_unconfig()` from a lower-level
driver's bus removal function (e.g. when a USB device is disconnected),
the class device in `dev->class_dev` (where `dev` points to the `struct
comedi_device`) is destroyed by a call to `device_destroy()` that
matches a previous call to `device_create()`.
However, if the `struct comedi_device` is still associated with an open
file object, the now invalid `dev->class_dev` pointer may still be
passed to `dev_printk()` (via `dev_dbg()` etc.), producing bogus output
or worse.
To fix this, call `get_device()` on the class device if
`device_create()` was successful. Add a matching call to `put_device()`
in `comedi_dev_kref_release()` when the `struct comedi_device` is freed.
The calls to `dev_dbg()` etc. after the call to `device_destroy()` will
still produce valid output, although the device will have been
unregistered in sysfs.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Paul Gortmaker [Tue, 10 Dec 2013 20:23:48 +0000 (15:23 -0500)]
staging: delete non-required instances of include <linux/init.h>
None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>. Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Steven Luo [Wed, 11 Dec 2013 20:51:56 +0000 (22:51 +0200)]
Staging: TIDSPBRIDGE: Fix mmap to map the correct region of physical memory
Commit 559c71fe5dc3 ("Staging: TIDSPBRIDGE: Use vm_iomap_memory for
mmap-ing instead of remap_pfn_range") had the effect of inadvertently
shifting the start of the physical memory area mapped by
pdata->phys_mempool_base. Correct this by subtracting that shift before
calling vm_iomap_memory() and adding it back afterwards.
staging: comedi: s626: tidy up comedi_lrange table
The comedi_lrange tables are fixed length based on the 'length' value
before the array of comedi_krange 'range' values. For aesthetics, remove
the trailing comma from last 'range' value.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>