The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.
Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.
Ajay Singh [Tue, 26 Jun 2018 06:07:14 +0000 (11:37 +0530)]
staging: wilc1000: updated TODO file
Item [1] in TODO list is already addressed, so removed it from TODO file.
[1]. Move handling for each individual members of 'union message_body' out
into a separate 'struct work_struct' and completely remove the
multiplexerthat is currently part of host_if_work(), allowing movement
of the implementation of each message handler into the callsite of the
function that currently queues the 'host_if_msg'.
Ajay Singh [Tue, 26 Jun 2018 06:07:11 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of 'key' & 'seq' data in wilc_add_rx_gtk()
Handle freeing of memory allocated to keep 'key' & 'seq' in wilc_add_rx_gtk().
Once completion event is received, free the memory allocated for
to avoid missing of free in work function.
Ajay Singh [Tue, 26 Jun 2018 06:07:10 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of key data in wilc_add_ptk()
Handle freeing of memory allocated to store the 'key' in wilc_add_ptk()
function. Once work completion notification is received, free the
memory allocated to avoid missing of free in work function sepecially
for error scenario.
Ajay Singh [Tue, 26 Jun 2018 06:07:09 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of key data in wep add key
Modified the code to free the allocated memory, used to store the key in
wilc_add_wep_key_bss_sta() and wilc_add_wep_key_bss_ap().
After work completion notification is received, free the
memory allocated to avoid missing of free in work function.
Ajay Singh [Tue, 26 Jun 2018 06:07:08 +0000 (11:37 +0530)]
staging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work()
Rename wilc_enqueue_cmd() to wilc_enqueue_work() because its used to
enqueue the work queue. Also removed the function header comment for
wilc_enqueue_cmd() as its not correct.
Ajay Singh [Tue, 26 Jun 2018 06:07:06 +0000 (11:37 +0530)]
staging: wilc1000: added 'work_comp' completion as part of host_if_msg
Added 'work_comp' completion in 'host_if_msg'. It allows handling the
sync call to wait for sepecific completion event.
The commands can be run in sync way waiting for their specific
completion event.
Added is_sync flag in wilc_create_work_queue() to handle the sync call to
host interface.
After adding completion as part of host_if_msg now
below completion are not required
comp_test_key_block;
comp_test_disconn_block
comp_get_rssi
comp_inactive_time
hif_wait_response
Modified wilc_get_statistics() API to handle get statistic in sync &
async way.
Ajay Singh [Tue, 26 Jun 2018 06:07:05 +0000 (11:37 +0530)]
staging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd()
Instead of allocating the host_if_cmd in wilc_enqueue_cmd() now moved
the allocation of cmd in the caller. Added the NULL check for
'hif_workqueue' before posting the work queue in wilc_enqueue_cmd().
Ajay Singh [Tue, 26 Jun 2018 06:07:04 +0000 (11:37 +0530)]
staging: wilc1000: remove unused marco related to HIF commands
After removing the multiplexing of hif commands in hif_if_work()
macros prefix with 'HOST_IF_MSG_' are not required. Also 'id' field in
host_if_msg is not required anymore.
Ajay Singh [Tue, 26 Jun 2018 06:07:03 +0000 (11:37 +0530)]
staging: wilc1000: remove host_if_work() to handle TODO list issue
Remove multiplexing of command at host_if_work().
Make use of function pointer instead of command ID to track individual
work_struct separately.
Modified the handler function to take work_struct pointer as argument
and its return type is changes to void. Now prototype of 'handle_'
function is same work_struct i.e. 'void (*fun)(struct struct *)' to
register with work_queue.
Removed host_if_work() because its not required now.
Thibaut Robert [Tue, 19 Jun 2018 18:44:19 +0000 (20:44 +0200)]
staging: wilc1000: Use common structs to parse ip packets
Use structs ethhdr, iphdr and tcphdr instead of manual parsing in
tcp_process.
This commit fix handling of ip packets containing options.
It also fixes the following sparse warning:
drivers/staging/wilc1000//wilc_wlan.c:201:19: warning: cast to restricted __be16
Signed-off-by: Thibaut Robert <thibaut.robert@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: mt7621-gpio: avoid use banks in device tree
Banks shouldn't be defined in DT if number of resources
per bank is not variable. We actually know that this SoC
has three banks so take that into account in order to don't
overspecify the device tree. Device tree will only have one
node making it simple. Update device tree, binding doc and
code accordly.
staging: mt7621-gpio: update Kconfig with SoC details
Kconfig is using a generic 'Mediatek GPIO Support' in
description and help which is not specific at all about
the current SoC which is MT7621. Update it.
Interrupts from /proc/interrupt show the same name which is
confusing:
/proc/interrupts:
17: 0 0 0 0 MIPS GIC 19 mt7621, mt7621, mt7621
which is the interrupt from the GPIO controller.
It is a little weird that all three banks are named "mt7621"
here. We also have:
26: 0 0 0 0 GPIO 18 reset
which is the interrupt from GPIO which provides the "reset"
button. I suspect that if I had interrupts form two different
banks they would both be called "GPIO" which would be a little
confusing.
In order to unify all of this set different names for each chip
Use a 'bank-based' name instead the same for all: 'mt7621-bank[0-2]'.
Create a new 'mediatek_gpio_bank_name' function which return the
name depending on the bank number. This function is allways called
with a valid index 0, 1 or 2.
staging: mt7621-gpio: avoid one level indentation in interrupt handler
There is no need to check for 'pending' before loop over the
interrupts using 'for_each_set_bit' if nothing is set the
return values will be the same so just avoid this check avoiding
also one level intentation and improving readability.
staging: mt7621-gpio: remove no more necessary PIN_MASK macro
PIN_MASK macro was being used because of the fact we were only
using one interrupt controller for all of the gpio chips. This
has been changed to use one per gpio chip and each has 32 irqs.
Because of this this macro is not needed anymore. Use BIT macro
instead.
staging: mt7621-gpio: avoid custom irq_domain for gpio
Instead of create a custom irq_domain for this chip, use
'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
is ok to call this function several times. We have to
manually mark the line with 'IRQF_SHARED' and then loop
over the three banks until you find a hit. There were
some problems with removing an irqchip like that but this
driver is a bool so it might work just fine. After this
changes the functions 'mediatek_gpio_to_irq' is not needed
anymore and also the 'gpio_irq_domain' field from the state
container. Instead of use the custom irq domain in the irq
handler use the associated domain from the gpio_chip in
'irq_find_mapping' function. Function 'mediatek_gpio_bank_probe'
has been moved a it to the botton to have all the irq related
functions together and avoid some forward declarations to resolve
some symbols along the code.
When implementing custom irqchips it is important to also
implement .irq_request_resources() and .irq_release_resources()
and make sure these call gpiochip_[un]lock_as_irq().
Add those two for this driver. Also store struct device pointer
in global state structure to be able to use 'dev_err' with the
device from 'mediatek_request_resources' function.
staging: mt7621-gpio: make use of 'builtin_platform_driver'
This driver was being registered using 'module_platform_driver'
but it is not a module at all. Instead of this use
'builtin_platform_driver' which seems to be the correct one.
staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC
Gpio complexity is just masking the fact that offset is always
0..n and writes to bits 0..n of some memory address. Because
of this whole thing can just me converted to use GPIO_GENERIC
and avoid duplications of a lot of driver custom functions.
So use bgpio_init instead of custom code adding GPIO_GENERIC
dependency to the Kconfig file. Also to make easier using
bgpio_init function offset for each gpio bank, enumeration
where register were defined has been replaced in favour of
some macros which handle each gpio offset taking into account
the bank where are located. Because of this change write and
read functions which are being used for remaining irq handling
stuff have been updated also as well as its dependencies along
the code.
Rosen Penev [Sun, 17 Jun 2018 02:17:50 +0000 (19:17 -0700)]
staging: mt7621-dts: Fix remaining pcie warnings
This currently fixes the remaining dtb warnings:
Node /pcie@1e140000/pcie0 has a reg or ranges property, but no unit name
Node /pcie@1e140000/pcie1 has a reg or ranges property, but no unit name
Node /pcie@1e140000/pcie2 has a reg or ranges property, but no unit name
Node /pcie@1e140000/pcie0 node name is not "pci" or "pcie"
Node /pcie@1e140000/pcie0 missing ranges for PCI bridge (or not a bridge)
Node /pcie@1e140000/pcie0 missing bus-range for PCI bridge
Node /pcie@1e140000/pcie1 node name is not "pci" or "pcie"
Node /pcie@1e140000/pcie1 missing ranges for PCI bridge (or not a bridge)
Node /pcie@1e140000/pcie1 missing bus-range for PCI bridge
Node /pcie@1e140000/pcie2 node name is not "pci" or "pcie"
Node /pcie@1e140000/pcie2 missing ranges for PCI bridge (or not a bridge)
Node /pcie@1e140000/pcie2 missing bus-range for PCI bridge
Warning (unit_address_format): Failed prerequisite 'pci_bridge'
Warning (pci_device_reg): Failed prerequisite 'pci_bridge'
Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge'
device_type was removed since according to documentation, it's deprecated
for pci(e) devices.
staging: mt7621-mmc: Find response of SD_APP_OP_COND by default
The response type of the SD_APP_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_app_op_cond, correctly places MMC_RSP_R3 in cmd.flags.
So there is no need to treat that opcode separately.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: mt7621-mmc: Find response of MMC_SEND_OP_COND by default
The response type of the MMC_SEND_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_op_cond, correctly places MMC_RSP_R3 in cmd.flags.
So there is no need to treat that opcode separately.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: mt7621-mmc: Cleanup source of base address for io
Currently the base address for all io operations is hidden behind a
macro, REG_ADD. This macro uses the symbol "base" as the base address
and all functions set base = host->base. This is hard to read, so the
whole wrapping is removed and host->base is directly inserted in the
io access.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: mt7621-mmc: Make msdc_clr_fifo a function and relax cpu
In the current code, msdc_clr_fifo is a macro and just busy waits for
a limited amount of time for the fifo clear to finish. That is not
correct, the programming manual hits, that the user should wait until
the bit is cleared by hardware and not a limited amount of time.
So the code is changed to a function, that also relaxes the cpu while
busy waiting.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: mt7621-mmc: Remove unnecessary BUG_ON() in msdc_dma_setup
The BUG_ON() removed by this patch is just a duplicate of a prior
BUG_ON() statement. There the condition is just clearer, it checks
weather sglen > MAX_BD_NUM and MAX_BD_NUM is equal MAX_BD_PER_GPD. So
this statement can be safely removed.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Current code uses two functions for dma setup, msdc_dma_config and
msdc_dma_setup. By now msdc_dma_setup is nearly empty and mainly calls
msdc_dma_config, so the later one can be inline into the first
one. While doing this there is also some refactoring done.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Current code has structures for all the registers of the device, but
these are never used and there are also masks for all of them, so
these structures do not contain any useful information.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: mt7621-mmc: Replace sdr_write32 with writel
The current code uses a macro (sdr_write32) for writing to hardware,
but it is only a writel with switched arguments, so replace it to get
nearer to upstream code.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: mt7621-pinctrl: replace 'unsigned' types with 'unsigned int'
This commit replaces all 'unsigned' type declarations along
the driver code in favour of the preferred one 'unsigned int'.
This also silence checkpatch script warnings about this issue.
It's good to have SPDX identifiers in driver files to make it easier to
audit the kernel tree for correct licenses.
Fix up the one of staging mt7621-pinctrl file to have a proper SPDX
identifier, based on the license text in the file itself. The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.
Merge tag 'iio-for-4.19a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First set of IIO new device support, features and cleanups in the 4.19 cycle
The usual mixed bunch. Particular good to see is the generic
touch screen driver. Will be interesting to see if this works
for other ADCs without major changes.
Core features
* Channel types
- New position relative channel type primarily for touch screen
sensors to feed the generic touchscreen driver.
New device support
* ad5586
- Add support for the AD5311R DAC.
* Generic touch screen driver as an IIO consumer.
- Note this is in input, but due to dependencies is coming through
the IIO tree.
- Specific support for this added to the at91-sama5d2 ADC.
- Various necessary DT bindings added.
Staging Drops
* ADIS16060 gyro
- A device with a very odd interface that was never cleanly supported.
It's now very difficult to get, so unlikely it'll ever be fixed up.
Cleanups and minor features and fixes
* core
- Fix y2038 timestamp issues now the core support is in place.
* 104-quad-8
- Provide some defines for magic numbers to help readability.
- Fix an off by one error in register selection
* ad7606
- Put in a missing function parameter name in a prototype.
* adis16023
- Use generic sign_extend function rather than local version.
* adis16240
- Use generic sign_extend funciton rather than local version.
* at91-sama5d2
- Drop dependency on HAS_DMA now this is handled elsewhere. Will
improve build test coverage.
- Add oversampling ratio control. Note there is a minor ABI change
here to increase the apparent depth to 14 bits so as to allow
for transparent provision of different oversampling ratios that
drop the actual bit depth to 13 or 12 bits.
* hx711
- Add a MAINTAINERS entry for this device.
* inv_mpu6050
- Replace the timestamp fifo 'special' code with generic timestamp
handling.
- Switch to using local store of timestamp divider rather than rate
as that is more helpful for accurate time measurement.
- Fix an unaligned access that didn't seem to be causing any trouble.
- Use the fifo overflow bit to track the overflow status rather than
a software counter.
- New timestamping mechanism to deal with missed sample interrupts.
* stm32-adc
- Drop HAS_DMA build dependency.
* sun4i-gpadc
- Select REGMAP_IRQ a very rarely hit build issue fix.
Eugen Hristev [Thu, 21 Jun 2018 07:56:21 +0000 (10:56 +0300)]
iio: adc: at91-sama5d2_adc: add support for oversampling resolution
This implements oversampling support for the SAMA5d2 ADC device.
Enabling oversampling : OSR can improve resolution from 12 bits to
13 or 14 bits.
Changing the channel specification to have 14 bits, and we shift the value
1 bit to the left if we have oversampling for just one extra bit, and two
bits to the left if we have no oversampling (old support).
From this commit on, the converted values for all the voltage channels
change to 14 bits real data, with most insignificant two bits always zero
if oversampling is not enabled.
sysfs object oversampling_ratio has been enabled and
oversampling_ratio_available will list possible values (1 or 4 or 16) having
1 as default (no oversampling, 1 sample for each conversion).
Special care was required for the triggered buffer scenario (+ DMA), to
adjust the values accordingly.
Touchscreen measurements supported by this driver are not affected by
oversampling, they are still on 12 bits (scale handing is already included
in the driver).
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Arnd Bergmann [Mon, 18 Jun 2018 15:31:36 +0000 (17:31 +0200)]
iio: use timespec64 based interfaces for iio_get_time_ns()
We have replacements for all the deprecated timespec based interfaces now,
so this can finally convert iio_get_time_ns() to consistently use the
nanosecond or timespec64 based interfaces instead, avoiding the y2038
overflow.
Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: adc: Remove depends on HAS_DMA in case of platform dependency
Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
In most cases this other symbol is an architecture or platform specific
symbol, or PCI.
Generic symbols and drivers without platform dependencies keep their
dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
cannot work anyway.
This simplifies the dependencies, and allows to improve compile-testing.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Mark Brown <broonie@kernel.org> Acked-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Joshua Lang [Mon, 4 Jun 2018 21:08:22 +0000 (14:08 -0700)]
staging: goldfish: Clear audio read buffer status after each read
The buffer_status field is interrupt updated. After every read request,
the buffer_status read field should be reset so that on the next loop
iteration we don't read a stale value and read data before the
device is ready.
Signed-off-by: Joshua Lang <joshualang@google.com> Signed-off-by: Roman Kiryanov <rkir@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>