staging: mt7621-pci: be sure gpio descriptor is null on fails
Function 'devm_gpiod_get_index_optional' returns NULL if the
descriptor is invalid and the error associated for the error
pointer is ENOENT. Sometimes if the pin is just assigned the
error associated for the pointer might not be ENOENT but other.
In order to avoid weirds behaviours if this happen set descriptor
to NULL in the driver port structure.
staging: mt7621-pci: use only two phys from device tree
In order to align work with the mt7621-pci-phy part of
the driver and device tree which is now using only two
real phys one of them dual ported properly parse the
device tree and don't call phy initialization for the
slot 1 because is being taking into account when the
phy for the slot 0 is instantiated.
This soc has only two real pcie phys one of them
having a different register to enable and disable it.
Change this to have only two dt nodes for the phys and
use 'phy-cells' properly to say if the phy has dual ports.
staging: mt7621-pci-phy: avoid to create to different phys for a dual port one
This soc has two phy's for the pcie one of them using just a different
register for settig it up but sharing all the rest of the config. Until
now we was presenting this schema as three different phy's in the device
tree using the 'phy-cells' node property to discriminate an index and
setting up a complete phy for the dual port index. This sometimes worked
properly but reconfiguring the same registers twice presents sometimes
some unstable pcie links and the ports was not properly being detected.
The problems only appears on hard resets and soft resets was properly
working. Instead of having this schema just set two phy's in the device
ree and use the 'phy-cells' property to say if the port has or not a dual
port. Doing this configuration and set up becomes easier, LOC is decreased
and the behaviour also gets deterministic with properly and stable pcie
links in both hard and soft resets.
staging: mt7621-pci: don't return if get gpio fails
In some platforms gpio's are not used for reset but
for other purposes. Because of that when we try to
get them are valid gpio's but are already assigned
to do other function. To avoid those kind of problems
in those platforms just notice the fail in the kernel
but continue doing normal boot.
Takashi Iwai [Thu, 19 Mar 2020 16:13:00 +0000 (17:13 +0100)]
staging: vc04_services: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit. Fix it by replacing with scnprintf().
staging: mt7621-pci: fix register to set up virtual bridges
Instead of being using PCI Configuration and Status Register to
set up virtual bridges we are using CONFIG_ADDR Register which is
wrong. Hence, set the correct value.
Merge tag 'iio-5.7a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First set of new IIO device support, fatures and cleanups for the 5.7 cycle
Includes changes for the counter subsystem
Core Feature
* Explicitly handle sysfs values in dB, including correctly handling the
needed postfix dB.
* Add a TODO to suggest suitable activities for new contributors to IIO now
the vast majority of drivers are out of staging (and the remaining ones
there are 'hard'). Also update the TODO in staging to remove stale entries.
Staging graduations
* ad7192 ADC.
New device support
* ad5770r
- New driver for this 6 channel DAC including DT bindings.
* ad8366
- Add supprot for the hmc1119 attenuator.
* al3010
- New driver supporting this Dyna-image light sensors.
- Power management and DT bindings added in additional patches.
* atlas-sensor
- Add support for atlas DO-SM device. Reads disolved oxygen in a solution.
* gpap002x00f
- New driver and bindings to support the GP2AP002A00F and GP2AP002S00F light
and proximity sensors. There is some limited existing support in
input. The intent is to drop this driver once IIO driver is in place.
* hmc425a
- New driver for this attenuator.
* icp10100
- New driver for this presure sensor.
* ltc2632
- Add support for the ltc2636 8 channel DAC. Includes bindings and some
tidying up of the driver.
* inv_mpu6050
- Support IAM20680, ICM20609, ICM20689 and ICM20690.
Includes related tidy up and rework of low pass filter bandwidth
handling to give suitable values for all chips.
Binding conversions to yaml or missing bindings docs.
* atlas-sensor, including consolidation of previous 3 separate docs into 1.
* ad7923, previously no doc.
* max1363, split into max1238 and max1363 to simplify yaml.
* stm32-adc
Features
* (counter) 104-quad-8
- Support a filter clock prescaler.
- Support reporting of encoder cable status.
* ad7124
- Low pass filter support.
- Debugfs interface to access registers directly.
* ad8366
- Support control of hardware gain.
* inv_mpu6050
- Runtime pm with autosuspend.
* npcm adc
- Add reset support. This is a breaking change if DT is not in sync,
however this device is a BMC so the ecosystem is closed enought that
this should not be a problem.
* srf04
- Add power management with DT bindings for the GPIO.
* stm32-timer-trigger
- Power management.
* (counter) stm32-timer-cnt
- Power management.
* vcnl4000
- Enable runtime PM for devices that don't use on demand measurement.
Cleanups and minor fixes
* core
- Avoid double read when using debugfs. Whilst we provide no guarantees
on lack of side effects using the debugfs interfaces, this one is
generate unexpected results so let us tidy it up.
* dac/Kconfig
- Alphabetic order.
* ad5755
- Grammar and minor other fixes.
* ad7124
- Fail probe if get_voltage fails as no meaningful readings can be had
without knowing the external reference.
- Switch to selection between different channel attributes rather than
building the arrays at runtime.
- Remove the spi_device_id table as the driver cannot be probled without
more information that can be provided without dt.
- Update sysfs docs to provide more inormation and bring remaining docs for
this part out of staging.
* ad9292
- Use new SPI transfer delay structure.
* adis library
- Add unlocked version of adis_initial_startup and refactor the function.
- Add a product ID santiy check.
- Add support for different self test registers.
- Use new SPI delay structure.
- Add new docs and tidy up existing.
* adis16136
- Initialize adis_data statically.
* adis16400
- Initialize adis_data statically.
* adis16460
- Use core __adis_initial_Startup now it supports everything needed.
* adis16480
- Initialize adis_data statically.
- Use core __adis_initial_startup now it supports everything needed.
* al3320a
- Add missing DT binding docs.
- Tidy up code formatting.
- Simplify error paths using devm_add_action_or_reset.
- Ensure autoloading works by adding the of_match_table.
* atlas-sensor
- Drop false requirement for interrupt line, the value can be polled using
a sysfs or hrtimer type trigger.
* exynos-adc
- Silence warning message on deferring probe.
* gp2ap002
- Greatly simplify the Lux LUT.
- Reorder actions around buffer setup and tear down as part of a sub-system
wide standardization of these.
* inv_mpu6050
- Various lttle tidyups.
- Simpliy I2C aux MUX handling by enabling it only at startup. It never
needs to be disabled.
- Simplify polling rate when magnetometer enabled by putting only under
control of userspace.
- Always execute full reset on devices supporting spi. It does no harm
when using i2c and makes for simpler code.
- Reduce over the top sleep times for vddio regulator power up.
- Greatly simplify power and engine management.
- Fix some delays in polled reads (only visible due to other changes)
- Stop preventing sampling rate changes whilst running as there is no
adverse consequence of doing so.
- Prevent attempting to read the temperature if neither accel nor
gyro is enabled.
* lmp9100
- Reorder actions around buffer setup and tear down as part of a sub-system
wide standardization of these.
* max1118
- Use new SPI transfer delay structure.
* mcp320x
- Use new SPI transfer delay structure.
* si1133
- Read full 24 bit signed integer instead o dropping last 8 bits of value.
Not a critical fix as just adds precision.
* st_sensors
- Use st_sensors_dev_name_probe instead of open coded version in st_accel
- Handle potential memory allocation failure.
* st_lsm6dsx
- Fix some wrong structure element naming in documentation.
- Add missing return value check.
* stm32_timer_cnt
- Drop some unused left over IIO headers from this count subsystem driver.
- Ensure the clock is enabled in master mode. Theoretical issue rather
than one known to happen in the wild.
* tlc4541
- Use new SPI delay structure.
* tag 'iio-5.7a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (98 commits)
iio: dac: Kconfig: sort symbols alphabetically
iio: light: gp2ap020a00f: fix iio_triggered_buffer_{predisable,postenable} positions
iio: potentiostat: lmp9100: fix iio_triggered_buffer_{predisable,postenable} positions
iio: trigger: stm32-timer: add power management support
iio: trigger: stm32-timer: rename enabled flag
iio: add a TODO
counter: 104-quad-8: Support Differential Encoder Cable Status
counter: 104-quad-8: Support Filter Clock Prescaler
iio: pressure: icp10100: add driver for InvenSense ICP-101xx
iio: industrialio-core: Fix debugfs read
iio: imu: adis: add a note better explaining state_lock
iio: imu: adis: update 'adis_data' struct doc-string
iio: imu: adis: add doc-string for 'adis' struct
iio: imu: adis_buffer: Use new structure for SPI transfer delays
iio: adc: ti-tlc4541: Use new structure for SPI transfer delays
iio: adc: mcp320x: Use new structure for SPI transfer delays
iio: adc: max1118: Use new structure for SPI transfer delays
iio: adc: ad9292: Use new structure for SPI transfer delays
iio: adc: exynos: Silence warning about regulators during deferred probe
staging: iio: update TODO
...
staging: mt7621-pci: fix io space and properly set resource limits
Function 'mt7621_pci_parse_request_of_pci_ranges' is using
'of_pci_range_to_resource' to get both mem and io resources.
Internally this function calls to 'pci_address_to_pio' which
returns -1 if io space address is an address > IO_SPACE_LIMIT
which is 0xFFFF for mips. This mt7621 soc has io space in physical
address 0x1e160000. In order to fix this, overwrite invalid io
0xffffffff with properly values from the device tree and set
mapped address of this resource as io port base memory address
calling 'set_io_port_base' function. There is also need to properly
setup resource limits and io and memory windows with properly
parsed values instead of set them as 'no limit' which it is wrong.
For any reason I don't really know legacy driver sets up mem window
as 0xFFFFFFFF and any other value seems to does not work as expected,
so set up also here with same values.
Kaaira Gupta [Fri, 13 Mar 2020 21:54:03 +0000 (03:24 +0530)]
staging: media: allegro: align with parenthesis
Align the lines of allegro-core.c with open parenthesis by giving proper
tabs and thereby fix checkpatch.pl warnings of matching alignment with
open parenthesis. Do it only for lines where character limit doesn't
exceed 80 characters.
staging: mt7621-pci: release gpios after pci initialization
R3G's LEDs fail to initialize because one of them uses GPIO8
Hence, release the GPIO resources after PCIe initialization
and properly release also in driver error path.
staging: mt7621-dts: make use of 'reset-gpios' property for pci
Properly set pins for group pcie as 'gpio' function and declare
gpio's in the pci node to make reset stuff properly functional.
Delete no more needed general reset and previous pers gpio which
is now being used in 'reset-gpios' property.
Original driver code was using three gpio's for reset
asserts and deasserts the pcis. Instead of using that
a general reset control with a perst gpio was introduced
and it seems it is partially working but sometimes there
are some unexpected hangs on boot. This commit make use of
the three original gpios using 'reset-gpios' property of
the device tree and removes the reset line and perst gpio.
According to the mediatek aplication note v0.1 there are
three gpios used for pcie ports reset control: gpio#19,
gpio#8 and gpio#7 for slots 0, 1 and 2 respectively.
This schema can be used separately for mt7621A but in some
boards due to pin share issue, if the PCM and I2S function
are enable at the same time, there are no enough GPIO to
control per-port PCIe reset. In those cases gpio#19 is enought
for reset the three ports together. Because of this we just
try to get the three gpios but if some of them fail we are not
failing in boot process, just prints a kernel notice and take
after into account if the descriptor is or not valid in order
to use it. All of them are set as GPIO output low configuration.
The gpio descriptor's API takes device tree property into account
and invert value if the pin is configured as active low.
So we also have to properly request pins from device tree
and set values correct in assert and deassert functions.
After this changes the order to make all assert and
deassert in the 'probe' process makes more sense:
* Parse device tree.
* make assert of the RC's and EP's before doing anything else.
* make deassert of the RC's before initializing the phy.
* Init the phy.
* make deassert of the EP's before initialize pci ports.
* Normal PCI initialization.
Solves the following checkpatch.pl for a triggered function:
WARNING: Prefer using '"%s...", __func__' to using 'setKey',
this function's name, in a string
Deepak R Varma [Sun, 15 Mar 2020 23:42:08 +0000 (05:12 +0530)]
staging: fbtft: simplify array index computation
An array index is being computed by mathematical calculation on the
Lvalue side of the expression. This also further results in the statement
exceeding 80 character statement length.
A local variable can store the value of the array index computation. The
variable can then be used as array index. This improves readability of
the code and also address 80 character warning raised by checkpatch.
Deepak R Varma [Sun, 15 Mar 2020 23:41:34 +0000 (05:11 +0530)]
staging: fbtft: Reformat long macro definitions
Multiple macro definitions crossing 80 character line length makes them
hard to understand. Reformatting the these lines makes the code more
readable and easier to understand. Issue flagged by checkpatch script.
Deepak R Varma [Sun, 15 Mar 2020 23:41:06 +0000 (05:11 +0530)]
staging: fbtft: Reformat line over 80 characters
A long variable name beyond 80 characters extends into the next
line. Reformatting the line makes it more readable. Also adding an extra
line for the next instruction following current if block helps
understand it better.
Remove unnecessary if and else conditions since both are leading to the
initialization of "phtpriv->ampdu_enable" with the same value.
Also, remove the unnecessary else-if condition since it does nothing.
Deepak R Varma [Sat, 14 Mar 2020 21:07:53 +0000 (02:37 +0530)]
staging: comedi: ni_mio_common: Code reformat and re-indentation
Resolve general code indentation problems as detected by checkpatch script.
Implement code reformat and re-indentation as per coding style to
improve readability.
Oscar Carter [Sat, 14 Mar 2020 16:14:41 +0000 (17:14 +0100)]
staging: vt6656: Use BIT_ULL() macro instead of bit shift operation
Replace the bit left shift operation with the BIT_ULL() macro and remove
the unnecessary mask off operation against the bit_nr variable.
This mask is only there for legacy reasons. Originally it was 31 (0x1f)
and the bit_nr variable spread across an mc_filter array with two u32
elements. Now, this mask is not needed because its value is 0x3f and the
mc_filter variable is an u64 type.
In this situation, the 26 bit right shift operation against the value
returned by the ether_crc function set the bit_nr variable to the
following value:
bit 31 to bit 6 -> All 0 (due to the bit shift operation happens over an
unsigned type).
bit 5 to bit 0 -> The 6 msb bits of the value returned by the ether_crc
function.
The purpose of the 0x3f mask against the bit_nr variable is to reset
(set to 0) the 26 msb bits (bit 31 to bit 6), but these bits are yet 0.
So, the mask off operation is now unnecessary.
Takashi Iwai [Wed, 11 Mar 2020 09:24:51 +0000 (10:24 +0100)]
staging: rtl8723bs: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit. Fix it by replacing with scnprintf().
Takashi Iwai [Wed, 11 Mar 2020 09:24:50 +0000 (10:24 +0100)]
staging: rtl8192e: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit. Fix it by replacing with scnprintf().
Takashi Iwai [Wed, 11 Mar 2020 09:24:49 +0000 (10:24 +0100)]
staging: rtl8188eu: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit. Fix it by replacing with scnprintf().
Takashi Iwai [Wed, 11 Mar 2020 09:19:44 +0000 (10:19 +0100)]
staging: most: core: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit. Fix it by replacing with scnprintf().
Merged the DT binding documentation of SDIO and SPI into a single file.
Removed documentation for some of the properties which are not required
and handled review comments received in [1] & [2].
staging: mt7621-pci: enable clock bit for each port
The clock related code concerns me from the very beginning because
there are some set ups got from legacy driver that are not documented
anywhere. According to the programming guide 0x7c is 'CPE_ROSC_SEL1'
register and 0x80 is 'CPU_CPE_CN'. I do think this set up is not needed
at all and the proper thing to do is just enable the clock bit for each
pcie port. Hence remove useless code and do the right thing which is
setting up the clock bit for each port enabled.
Kaaira Gupta [Tue, 10 Mar 2020 14:25:09 +0000 (19:55 +0530)]
staging: wfx: remove unused structure
struct hif_cnf_reset is not used anywhere in wfx. It's parent file
hif_api_cmd.h is imported form some other driver, hence some functions
in it are not used. This is one of them. Hence remove it.
staging: mt7621-pci: simplify 'mt7621_pcie_init_virtual_bridges' function
Function 'mt7621_pcie_init_virtual_bridges' is a bit mess and can be
refactorized properly in a cleaner way. Introduce new 'pcie_rmw' inline
function helper to do clear and set the correct bits this function needs
to work.
staging: wilc1000: spi: Use new structure for SPI transfer delays
In a recent change to the SPI subsystem in commit <2b6d42495042>
("spi: introduce `delay` field for `spi_transfer` +
spi_transfer_delay_exec()"), a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current
`delay_usecs` with `delay` for this driver.
The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).
staging: kpc2000: kpc2000_spi: Use new structure for SPI transfer delays
In a recent change to the SPI subsystem in commit <2b6d42495042>
("spi: introduce `delay` field for `spi_transfer` +
spi_transfer_delay_exec()"), a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current
`delay_usecs` with `delay` for this driver.
The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).