Peter Huewe [Mon, 14 Jan 2013 21:00:48 +0000 (22:00 +0100)]
staging/comedi: Add macro for registering a comedi PCMCIA driver
This patch introduces a new macro 'module_comedi_pcmcia_driver'
for comedi PCMCIA drivers which do not do anything special in module
init/exit. This eliminates a lot of boilerplate.
Adapted from 'module_comedi_pci_driver'
Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: comedi_buf: remove noise in comedi_buf_read_free()
If an attempt is made to free more bytes than have been allocated
a dev_info message is output and the number of bytes to free is
adjusted to the allocated size.
Telling the user this happened is just noise. Remove the message.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbobbi@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: comedi_buf: remove noise in comedi_buf_write_free()
If an attempt is made to free more bytes than have been allocated
a dev_info message is output and the number of bytes to free is
adjusted to the allocated size.
Telling the user this happened is just noise. Remove the message.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbobbi@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: comedi_buf: reorder exported function prototypes
For aesthetic reasons, reorder the prototypes for the exported
comedi_buf_* functions in comedidev.h to follow the function
declarations in comedi_buf.c.
Also, change a couple of the return values from 'unsigned' to
'unsigned int' to match the value actually returned.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This helper function is only called by the comedi core in comedi_buf.c
and comedi_fops.c. For aesthetic reasons, move it to comedi_buf.c and
remove the inline. Move the prototype from comedidev.h to comedi_internal.h
so it's not exposed outside the comedi core.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Use the helper comedi_buf_write_n_allocated() to clarify the check
to make sure the number of bytes to free is not more than the number
of bytes allocated.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Refactor this function so there is a single return point and only
one BUG_ON check. The BUG_ON needs to be looked at to see if it
can be safely removed.
Clarify the test in the munge loop that checks for a block copy
that would extend pass the end of the prealloc_buf.
Reword the comment about the need for the smp_wmb().
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: comedi_buf: factor out common comedi_buf_write_alloc_* code
The only difference between comedi_buf_write_alloc() and the *_strict()
version is that the *_strict() one will only allocate the chunk if it
can completely fulfill the request.
Factor out the common code and add a flag parameter to indicate the 'strict'
usage. Change the exported functions so they are just wrappers around the
common function.
Cleanup the common function a bit and use the comedi_buf_write_n_available()
helper to determine the number of bytes available.
comedi_buf_write_n_available() is not used outside this module so make it
static. Since the only caller is __comedi_buf_write_alloc(), which will
always have a valid async pointer and already has a memory barrier, we
can remove the unnecessary (async == NULL) test as well as the smp_mb().
Also, the rounding of the sample size can be removed since the caller
does not need it.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: comedi_buf: factor out new buffer allocation code
The function comedi_buf_alloc() first frees any allocated buffer then,
optionally, allocates a new buffer.
Factor out the new buffer allocation code to a new function. This
allows reducing the indent level and makes the code a bit cleaner.
Also, cleanup to factored out code to make it a bit more concise.
Use a local variable for the current comedi_buf_page being allocated.
This cleans up the ugly line breaks used to keep the lines < 80 chars.
Move the #ifdef'ery for the page protection determination out of the
vmap() call.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: comedi_buf: factor out common code to free the async buffer
The function comedi_buf_alloc() uses two loops to free the async buffer's
buf_page_list. The first one is used at the beginning to deallocate the
current buffer. The second is used to cleanup if the new buffer allocation
fails.
Factor out the common code to a new function.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: separate out comedi_buf_* functions
Create a new file, comedi_buf.c, to hold all the comedi_async buffer
functions. Currently they are all in drivers.c and really don't have
any association with that source file.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: deprecate loading firmware with comedi_config
All the comedi drivers have been converted to use the request_firmware()
hotplug interface. The COMEDI_DEVCONFIG ioctl support for passing the
firmware blob as 'aux_data' is no longer required.
Remove the feature and give the user a dev_warn message if it is
attempted.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Setting `info = comedi_file_info_from_minor(minor)` and `dev =
comedi_dev_from_minor(minor)` in the same function is a bit of a waste.
The latter function is just a call of the former followed by a
conditional return of an embedded pointer (`info->device`) or NULL. The
former function uses a spin-lock which is where the wastfulness comes
in.
Move the "followed by a conditional return of an embedded pointer" part
into a new function `comedi_dev_from_file_info` and call this instead of
`comedi_dev_from_minor()` in the places where
`comedi_file_info_from_minor()` is also called.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: tidspbridge: remove unused code to handle iva_img
There is no way to specify the value of iva_img and since this code
is not being used, remove it.
This analysis resulted from a report by
Chen Gang <gang.chen@asianux.com>, mentioning that the existing code
was wrongly specifying the size to be copied.
Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: tidspbridge: fix memory corruption on long string names
The value allocated doesn't match the one that is meant to be
stored, resulting in corruption of memory for longer strings
that can't be held in such space.
Fix by allocating the correct byte value for the string meant to
be stored.
Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: tidspbridge: fix potential array out of bounds write
The name of the firmware (drv_datap->base_img) could potentially
become equal to 255 valid characters (size of exec_file), this
will result in an out of bounds write, given that the 255 chars
along with a '\0' terminator will be copied into an array of
255 chars.
Produce an error on this cases, because the driver expects the NULL
ending to be among the 255 char limit.
Reported-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Dan Carpenter [Wed, 9 Jan 2013 07:12:14 +0000 (10:12 +0300)]
staging: sb105x: clean up interface type test
IIR_RS232 is zero so "if (IIR_RS232 == (b_ret & IIR_RS232))" is always
true so RS232 was always chosen by default. The test should be
"if (0 == (b_ret & 0x30)) { ". The other tests should also be in that
format.
This does change how the code works... If 0x30 is set then it now
defaults to RS232 instead of RS485.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This fixes all instances of
"Please, no spaces at start of a new line"
"Please, no spaces before tabs"
Please note that I probably got the warning names wrong,
but they should be close enough for usage here :)
Additional post-commit note: There is one comment on line 230ish in slic.h
that appears to have lost it's formatting. It was fine when I was working
in Geany, but it caught my eye in the below diff. Sorry if it actually happened!
Dan Carpenter [Wed, 9 Jan 2013 07:09:19 +0000 (10:09 +0300)]
Staging: bcm: copying more data than intended
This was changed to bcm_flash2x_cs_info instead of bcm_flash_cs_info
when we got rid of the typedefs. bcm_flash2x_cs_info is quite a bit
larger than bcm_flash_cs_info (436 bytes instead of 96) so it would
corrupt user memory and it's an info leak.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fix the following warning when building with W=1 option:
drivers/staging/imx-drm/ipu-v3/ipu-common.c: In function 'ipu_remove':
drivers/staging/imx-drm/ipu-v3/ipu-common.c:1145:19: warning: variable 'res' set but not used [-Wunused-but-set-variable]
Andy Gross [Wed, 19 Dec 2012 20:53:38 +0000 (14:53 -0600)]
drm/omap: Add OMAP5 support
Add support for OMAP5 processor. The main differences are that the OMAP5
has 2 containers, one for 1D and one for 2D. Each container is 128MiB in
size.
Signed-off-by: Andy Gross <andy.gross@ti.com> Signed-off-by: Rob Clark <rob@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Andy Gross [Wed, 19 Dec 2012 20:53:37 +0000 (14:53 -0600)]
drm/omap: Add PM capabilities
Added power management capabilities into the omapdrm and DMM drivers.
During suspend, we don't need to do anything to maintain the state of
the LUT. We have all the necessary information to recreate the mappings
of the GEM object list maintained by the omapdrm driver.
On resume, the DMM resume handler will first reprogram the LUT to point
to the dummy page. The subsequent resume handler in the omapdrm will call
into the DMM and reprogram each of the buffer objects. This will ensure
that all of the necessary objects will be pinned into the DMM properly.
Order of suspend/resume handlers is done by device creation. We create
the DMM device before the omapdrm, so the correct order is maintained.
Signed-off-by: Andy Gross <andy.gross@ti.com> Signed-off-by: Rob Clark <rob@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: ced1401: fix GFP_KERNEL in spinlock context
Allowi() calls usb_submit_urb(pdx->pUrbCharIn, bInCallback ? GFP_ATOMIC : GFP_KERNEL)
under spin_lock_irqsave(&pdx->charInLock, flags). That means it should use GFP_ATOMIC anyway.
As soon as it is the only usage of bInCallback argument, the patch removes it at all.
Found by Linux Driver Verification project (linuxtesting.org).
Note that "midibuf" would be another good name but sound/oss/midibuf.c
already uses it for a different concept. Avoid possible confusion by
using "midi_buffer" instead.
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stefan Hajnoczi [Fri, 11 Jan 2013 22:08:11 +0000 (23:08 +0100)]
staging: line6: use pr_err() instead of printk(KERN_ERR, ...)
Fix the following checkpatch.pl warning:
WARNING: Prefer netdev_err(netdev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ...
#1861: FILE: staging/line6/driver.h:56:
+ printk(KERN_ERR "line6usb driver bug: missing case in %s:%d\n", \
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stefan Hajnoczi [Fri, 11 Jan 2013 22:08:10 +0000 (23:08 +0100)]
staging: line6: wrap comment to 80 chars in driver.c
Fix the following checkpatch.pl warning:
WARNING: line over 80 characters
#1107: FILE: staging/line6/driver.c:523:
+ /* Wait for data length. We'll get a couple of 0xff until length arrives. */
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Since the struct is only used to define the global
toneport_source_info[] table, I have chosen to make the struct
anonymous and part of the table definition.
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Przemo Firszt [Mon, 10 Dec 2012 23:21:22 +0000 (23:21 +0000)]
rtl8712: replace min with min_t
I've changed the ugly casting here and used min_t() instead. I
also changed the u16 to a u32 because ->network.Ssid.SsidLength
is 32 bits. It doesn't make a difference, but truncating the
upper bits away is sloppy.
Przemo Firszt [Mon, 10 Dec 2012 23:21:19 +0000 (23:21 +0000)]
rtl8712: code clean up
Clean some trivial formating problems in rtl8712 from staging tree. This patch
also changes the way preprocessor macros are defined to keep checkpatch.pl
quiet.
staging: tidspbridge: use prepare/unprepare on dsp clocks
This solves runtime failures while trying to enable WDT3 related
functionality on firmware load, however it does affect other clocks
controlled by the driver. Seen on 3.8-rc1.
CCF provides clk_prepare and clk_unprepare for enable and disable
operations respectively, this needs to be called in the correct
order while handling clocks.
Code path to enable/disable dsp clocks can still be reached from an
atomic context, hence we can't use clk_prepare_enable and
clk_disable_unprepare yet.
Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: tidspbridge: Fix build breakage due to splitting CM functions.
Commit ff4ae5d (ARM: OMAP2+: CM/hwmod: split CM functions into OMAP2, OMAP3-specific files)
resulted in a build breakage for tidspbridge driver.
...
CC [M] drivers/staging/tidspbridge/core/tiomap3430.o
staging/tidspbridge/core/tiomap3430.c: In function ‘bridge_brd_start’:
staging/tidspbridge/core/tiomap3430.c:550:24: error: ‘OMAP3430_CM_AUTOIDLE_PLL’
undeclared (first use in this function)
make[3]: *** [drivers/staging/tidspbridge/core/tiomap3430.o] Error 1
...
Fix this by including the appropriate header file.
Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Peter Huewe [Mon, 7 Jan 2013 22:09:53 +0000 (23:09 +0100)]
staging/csr: Fix dereference before check
Smatch complains about some pointers that are dereferenced before being
checked:
drivers/staging/csr/sme_sys.c:285
CsrWifiRouterCtrlHipReqHandler() warn: variable dereferenced before
check 'priv' (see line 283)
drivers/staging/csr/sme_sys.c:1503
CsrWifiRouterMaPacketReqHandler() warn: variable dereferenced before
check 'priv' (see line 1501)
drivers/staging/csr/sme_sys.c:2062
CsrWifiRouterCtrlPeerDelReqHandler() warn: variable dereferenced before
check 'priv' (see line 2059)
drivers/staging/csr/sme_sys.c:2477
CsrWifiRouterCtrlPeerAddReqHandler() warn: variable dereferenced before
check 'priv' (see line 2474)
drivers/staging/csr/sme_sys.c:3045
CsrWifiRouterCtrlWapiRxPktReqHandler() warn: variable dereferenced
before check 'priv' (see line 3039)
We put the check before the dereferencing and prevent an oops and fix
the warning.
Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Instead of using the #ifdef'ery in the comedi_compat32.c and proc.c
files to include/exclude them from the comedi core, modify the Makefile
to include those files automatically when enabled in the .config.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 4 Jan 2013 11:33:21 +0000 (11:33 +0000)]
staging: comedi: comedi_test: fix race when cancelling command
Éric Piel reported a kernel oops in the "comedi_test" module. It was a
NULL pointer dereference within `waveform_ai_interrupt()` (actually a
timer function) that sometimes occurred when a running asynchronous
command is cancelled (either by the `COMEDI_CANCEL` ioctl or by closing
the device file).
This seems to be a race between the caller of `waveform_ai_cancel()`
which on return from that function goes and tears down the running
command, and the timer function which uses the command. In particular,
`async->cmd.chanlist` gets freed (and the pointer set to NULL) by
`do_become_nonbusy()` in "comedi_fops.c" but a previously scheduled
`waveform_ai_interrupt()` timer function will dereference that pointer
regardless, leading to the oops.
Fix it by replacing the `del_timer()` call in `waveform_ai_cancel()`
with `del_timer_sync()`.
Ian Abbott [Thu, 3 Jan 2013 12:15:26 +0000 (12:15 +0000)]
staging: comedi: Kconfig: COMEDI_NI_AT_A2150 should select COMEDI_FC
The 'ni_at_a2150' module links to `cfc_write_to_buffer` in the
'comedi_fc' module, so selecting 'COMEDI_NI_AT_A2150' in the kernel config
needs to also select 'COMEDI_FC'.
Ian Abbott [Fri, 4 Jan 2013 11:33:24 +0000 (11:33 +0000)]
staging: comedi: comedi_test: make samples unsigned
Represent the fake samples as unsigned shorts instead of signed shorts,
as this is the usual Comedi convention. There is no change to the
actual binary representation, although the `cfc_write_to_buffer()` call
currently expects a signed short for some bizarre reason.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 4 Jan 2013 11:33:23 +0000 (11:33 +0000)]
staging: comedi: comedi_test: change end-of-acquisition test
In the "comedi_test" module's acquisition timer function
`waveform_ai_interrupt()`, move the code for ending the acquisition
outside the scan loop. Determine if the number of scans to be done is
sufficient to end the acquisition before entering the scan loop. On
leaving the scan loop, set the `COMEDI_CB_EOA` event if the acquisition
is ending. Only reschedule the timer if the acquisition is not ending.
Remove the somewhat useless `timer_running` flag from the private data.
This was intended to stop the timer function adding the timer back on
the timer queue periodically, but the flag setting wasn't synchronized
with the timer and we already use `del_timer_sync()` to synchronize
removal from the queue.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
In the "comedi_test" module, the timer function
`waveform_ai_interrupt()` doesn't need to remove the timer from the
timer queue as the caller has already removed it from the queue. Remove
the call to `del_timer()` in this function.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 4 Jan 2013 11:33:21 +0000 (11:33 +0000)]
staging: comedi: comedi_test: fix race when cancelling command
Éric Piel reported a kernel oops in the "comedi_test" module. It was a
NULL pointer dereference within `waveform_ai_interrupt()` (actually a
timer function) that sometimes occurred when a running asynchronous
command is cancelled (either by the `COMEDI_CANCEL` ioctl or by closing
the device file).
This seems to be a race between the caller of `waveform_ai_cancel()`
which on return from that function goes and tears down the running
command, and the timer function which uses the command. In particular,
`async->cmd.chanlist` gets freed (and the pointer set to NULL) by
`do_become_nonbusy()` in "comedi_fops.c" but a previously scheduled
`waveform_ai_interrupt()` timer function will dereference that pointer
regardless, leading to the oops.
Fix it by replacing the `del_timer()` call in `waveform_ai_cancel()`
with `del_timer_sync()`.
staging: comedi: store the 'index' for each subdevice
Store the 'index' for each comedi_subdevice when they are initially
allocated by comedi_alloc_subdevice(). This allows removing the
pointer math in comedi_fops.c which is used to figure out the
index that user space uses to access the individual subdevices.
Fix the ni_mio_common driver so it also uses the 'index' instead
of doing the pointer math.
Also, remove a couple unused macros in the pcmda12, pcmmio, and
pcmuio drivers which also do the pointer math to figure out the
index.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Use comedi_dev_from_minor() to simplify the return -ENODEV tests.
Change the (foo == NULL) tests to simply (!foo).
Use a local variable to hold a pointer to the async->buf_page_list[]
when doing the remap_pfn_range(). This cleans up the ugly line breaks
for the page_to_pfn(virt_to_page(...) operation.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>