Lidza Louina [Mon, 26 Aug 2013 18:04:59 +0000 (14:04 -0400)]
staging: dgnc: tty.c: edits var in init func for sparse
This patch edits the vaddr variable in dgnc_tty_init.
The variable gets set to board_t->re_map_membase. A
previous patch changed the re_map_membase variable's
marker and type. This patch makes sure that the
changes are consistent and that it doesn't cause
sparse warnings.
Lidza Louina [Mon, 26 Aug 2013 17:56:11 +0000 (13:56 -0400)]
staging: dgnc: neo.c: changes param in neo_read_eeprom function for sparse
This patch adds a marker to neo_read_eeprom function's
base parameter.
It removes these warnings found in neo.c:
warning: incorrect type in argument 1 (different address spaces)
expected unsigned char *base
got unsigned char [noderef] [usertype] <asn:2>*re_map_membase
warning: incorrect type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr
got unsigned char *
These warnings happen because this function gets
called with a board_t->re_map_base variable. A previous
patch added the __iomem marker to this variable. This
patch ensures that the changes are consistent.
Lidza Louina [Mon, 26 Aug 2013 16:49:31 +0000 (12:49 -0400)]
staging: dgnc: driver.h: changes a struct board_t var's type and marker for sparse
This patch changes the board_t->re_map_membase variable
type and marker.
It removes these warnings found in the neo.c,
driver.c and cls.c files:
warning: incorrect type in argument 1 (different address spaces)
expected void const volatile [noderef] <asn:2>*addr
got unsigned char volatile *<noident>
warning: incorrect type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr
got unsigned char volatile *<noident>
The variables passed to readb and writeb need to
be of type u8 with a __iomem marker. These warnings
were popping up everytime the readb and writeb
functions were called with a
board_t->re_map_membase variable.
The change made to the driver.h file adds the marker
and changes the variable type.
Lidza Louina [Mon, 26 Aug 2013 15:08:02 +0000 (11:08 -0400)]
staging: dgnc: neo_uart_struct: adds marker and changes vars' types for sparse
This patch fixes these warnings found in the neo.c file:
warning: incorrect type in argument 1 (different address spaces)
expected void const volatile [noderef] <asn:2>*addr
got unsigned char volatile *<noident>
warning: incorrect type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr
got unsigned char volatile *<noident>
The variables passed to readb and writeb need to
be of type u8 with a __iomem marker. These warnings
were popping up everytime the readb and writeb
functions were called with a neo_uart_struct variable.
The change made to the driver.h file adds the marker
to the neo_uart_struct and the changes in neo.h
changes the variables' types.
Lidza Louina [Mon, 26 Aug 2013 14:53:09 +0000 (10:53 -0400)]
staging: dgnc: cls_uart_struct: adds marker and changes vars' types for sparse
This patch removes these sparse warnings found in the cls.c file:
warning: incorrect type in argument 1 (different address spaces)
expected void const volatile [noderef] <asn:2>*addr
got unsigned char volatile *<noident>
warning: incorrect type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr
got unsigned char volatile *<noident>
The variables passed to readb and writeb need to
be of type u8 with a __iomem marker. These warnings
were popping up everytime the readb and writeb
functions were called with a cls_uart_struct variable.
The change made to the driver.h file adds the marker
to the cls_uart_struct and the changes in cls.h
changes its variables' types.
Ian Abbott [Fri, 23 Aug 2013 13:45:10 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: use correct minor device numbers in name
The board name for "comedi_bond" is constructed from a space-separated
list of items of the form "minor:subdevice" where "minor" is a minor
device number and "subdevice" is a subdevice number. Currently, all the
"minor" device numbers are for the "comedi_bond" device itself and the
"subdevice" numbers are for the bonded devices. It makes makes more
sense for the "minor" device numbers to come from the bonded devices as
well so that the string is a list of bonded "minor:subdevice" pairs.
Fix it.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:45:09 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: use krealloc() and fix memory leak
`do_dev_config()` is called from the comedi 'attach' handler,
`bonding_attach()`. The device private data structure contains a
dynamically allocated array of pointers to "bonded" device structures
which grows during the `do_dev_config()` call. The length of this array
is in `devpriv->ndevs`. It currently uses a local function `realloc()`
to allocate a new array, copy the old contents over and free the old
array. It should be more efficient to use `krealloc()` as it may be
able to use slack space at the end of the previous array and avoid a
copy.
The old `realloc()` function always freed the old buffer which meant
that if it failed to allocate the new buffer it would lose the contents
of the old buffer. Unfortunately, that contained pointers to more
dynamically allocated memory, leading to a memory leak. If `krealloc()`
fails, keep the old buffer and avoid the memory leak. The
aforementioned pointers to more dynamically allocated memory will be
cleaned up by the 'detach' handler, `bonding_detach()` which will be
called by the comedi core as a consequence of `krealloc()` failing in
`do_dev_config()`.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:45:08 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: handle base channel for insn_bits
If a DIO subdevice has more than 32 channels, its 'insn_bits' handler is
supposed to take account of the base channel from
`CR_CHAN(insn->chanspec)`. (The comedi core will adjust the base
channel to 0 and shift the mask and data to compensate if the subdevice
has less than or equal to 32 channels.) The "comedi_bond" driver
currently ignores the base channel and assumes it is 0.
Replace `comedi_dio_bitfield()` in the "kcomedilib" module with
`comedi_dio_bitfield2()` that takes account of the base channel, and
rewrite the "comedi_bond" driver's 'insn_bits' handler
(`bonding_dio_insn_bits()`) to take account of the base channel and use
the new function.
No other modules use `comedi_dio_bitfield()` so it is safe to replace it
with `comedi_dio_bitfield2()`. The name follows that of the equivalent
function in the user-space comedilib. If the base channel is non-zero
and the subdevice has less than or equal to 32 channels it needs to
adjust things in the same way as the comedi core (same as `parse_insn()`
in "comedi_fops.c") due to most drivers ignoring the base channel.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:45:07 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: get INSN_CONFIG_DIO_QUERY info from horse's mouth
The DIO subdevice of the "comedi_bond" device attempts to remember the
directions of DIO channels itself in the `io_bits` member of the
subdevice, but that is only large enough for the first 32 channels and
it might not be accurate anyway as changing the direction of one channel
may have affected a whole group of channels and we have no idea of the
initial directions before the "bonded" device was linked to the the
"comedi_bond" device. It would be better to ask the bonded device for
this information when handling a `INSN_CONFIG_DIO_QUERY` configuration
instruction. Add new function `comedi_dio_get_config()` to the
"kcomedilib" module to allow us to get the DIO direction of a channel
and use it.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:45:06 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: just check devprivs->devs once on detach
The `while` loop in `bonding_detach()` doesn't need to check
`devpriv->devs` each time round the loop. Move the test outside the
loop. The enclosing `if (devpriv)` can be changed to `if (devpriv &&
devpriv->devs)` as everything in this `if` statement is associated with
`devpriv->devs` anyway.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:45:05 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: no need to free dev->private on detach
The comedi core will free `dev->private` if it is non-NULL after calling
the "detach" handler (`bonding_detach()`), so don't bother freeing it in
`bonding_detach()`.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The private data structure (`struct comedi_bond_private`) for the
overall "comedi_bond" device maps each channel individually to a pointer
to the `struct bonded_device` it belongs to via array member
`chan_id_dev_map[MAX_CHANS]`. This speeds up look-ups from channel
number to bonded device a bit, but the length of the array used to look
this up is currently fixed at `MAX_CHANS` (256) and there are no
overflow checks when filling the array.
In practice, there will only be a few bonded devices (actually bonded
subdevices) and it is practical to just skip through the list until we
reach the one containing the desired channel.
The only place where the bonded device is looked up from the channel
number is in `bonding_dio_insn_config()`. Change it to do the look-up
by skipping through the list of bonded devices and remove the
`chan_id_dev_map[]` member. The `chanid_offset` member of `struct
bonded_device` is also no longer needed as the value can be derived
while skipping through the list of bonded devices, so remove that member
as well.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:45:02 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: use bitmap to record opened/closed minors
`do_dev_config()` currently records the comedi minor devices it has
opened by setting `devs_opened[minor]` to the pointer returned by
`comedi_open()`. This is checked to avoid opening the same minor device
twice. The pointer values in `devs_opened[]` aren't needed; we only
need to record which minor device numbers are being used. Change
`devs_opened` to a bitmap (declared with `DECLARE_BITMAP()`) of length
`COMEDI_NUM_BOARD_MINORS` as the minor device numbers are range-checked
to fit in a bitmap of this length. Use `test_and_set_bit()` to record
the minor device numbers we attempt to open with `comedi_open()`.
`bonding_detach()` calls `comedi_close()` to close the comedi minor
devices. Since the minor device numbers may be repeated in its list of
bonded subdevices, it currently uses a simple `unsigned long
devs_closed` variable as a bitmap to keep track of which minor device
numbers it has already closed to avoid closing them twice. As a single
`unsigned long` consists of less than `COMEDI_NUM_BOARD_MINORS` bits on
a 32-bit machine, change `devs_closed to a bitmap of this length using
`DECLARE_BITMAP()` and use `test_and_set_bit()` to avoid calling
`comedi_close()` more than once for each minor device number in use.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:45:01 +0000 (14:45 +0100)]
staging: comedi: comedi_bond: change return value of bonding_attach()
`bonding_attach()` is the comedi "attach" handler for the driver. Any
non-negative return value is treated as successful, but 0 is the
preferred return value on success.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 23 Aug 2013 13:44:59 +0000 (14:44 +0100)]
staging: comedi: comedi_bond: no need to initialize file[]
The `char file[]` variable in `do_dev_config()` doesn't need to be
initialized as it gets overwritten with a `snprintf()`. It just needs
to be long enough.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Chen Gang [Mon, 26 Aug 2013 03:55:50 +0000 (11:55 +0800)]
staging: dgnc: Kconfig: add dependency PCI for it
DGNC is based on PCI, so need add related dependency, or when compiled
with PCI disabled, it will be fail.
The related error (randconfig for PCI disabled under s390):
drivers/staging/dgnc/dgnc_cls.c:1394:2: error: implicit declaration of function ‘ioremap’ [-Werror=implicit-function-declaration]
drivers/staging/dgnc/dgnc_cls.c:1407:3: error: implicit declaration of function ‘iounmap’ [-Werror=implicit-function-declaration]
Larry Finger [Sun, 25 Aug 2013 16:55:15 +0000 (11:55 -0500)]
staging: r8188eu: Fix build errors for allyesconfig
This driver has some global names that are the same as found in
driver r8712. Fix the allyesconfig build errors by changing the
names of those routines.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Larry Finger [Sun, 25 Aug 2013 16:49:37 +0000 (11:49 -0500)]
staging: gdm724x: Remove tests of KERNELVERSION
Kernel code need not test for KERNELVERSION. Besides being unnecessary
for an in-kernel driver, these lines will cause a build failure for any
source tree with a stale include/linux/version.h.
This patch is only compile tested.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: line6: use default sysfs attribute macros
Move to use the DEVICE_ATTR_RW/RO macros, making it easier to audit the
sysfs file permissions, and get rid of the "empty" callback for
read-only files, saving lines of code.
Cc: Stefan Hajnoczi <stefanha@gmail.com> Cc: Laurent Navet <laurent.navet@gmail.com> Cc: Johannes Thumshirn <morbidrsa@googlemail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The sysfs file in this driver is showing a raft of debugging values,
none of which belong in sysfs, let alone in a single sysfs file. If
these really need to be described somewhere, they should go into
debugfs.
For now, just delete the sysfs file, which removes a bunch of files from
the tree.
Cc: Henk de Groot <pe1dnn@amsat.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Lidza Louina [Fri, 23 Aug 2013 02:17:11 +0000 (22:17 -0400)]
staging: dgap: removes proc.c
This patch removes proc.c. This code isn't needed anymore because
a previous patch removed references to it and because the kernel
uses sysfs instead of proc.
Lidza Louina [Thu, 22 Aug 2013 18:54:15 +0000 (14:54 -0400)]
staging: dgnc: driver.c: removes dgnc_mbuf function
This patch removes the dgnc_mbuf function. This function was causing the
errors:
drivers/staging/dgnc/dgnc_driver.c: In function 'dgnc_mbuf.constprop.0':
drivers/staging/dgnc/dgnc_driver.c:945:1: warning: the frame size of 1032
bytes is larger than 1024 bytes [-Wframe-larger-than=]
drivers/staging/dgnc/dgnc_tty.c: In function 'dgnc_sniff_nowait_nolock':
drivers/staging/dgnc/dgnc_tty.c:614:1: warning: the frame size of 1056
bytes is larger than 1024 bytes [-Wframe-larger-than=]
This patch removes it so the kernel won't be making noise when its
device is found on the system.