staging: dwc2: make dwc2_core_params documentation more complete
Some of the defaults were missing or unclear. In particular, I suspect
the defaults were documented assuming there were still module parameters
and taking the default module parameters into account. Now, the defaults
are the values that will get chosen when the params passed to
dwc2_hcd_init are all -1.
staging: dwc2: validate the value for phy_utmi_width
The HWCFG4 register stores the supported utmi width values (8, 16 or
both). This commit reads that value and validates the configured value
against that.
If no (valid) value is given, the parameter defaulted to 8 bits
previously. However, the documentation for dwc2_core_params_struct
suggests that the default should have been 16. Also, the pci bindings
explicitely set the value to 16, so this commit changes the default to
16 bits (if supported, 8 bits otherwise).
With the default changed, the value set in pci.c is changed to -1 to
make it autodetected as well.
staging: dwc2: interpret all hwcfg and related register at init time
Before, the hwcfg registers were read at device init time, but
interpreted at various parts in the code. This commit unpacks the hwcfg
register values into a struct with properly labeled variables at init
time, which makes all the other code using these values more consise and
easier to read. Some values that were previously stored in the hsotg
struct are now moved into this new struct as well.
In addition to the hwcfg registers, the contents of some fifo size
registers are also unpacked. The hwcfg registers are read-only, so they
can be safely stored. The fifo size registers are read-write registers,
but their power-on values are significant: they give the maximum depth
of the fifo they describe.
This commit mostly moves code, but also attempts to simplify some
expressions from (val >> shift) & (mask >> shift) to
(val & mask) >> shift.
Finally, all of the parameters read from the hardware are debug printed
after unpacking them, so a bunch of debug prints can be removed from
other places.
Bits 16-31 are reserved, so the old code just reads the whole register to
get bits 0-15, assuming the reserved bits would be 0 (which seems true
on current hardware, but who knows...).
This commit properly masks out the reserved bits when reading and
doesn't touch the reserved bits while writing.
For calculating FIFO offsets, the sizes of preceding fifos need to be
known. For filling the GDFIFOCFG register, these fifo sizes were read
from hardware registers. However, these values were written to these
registers just a few lines before, so we can just use the values written
instead.
For some reason, the value of the HPTXFSIZ register was built in the
ptxfsiz variable, while there was also a hptxfsiz variable availble.
Better just use that and remove the (now unused) ptxfsiz variable.
staging: dwc2: simplify debug output in dwc_hc_init
The value of the hcchar register is built from individual values by
shifting and masking. Before, the debug output extracted the individual
values out of the complete hcchar register again by doing the reverse.
This commit makes the debug output use the original values instead.
One debug message got removed, since it would always print a fixed value
of zero.
This line extracted the available queue space without properly shifting
it. Since the code only cared wether it was zero or not, it worked as
expected without the shift, but adding shift makes the code cleaner.
While we're here, store the result in a helper variable that was already
declared to increase readability a bit more.
staging: dwc2: unshift non-bool register value constants
Various register fields wider than one bit have constants defined for
their value. Previously, these registers would define the values as they
appear in the register, so shifted to the right to the position the
value appears in the register.
This commit changes those constants to their natural values (e.g, 0, 1,
2, etc.), as they are after shifting the register value to the right.
This also changes all relevant code to shift the values before comparing
them with constants.
This has the advantage that the values can be stored in smaller
variables (now they always require a u32) and makes the handling of
these values more consistent with other register fields that represent
natural numbers instead of enumerations (e.g., number of host channels).
staging: dwc2: fix off-by-one in check for max_packet_count parameter
Previously, the max_packet_count could be set to 1 << x, where x is the
number of bits available (width + 4 in the code). Since 1 << x requires
x + 1 bits to represent, this will not work. The real maximum value is
(1 << x) - 1. This value is already used the default when the set value
is invalid, but the upper limit for the set value was off-by-one.
This change makes the check the same as the one for max_transfer_size,
which was already correct.
staging: dwc2: remove specific fifo size constants
A generic set of FIFOSIZE_* constants is defined which applies to all
fifo size and offset registers. It is already used for both the
GNPTXFSIZ and HPTXFSIZ registers, but it applies to DPTXFSIZN as well.
Some of these also had specific constants defined. This patch removes
the specific constants and documents to use the generic constants.
Note that the removed constants weren't actually used. Instead, most of
the related code uses hardcoded masks and shifts. But given that
subsequent patches will be moving that code around and introducing the
constants in the process, this patch leaves those untouched.
Also note that the GRXFSIZ register also contains a fifo size, but
there is no corresponding start address register (it is always the first
fifo in memory), the layout of the GRXFSIZ register is different and
cannot use the same constants.
Larry Finger [Thu, 29 Aug 2013 02:12:25 +0000 (21:12 -0500)]
staging: r8188eu: Fix compiler warnings in os_dep/ioctl_linux.c
The 0-DAY kernel build testing backend reports the following compiler
warnings not shown on my compiler version/options:
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c: In function 'rtw_mp_efuse_get':
>> drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:5836:65: warning: iteration 16u invokes undefined behavior [-Waggressive-loop-optimizations]
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
^
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:5830:3: note: containing loop
for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
^
>> drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:6042:69: warning: iteration 16u invokes undefined behavior [-Waggressive-loop-optimizations]
sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
^
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:6036:3: note: containing loop
for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
^
The problem is due to improper settings for some of the EFUSE_XXX defines such that
EFUSE_MAP_SIZE was larger than the sizes of the marked arrays. Thanks to
Fengguang Wu for helping me understand the root cause.
drivers/staging/dgap/dgap_driver.c: In function ‘dgap_cleanup_module’:
drivers/staging/dgap/dgap_driver.c:423: error: implicit declaration of function ‘kfree’
drivers/staging/dgap/dgap_driver.c: In function ‘dgap_driver_kzmalloc’:
drivers/staging/dgap/dgap_driver.c:940: error: implicit declaration of function ‘kmalloc’
drivers/staging/dgap/dgap_driver.c:940: warning: initialization makes pointer from integer without a cast
Merge tag 'iio-for-3.12c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
Third set of new drivers, cleanups and features for IIO in the 3.12 cycle.
New drivers
1) Bosh BMA180 accelerometer + a new sysfs abi element, power_mode to
allow for device that trade off accuracy and power usage.
Cleanups
1) Another lot of devm_iio_device_alloc patches
2) An code ordering bug in the twl6030 driver introduced earlier in this
cycle.
New features
1) at91 adc driver rework to support a wider range of parts and drop
the necessity for some of the current device tree elements. This is
a precursor to introducing input support which is still under review.
staging: vt6656: baseband.h re: baseband.c:877:26: sparse: incorrect type in assignment (different base types)
sparse warnings: (new ones prefixed by >>)
...
>> drivers/staging/vt6656/baseband.c:877:26: sparse: incorrect type in assignment (different base types)
drivers/staging/vt6656/baseband.c:877:26: expected unsigned short [unsigned] [usertype] len
drivers/staging/vt6656/baseband.c:877:26: got restricted __le16 [usertype] <noident>
>> drivers/staging/vt6656/baseband.c:880:26: sparse: incorrect type in assignment (different base types)
drivers/staging/vt6656/baseband.c:880:26: expected unsigned short [unsigned] [usertype] len
drivers/staging/vt6656/baseband.c:880:26: got restricted __le16 [usertype] <noident>
Rupesh Gujare [Wed, 28 Aug 2013 11:43:14 +0000 (12:43 +0100)]
staging: ozwpan: Increase ISOC IN buffer depth
Buffer depth of 50 units is not sufficient when there is considerable delay
occuring on air due to interference, increase ISOC IN buffer depth to 100 units.
Andrea Merello [Mon, 26 Aug 2013 11:53:30 +0000 (13:53 +0200)]
staging: Update e-mail address for Andrea Merello
A lot of files contain reference to my old e-mail address.
Now I'm going not to read mail from it anymore, so update it
with my current address everywhere.
Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Lidza Louina [Wed, 28 Aug 2013 02:13:28 +0000 (22:13 -0400)]
staging: dgnc: driver.c and .h: removes dgnc_driver_kzmalloc func
This patch removes the dgnc_driver_kzmalloc function from
driver.c and driver.h. A previous patch replaced all
dgnc_driver_kzmalloc function calls with kzalloc.
Lidza Louina [Wed, 28 Aug 2013 02:13:26 +0000 (22:13 -0400)]
staging: dgnc: tty.c: updates uart_struct declaration for sparse
This patch edits the type casts neo_uart_struct and
cls_uart_struct. A previous patch added the marker __iomem
to these structs. This patch ensures that the change to
the marker is consistent. This also removes these
sparse warnings:
warning: incorrect type in assignment (different address spaces)
expected struct neo_uart_struct [noderef] <asn:2>*ch_neo_uart
got struct neo_uart_struct *<noident>
warning: incorrect type in assignment (different address spaces)
expected struct cls_uart_struct [noderef] <asn:2>*ch_cls_uart
got struct cls_uart_struct *<noident>
drivers/staging/rtl8188eu/core/rtw_p2p.c: In function 'go_add_group_info_attr':
>> drivers/staging/rtl8188eu/core/rtw_p2p.c:70:11: error: 'struct sta_info' has no member named 'is_p2p_device'
if (psta->is_p2p_device) {
This and the following errors were caused by an incorrect nesting of
conditional compilation directives.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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>