platform/kernel/linux-rpi.git
2 years agoMerge tag 'phy-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux...
Greg Kroah-Hartman [Wed, 27 Oct 2021 15:01:16 +0000 (17:01 +0200)]
Merge tag 'phy-for-5.16' of git://git./linux/kernel/git/phy/linux-phy into char-misc-next

Vinod writes:

phy-for-5.16

  - New support:
- Kirin 970 PCIe PHY driver
- Qualcomm QCM2290 USB2 and USB3 support

  - Updates:
        - Qualcomm synopsis phy driver updates
- sc8180x PCIe update
- cadence-torrent driver updates for output reference clock
- stm32 phy tuning support

* tag 'phy-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: (28 commits)
  phy: Sparx5 Eth SerDes: Fix return value check in sparx5_serdes_probe()
  phy: qcom-snps: Correct the FSEL_MASK
  phy: hisilicon: Add of_node_put() in phy-hisi-inno-usb2
  phy: qcom-qmp: another fix for the sc8180x PCIe definition
  phy: cadence-torrent: Add support to output received reference clock
  phy: cadence-torrent: Model reference clock driver as a clock to enable derived refclk
  dt-bindings: phy: cadence-torrent: Add clock IDs for derived and received refclk
  phy: cadence-torrent: Migrate to clk_hw based registration and OF APIs
  phy: ti: gmii-sel: check of_get_address() for failure
  dt-bindings: phy: qcom,qmp: IPQ6018 and IPQ8074 PCIe PHY require no supply
  phy: stm32: add phy tuning support
  dt-bindings: phy: phy-stm32-usbphyc: add optional phy tuning properties
  phy: stm32: restore utmi switch on resume
  dt-bindings: phy: rockchip: remove usb-phy fallback string for rk3066a/rk3188
  phy: qcom-qusb2: Fix a memory leak on probe
  phy: qcom-qmp: Add QCM2290 USB3 PHY support
  dt-bindings: phy: qcom,qmp: Add QCM2290 USB3 PHY
  phy: qcom-qusb2: Add missing vdd supply
  dt-bindings: phy: qcom,qusb2: Add missing vdd-supply
  phy: rockchip-inno-usb2: Make use of the helper function devm_add_action_or_reset()
  ...

2 years agoMerge tag 'extcon-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git...
Greg Kroah-Hartman [Wed, 27 Oct 2021 14:49:55 +0000 (16:49 +0200)]
Merge tag 'extcon-next-for-5.16' of git://git./linux/kernel/git/chanwoo/extcon into char-misc-next

Chanwoo writes:

Update extcon next for v5.16

Detailed description for this pull request:
1. Add support for TUSB320L and update tusb320 extcon driver
- The existing extcon-usbc-tusb320 driver is updated
for supporting the mode setting and reset operation.
Also, this driver supports the simliar TUSB320L device
at the same extcon-usbc-tusb320 extcon provider driver.

2. Use p-unit semaphone lock for register access for extcon-axp288
driver

3. Update the minor clean-up for extcon-max3355 and extcon-usb-gpio
driver.

* tag 'extcon-next-for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon:
  dt-bindings: extcon: usbc-tusb320: Add TUSB320L compatible string
  extcon: usbc-tusb320: Add support for TUSB320L
  extcon: usbc-tusb320: Add support for mode setting and reset
  extcon: extcon-axp288: Use P-Unit semaphore lock for register accesses
  extcon: max3355: Drop unused include
  extcon: usb-gpio: Use the right includes

2 years agofix for "dma-buf: move dma-buf symbols into the DMA_BUF module namespace"
Stephen Rothwell [Wed, 27 Oct 2021 04:48:43 +0000 (15:48 +1100)]
fix for "dma-buf: move dma-buf symbols into the DMA_BUF module namespace"

Adds the proper MODULE_IMPORT_NS(DMA_BUF) line to the file to get it to
build properly.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Link: https://lore.kernel.org/r/20211027154843.622961fd@canb.auug.org.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agodt-bindings: extcon: usbc-tusb320: Add TUSB320L compatible string
Yassine Oudjana [Sat, 25 Sep 2021 05:46:09 +0000 (05:46 +0000)]
dt-bindings: extcon: usbc-tusb320: Add TUSB320L compatible string

Add a compatible string for TUSB320L.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoextcon: usbc-tusb320: Add support for TUSB320L
Yassine Oudjana [Sat, 25 Sep 2021 05:45:54 +0000 (05:45 +0000)]
extcon: usbc-tusb320: Add support for TUSB320L

TUSB320L is a newer chip with additional features, and it has additional steps
in its mode changing sequence:
 - Disable CC state machine,
 - Write to mode register,
 - Wait for 5 ms,
 - Re-enable CC state machine.
It also has an additional register that a revision number can be read from.

Add support for the mode changing sequence, and read the revision number during
probe and print it as info.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoextcon: usbc-tusb320: Add support for mode setting and reset
Yassine Oudjana [Sat, 25 Sep 2021 05:45:39 +0000 (05:45 +0000)]
extcon: usbc-tusb320: Add support for mode setting and reset

Reset the chip and set its mode to default (maintain mode set by PORT pin)
during probe to make sure it comes up in the default state.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoextcon: extcon-axp288: Use P-Unit semaphore lock for register accesses
Fabio Aiuto [Thu, 16 Sep 2021 07:12:55 +0000 (09:12 +0200)]
extcon: extcon-axp288: Use P-Unit semaphore lock for register accesses

use low level P-Unit semaphore lock for axp288 register
accesses directly and for more than one access a time,
to reduce the number of times this semaphore is locked
and released which is an expensive operation.

i2c-bus to the XPower is shared between the kernel and the
SoCs P-Unit. The P-Unit has a semaphore wich the kernel must
lock for axp288 register accesses. When the P-Unit semaphore
is locked CPU and GPU power states cannot change or the system
will freeze.

The P-Unit semaphore lock is already managed inside the regmap
access logic, but for each access the semaphore is locked and
released. So use directly iosf_mbi_(un)block_punit_i2c_access(),
we are safe in doing so because nested calls to the same
semaphore are turned to nops.

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoextcon: max3355: Drop unused include
Linus Walleij [Thu, 15 Jul 2021 15:26:57 +0000 (17:26 +0200)]
extcon: max3355: Drop unused include

This driver includes the legacy <linux/gpio.h> header but
does not use it. Drop this include.

Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agoextcon: usb-gpio: Use the right includes
Linus Walleij [Thu, 15 Jul 2021 19:06:06 +0000 (21:06 +0200)]
extcon: usb-gpio: Use the right includes

The USB GPIO extcon driver does not use any of the legacy
includes <linux/gpio.h> or <linux/of_gpio.h> but
exploits the fact that this brings in <linux/mod_device_table.h>.
Fix this up by using the right includes.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2 years agomost: fix control-message timeouts
Johan Hovold [Mon, 25 Oct 2021 11:58:11 +0000 (13:58 +0200)]
most: fix control-message timeouts

USB control-message timeouts are specified in milliseconds and should
specifically not vary with CONFIG_HZ.

Use the common control-message timeout defines for the five-second
timeouts.

Fixes: 97a6f772f36b ("drivers: most: add USB adapter driver")
Cc: stable@vger.kernel.org # 5.9
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20211025115811.5410-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocomedi: vmk80xx: fix bulk and interrupt message timeouts
Johan Hovold [Mon, 25 Oct 2021 11:45:32 +0000 (13:45 +0200)]
comedi: vmk80xx: fix bulk and interrupt message timeouts

USB bulk and interrupt message timeouts are specified in milliseconds
and should specifically not vary with CONFIG_HZ.

Note that the bulk-out transfer timeout was set to the endpoint
bInterval value, which should be ignored for bulk endpoints and is
typically set to zero. This meant that a failing bulk-out transfer
would never time out.

Assume that the 10 second timeout used for all other transfers is more
than enough also for the bulk-out endpoint.

Fixes: 985cafccbf9b ("Staging: Comedi: vmk80xx: Add k8061 support")
Fixes: 951348b37738 ("staging: comedi: vmk80xx: wait for URBs to complete")
Cc: stable@vger.kernel.org # 2.6.31
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20211025114532.4599-6-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocomedi: vmk80xx: fix bulk-buffer overflow
Johan Hovold [Mon, 25 Oct 2021 11:45:31 +0000 (13:45 +0200)]
comedi: vmk80xx: fix bulk-buffer overflow

The driver is using endpoint-sized buffers but must not assume that the
tx and rx buffers are of equal size or a malicious device could overflow
the slab-allocated receive buffer when doing bulk transfers.

Fixes: 985cafccbf9b ("Staging: Comedi: vmk80xx: Add k8061 support")
Cc: stable@vger.kernel.org # 2.6.31
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20211025114532.4599-5-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocomedi: vmk80xx: fix transfer-buffer overflows
Johan Hovold [Mon, 25 Oct 2021 11:45:30 +0000 (13:45 +0200)]
comedi: vmk80xx: fix transfer-buffer overflows

The driver uses endpoint-sized USB transfer buffers but up until
recently had no sanity checks on the sizes.

Commit e1f13c879a7c ("staging: comedi: check validity of wMaxPacketSize
of usb endpoints found") inadvertently fixed NULL-pointer dereferences
when accessing the transfer buffers in case a malicious device has a
zero wMaxPacketSize.

Make sure to allocate buffers large enough to handle also the other
accesses that are done without a size check (e.g. byte 18 in
vmk80xx_cnt_insn_read() for the VMK8061_MODEL) to avoid writing beyond
the buffers, for example, when doing descriptor fuzzing.

The original driver was for a low-speed device with 8-byte buffers.
Support was later added for a device that uses bulk transfers and is
presumably a full-speed device with a maximum 64-byte wMaxPacketSize.

Fixes: 985cafccbf9b ("Staging: Comedi: vmk80xx: Add k8061 support")
Cc: stable@vger.kernel.org # 2.6.31
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20211025114532.4599-4-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agophy: Sparx5 Eth SerDes: Fix return value check in sparx5_serdes_probe()
Yang Yingliang [Thu, 9 Sep 2021 07:21:49 +0000 (15:21 +0800)]
phy: Sparx5 Eth SerDes: Fix return value check in sparx5_serdes_probe()

In case of error, the function devm_ioremap() returns NULL
pointer not ERR_PTR(). The IS_ERR() test in the return value
check should be replaced with NULL test.

Fixes: 2ff8a1eeb5aa ("phy: Add Sparx5 ethernet serdes PHY driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210909072149.2934047-1-yangyingliang@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: qcom-snps: Correct the FSEL_MASK
Sandeep Maheswaram [Mon, 25 Oct 2021 04:19:35 +0000 (09:49 +0530)]
phy: qcom-snps: Correct the FSEL_MASK

The FSEL_MASK which selects the refclock is defined incorrectly.
It should be [4:6] not [5:7]. Due to this incorrect definition, the BIT(7)
in USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 is reset which keeps PHY analog
blocks ON during suspend.
Fix this issue by correctly defining the FSEL_MASK.

Fixes: 51e8114f80d0 ("phy: qcom-snps: Add SNPS USB PHY driver for QCOM based SOCs")
Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
Link: https://lore.kernel.org/r/1635135575-5668-1-git-send-email-quic_c_sanm@quicinc.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: hisilicon: Add of_node_put() in phy-hisi-inno-usb2
Wan Jiabing [Fri, 15 Oct 2021 08:01:51 +0000 (04:01 -0400)]
phy: hisilicon: Add of_node_put() in phy-hisi-inno-usb2

Fix following coccicheck warning:
./drivers/phy/hisilicon/phy-hisi-inno-usb2.c:138:1-23: WARNING: Function
for_each_child_of_node should have of_node_put() before break

Early exits from for_each_child_of_node should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Link: https://lore.kernel.org/r/20211015080154.16016-1-wanjiabing@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: qcom-qmp: another fix for the sc8180x PCIe definition
Dmitry Baryshkov [Wed, 20 Oct 2021 15:56:04 +0000 (18:56 +0300)]
phy: qcom-qmp: another fix for the sc8180x PCIe definition

Commit f839f14e24f2 ("phy: qcom-qmp: Add sc8180x PCIe support") added
SC8180X PCIe tables, but used sm8250_qmp_pcie_serdes_tbl as a serdes
table because of the copy paste error. Commit bfccd9a71a08 ("phy:
qcom-qmp: Fix sc8180x PCIe definition") corrected part of this mistake
by pointing serdes_tbl to sc8180x_qmp_pcie_serdes_tbl, however the
serdes_tbl_num field was not updated to use sc8180x table. So let's now
fix the serdes_tbl_num field too.

Fixes: bfccd9a71a08 ("phy: qcom-qmp: Fix sc8180x PCIe definition")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20211020155604.1374530-1-dmitry.baryshkov@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: cadence-torrent: Add support to output received reference clock
Swapnil Jakhade [Wed, 22 Sep 2021 12:37:35 +0000 (14:37 +0200)]
phy: cadence-torrent: Add support to output received reference clock

Add support to output received reference clock. Model the received
reference clock as an alternate parent of reference clock driver
clock. When received refclk is selected to output on cmn_refclk_p/m,
this is the internal reference clock driven on the pma_cmn_refclk_int.

Signed-off-by: Swapnil Jakhade <sjakhade@cadence.com>
Link: https://lore.kernel.org/r/20210922123735.21927-5-sjakhade@cadence.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: cadence-torrent: Model reference clock driver as a clock to enable derived refclk
Swapnil Jakhade [Wed, 22 Sep 2021 12:37:34 +0000 (14:37 +0200)]
phy: cadence-torrent: Model reference clock driver as a clock to enable derived refclk

When reference clock driver is enabled, either derived or received refclk
is output on cmn_refclk_p/m. Update the reference clock driver
implementation by modelling reference clock driver as a "clock" with
derived reference clock set as its default parent. The support for
received reference clock will be added in a separate patch.

Signed-off-by: Swapnil Jakhade <sjakhade@cadence.com>
Link: https://lore.kernel.org/r/20210922123735.21927-4-sjakhade@cadence.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agodt-bindings: phy: cadence-torrent: Add clock IDs for derived and received refclk
Swapnil Jakhade [Wed, 22 Sep 2021 12:37:33 +0000 (14:37 +0200)]
dt-bindings: phy: cadence-torrent: Add clock IDs for derived and received refclk

Add clock IDs for derived and received reference clock output.

Signed-off-by: Swapnil Jakhade <sjakhade@cadence.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210922123735.21927-3-sjakhade@cadence.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: cadence-torrent: Migrate to clk_hw based registration and OF APIs
Swapnil Jakhade [Wed, 22 Sep 2021 12:37:32 +0000 (14:37 +0200)]
phy: cadence-torrent: Migrate to clk_hw based registration and OF APIs

Use clk_hw based provider APIs to register clks to remove the usage of
deprecated APIs.

Signed-off-by: Swapnil Jakhade <sjakhade@cadence.com>
Link: https://lore.kernel.org/r/20210922123735.21927-2-sjakhade@cadence.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: ti: gmii-sel: check of_get_address() for failure
Dan Carpenter [Tue, 14 Sep 2021 11:00:38 +0000 (14:00 +0300)]
phy: ti: gmii-sel: check of_get_address() for failure

Smatch complains that if of_get_address() returns NULL, then "size"
isn't initialized.  Also it would lead to an Oops.

Fixes: 7f78322cdd67 ("phy: ti: gmii-sel: retrieve ports number and base offset from dt")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Link: https://lore.kernel.org/r/20210914110038.GB11657@kili
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agodt-bindings: phy: qcom,qmp: IPQ6018 and IPQ8074 PCIe PHY require no supply
Shawn Guo [Wed, 20 Oct 2021 13:06:34 +0000 (21:06 +0800)]
dt-bindings: phy: qcom,qmp: IPQ6018 and IPQ8074 PCIe PHY require no supply

The qmp-phy driver suggests that 'vdda-phy-supply' and 'vdda-pll-supply'
are not required for IPQ6018 and IPQ8074 QMP PCIe PHY.  Update the
bindings to reflect it.

While at it, also correct the clock properties for IPQ8074 QMP PCIe PHY.
And as the result, 'qcom,ipq8074-qmp-pcie-phy' and
'qcom,ipq6018-qmp-pcie-phy' share the same clock, reset and supply
bindings.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20211020130634.26194-1-shawn.guo@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: stm32: add phy tuning support
Amelie Delaunay [Fri, 15 Oct 2021 16:14:27 +0000 (18:14 +0200)]
phy: stm32: add phy tuning support

It can be necessary to adjust the phys settings to compensate parasitics.
This patch adds support of new optional properties to configure the tune
interface of the phys of stm32-usbphyc.
Properties are optional, that's why each property is skipped if not
found (-EINVAL).
Phy tuning is restored on resume because if deep low power state is
achieved, phy tuning configuration is reset.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20211015161427.220784-4-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agodt-bindings: phy: phy-stm32-usbphyc: add optional phy tuning properties
Amelie Delaunay [Fri, 15 Oct 2021 16:14:26 +0000 (18:14 +0200)]
dt-bindings: phy: phy-stm32-usbphyc: add optional phy tuning properties

This patch adds the description of new optional phy tuning properties
for usbphyc phy sub nodes.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20211015161427.220784-3-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: stm32: restore utmi switch on resume
Amelie Delaunay [Fri, 15 Oct 2021 16:14:25 +0000 (18:14 +0200)]
phy: stm32: restore utmi switch on resume

UTMI switch value can be lost during suspend/resume, depending on the power
state reached.
This patch adds resume function to usbphyc, to reconfigure utmi switch
after suspend.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20211015161427.220784-2-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agodt-bindings: phy: rockchip: remove usb-phy fallback string for rk3066a/rk3188
Johan Jonker [Sat, 28 Aug 2021 11:12:17 +0000 (13:12 +0200)]
dt-bindings: phy: rockchip: remove usb-phy fallback string for rk3066a/rk3188

With the conversion of rockchip-usb-phy.yaml a long time used fallback
string for rk3066a/rk3188 was added. The linux driver doesn't do much with
the GRF phy address range, however the u-boot driver rockchip_usb2_phy.c
does. The bits in GRF_UOC0_CON2 for rk3066a/rk3188 and rk3288 for example
don't match. Remove the usb-phy fallback string for rk3066a/rk3188
to prevent possible strange side effects.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210828111218.10026-1-jbx6244@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: qcom-qusb2: Fix a memory leak on probe
Vladimir Zapolskiy [Wed, 22 Sep 2021 23:35:48 +0000 (02:35 +0300)]
phy: qcom-qusb2: Fix a memory leak on probe

On success nvmem_cell_read() returns a pointer to a dynamically allocated
buffer, and therefore it shall be freed after usage.

The issue is reported by kmemleak:

  # cat /sys/kernel/debug/kmemleak
  unreferenced object 0xffff3b3803e4b280 (size 128):
    comm "kworker/u16:1", pid 107, jiffies 4294892861 (age 94.120s)
    hex dump (first 32 bytes):
      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    backtrace:
      [<000000007739afdc>] __kmalloc+0x27c/0x41c
      [<0000000071c0fbf8>] nvmem_cell_read+0x40/0xe0
      [<00000000e803ef1f>] qusb2_phy_init+0x258/0x5bc
      [<00000000fc81fcfa>] phy_init+0x70/0x110
      [<00000000e3d48a57>] dwc3_core_soft_reset+0x4c/0x234
      [<0000000027d1dbd4>] dwc3_core_init+0x68/0x990
      [<000000001965faf9>] dwc3_probe+0x4f4/0x730
      [<000000002f7617ca>] platform_probe+0x74/0xf0
      [<00000000a2576cac>] really_probe+0xc4/0x470
      [<00000000bc77f2c5>] __driver_probe_device+0x11c/0x190
      [<00000000130db71f>] driver_probe_device+0x48/0x110
      [<0000000019f36c2b>] __device_attach_driver+0xa4/0x140
      [<00000000e5812ff7>]  bus_for_each_drv+0x84/0xe0
      [<00000000f4bac574>] __device_attach+0xe4/0x1c0
      [<00000000d3beb631>] device_initial_probe+0x20/0x30
      [<000000008019b9db>] bus_probe_device+0xa4/0xb0

Fixes: ca04d9d3e1b1 ("phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20210922233548.2150244-1-vladimir.zapolskiy@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agophy: qcom-qmp: Add QCM2290 USB3 PHY support
Shawn Guo [Mon, 27 Sep 2021 06:48:29 +0000 (14:48 +0800)]
phy: qcom-qmp: Add QCM2290 USB3 PHY support

Enable QCM2290 USB3 PHY support by adding the qmp_phy_cfg data which are
taken from downstream kernel.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Link: https://lore.kernel.org/r/20210927064829.5752-3-shawn.guo@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agodt-bindings: phy: qcom,qmp: Add QCM2290 USB3 PHY
Shawn Guo [Mon, 27 Sep 2021 06:48:28 +0000 (14:48 +0800)]
dt-bindings: phy: qcom,qmp: Add QCM2290 USB3 PHY

Add support for USB3 PHY found on Qualcomm QCM2290 SoC.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210927064829.5752-2-shawn.guo@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agodma-buf: move dma-buf symbols into the DMA_BUF module namespace
Greg Kroah-Hartman [Sun, 10 Oct 2021 12:46:28 +0000 (14:46 +0200)]
dma-buf: move dma-buf symbols into the DMA_BUF module namespace

In order to better track where in the kernel the dma-buf code is used,
put the symbols in the namespace DMA_BUF and modify all users of the
symbols to properly import the namespace to not break the build at the
same time.

Now the output of modinfo shows the use of these symbols, making it
easier to watch for users over time:

$ modinfo drivers/misc/fastrpc.ko | grep import
import_ns:      DMA_BUF

Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://lore.kernel.org/r/20211010124628.17691-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agolkdtm/bugs: Check that a per-task stack canary exists
Kees Cook [Fri, 22 Oct 2021 22:38:26 +0000 (15:38 -0700)]
lkdtm/bugs: Check that a per-task stack canary exists

Introduce REPORT_STACK_CANARY to check for differing stack canaries
between two processes (i.e. that an architecture is correctly implementing
per-task stack canaries), using the task_struct canary as the hint to
locate in the stack. Requires that one of the processes being tested
not be pid 1.

Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20211022223826.330653-3-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoselftests/lkdtm: Add way to repeat a test
Kees Cook [Fri, 22 Oct 2021 22:38:25 +0000 (15:38 -0700)]
selftests/lkdtm: Add way to repeat a test

Some LKDTM tests need to be run more than once (usually to setup and
then later trigger). Until now, the only case was the SOFT_LOCKUP test,
which wasn't useful to run in the bulk selftests. The coming stack canary
checking needs to run twice, so support this with a new test output prefix
"repeat".

Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20211022223826.330653-2-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoMerge tag 'soundwire-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul...
Greg Kroah-Hartman [Mon, 25 Oct 2021 06:52:44 +0000 (08:52 +0200)]
Merge tag 'soundwire-5.16-rc1' of git://git./linux/kernel/git/vkoul/soundwire into char-misc-next

Vinod writes:

soundwire updates for 5.16-rc1

 - Update on sysfs wildcard documentation
 - debugfs update for core and qcom driver
 - invalid slave pointer fix for bus

* tag 'soundwire-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire:
  soundwire: qcom: add debugfs entry for soundwire register dump
  soundwire: bus: stop dereferencing invalid slave pointer
  ABI: sysfs-bus-soundwire-slave: use wildcards on What definitions
  ABI: sysfs-bus-soundwire-master: use wildcards on What definitions
  soundwire: debugfs: use controller id and link_id for debugfs

2 years agoiio: frequency: adrf6780: Fix adrf6780_spi_{read,write}()
Nathan Chancellor [Fri, 22 Oct 2021 19:56:56 +0000 (12:56 -0700)]
iio: frequency: adrf6780: Fix adrf6780_spi_{read,write}()

Clang warns:

drivers/iio/frequency/adrf6780.c:117:1: error: all paths through this
function will call itself [-Werror,-Winfinite-recursion]
{
^
drivers/iio/frequency/adrf6780.c:138:1: error: all paths through this
function will call itself [-Werror,-Winfinite-recursion]
{
^
2 errors generated.

The underscore variants should be used here.

Link: https://github.com/ClangBuiltLinux/linux/issues/1490
Fixes: 63aaf6d06d87 ("iio: frequency: adrf6780: add support for ADRF6780")
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211022195656.1513147-1-nathan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoMerge tag 'iio-for-5.16b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23...
Greg Kroah-Hartman [Sun, 24 Oct 2021 11:09:37 +0000 (13:09 +0200)]
Merge tag 'iio-for-5.16b' of https://git./linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

2nd set of IIO new driver, cleanups and features for the 5.16 cycle

New device support
* adrf6780 microwave upconverter.
  - New driver for this interesting device including bindings.

Features
* lite-on ltr501
  - Add dt-bindings including vendor ID and of_device_id table.
  - Add regulator support.
* sensiron,scd4x
  - Add reporting of channel scale.

Cleanups including fixes for things in this cycle
* Tree wide: Another set of dev_err_probe() introductions to reduce
  noise in logs when deferred probing is needed and provide more debug
  info. Devices included this time:
  - amlogic,meson_saradc
  - capella,cm3605
  - fsl,imx7d
  - maxim,max1118
  - maxim,max1241
  - nxp,lpc18xx
  - qcom,pm8xxxx-xoadc
  - rockchip,saradc
  - sharp,gp2ap002
  - sterricson,ab8500
  - ti,ads7950
* core - iio:buffer
  - Fix a path where a ret value is not intialized.
* channel-mux
  - Add support to mux core subsystem for a settling delay and use
    it in the iio-channel-mux driver.
  - Fix a few dt binding warnings.
* nxp,lpc18xx
  - Convert to devm_ functions for all of probe and drop remove()
* st,lsm6dsx
  - Suppress a warning due to lack of handling of an enum *_MAX entry
    that is just there to get the size.
* st,stm32-adc
  - Add generic channel binding, deprecating the old approach.
  - Add nvmem support to get calibration data for the vrefint channel and
    use it to perform such calibration.
  - Add a binding for sample-time to the generic channel description as it
    can be per channel.
* ti,adc128s052
  - Use devm_ managed functions and drop remove()
* vti,sca3000
  - Use sign_extend32() rather than opencoding.
* xilinx,xadc
  - Drop irq field from state structure as now just used in probe.

* tag 'iio-for-5.16b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (36 commits)
  dt-bindings: iio: frequency: add adrf6780 doc
  iio: frequency: adrf6780: add support for ADRF6780
  iio: chemical: scd4x: Add a scale for the co2 concentration reading
  dt-bindings: iio: io-channel-mux: allow duplicate channel, labels
  dt-bindings: iio: io-channel-mux: add optional #io-channel-cells
  iio: adc: adc128s052: Simplify adc128_probe()
  iio: multiplexer: iio-mux: Support settle-time-us property
  dt-bindings: iio: io-channel-mux: Add property for settle time
  mux: add support for delay after muxing
  iio: adc: stm32-adc: use generic binding for sample-time
  iio: adc: stm32-adc: add vrefint calibration support
  iio: adc: stm32-adc: add support of internal channels
  iio: adc: stm32-adc: add support of generic channels binding
  iio: adc: stm32-adc: split channel init into several routines
  dt-bindings: iio: stm32-adc: add nvmem support for vrefint internal channel
  dt-bindings: iio: stm32-adc: add generic channel binding
  iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.
  iio: xilinx-xadc: Remove `irq` field from state struct
  iio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr()
  iio: light: gp2ap002: Make use of the helper function dev_err_probe()
  ...

2 years agoMerge tag 'iio-fixes-for-5.16a' of https://git.kernel.org/pub/scm/linux/kernel/git...
Greg Kroah-Hartman [Sun, 24 Oct 2021 11:08:36 +0000 (13:08 +0200)]
Merge tag 'iio-fixes-for-5.16a' of https://git./linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

First set of IIO fixes for the 5.16 cycle

As these are very late in the 5.15 cycle and non are particularly urgent,
they can wait for the merge window.

Key element in this set is Yang Yingliang has identified a number of
issues in error paths introduced recently when we added multiple
buffer support.

Other fixes:
* adi,ad5662
  - Fix handling of i2c_master_send() return value.
* adi,ad5766
  - Fix a wrong dt-property name that indicated wrong units and
    did not mach the bindings.
  - Associated 'fix' of the bindings example to have a possible scale.
* st,pressure-spi
  - Add some missing entries to the spi_device_id table to ensure
    auto-loading works.
* ti,tsc2046
  - Fix a backwards comparison leading to a false dev_warn

* tag 'iio-fixes-for-5.16a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: buffer: Fix memory leak in iio_buffers_alloc_sysfs_and_mask()
  iio: adc: tsc2046: fix scan interval warning
  iio: core: fix double free in iio_device_unregister_sysfs()
  iio: core: check return value when calling dev_set_name()
  iio: buffer: Fix memory leak in iio_buffer_register_legacy_sysfs_groups()
  iio: buffer: Fix double-free in iio_buffers_alloc_sysfs_and_mask()
  iio: buffer: Fix memory leak in __iio_buffer_alloc_sysfs_and_mask()
  iio: buffer: check return value of kstrdup_const()
  iio: dac: ad5446: Fix ad5622_write() return value
  Documentation:devicetree:bindings:iio:dac: Fix val
  drivers: iio: dac: ad5766: Fix dt property name
  iio: st_pressure_spi: Add missing entries SPI to device ID table

2 years agomisc: enclosure: replace snprintf in show functions with sysfs_emit
Ye Guojin [Fri, 22 Oct 2021 09:06:04 +0000 (09:06 +0000)]
misc: enclosure: replace snprintf in show functions with sysfs_emit

coccicheck complains about the use of snprintf() in sysfs show
functions:
WARNING  use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
Link: https://lore.kernel.org/r/20211022090604.1065367-1-ye.guojin@zte.com.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoMerge tag 'icc-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/djakov...
Greg Kroah-Hartman [Fri, 22 Oct 2021 09:25:05 +0000 (11:25 +0200)]
Merge tag 'icc-5.16-rc1' of git://git./linux/kernel/git/djakov/icc into char-misc-next

Georgi writes:

interconnect changes for 5.16

Here are the changes for the 5.16-rc1 merge window consisting of just
driver updates. The highlight is the refactoring of some existing drivers
into common code and expanding some macros that will make adding QoS
support much easier.

Driver changes:
- icc-rpm: move bus clocks handling into qnoc_probe
- sdm660: expand DEFINE_QNODE macros
- sdm660: drop default/unused values
- sdm660: merge common code into icc-rpm
- icc-rpm: add support for QoS reg offset
- msm8916: expand DEFINE_QNODE macros
- msm8916: add support for AP-owned nodes
- msm8939: expand DEFINE_QNODE macros
- msm8939: add support for AP-owned nodes
- qcs404: expand DEFINE_QNODE macros
- qcom: drop DEFINE_QNODE macro
- samsung: describe drivers in KConfig

Signed-off-by: Georgi Djakov <djakov@kernel.org>
* tag 'icc-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/djakov/icc:
  interconnect: samsung: describe drivers in KConfig
  interconnect: qcom: drop DEFINE_QNODE macro
  interconnect: qcs404: expand DEFINE_QNODE macros
  interconnect: msm8939: add support for AP-owned nodes
  interconnect: msm8939: expand DEFINE_QNODE macros
  interconnect: msm8916: add support for AP-owned nodes
  interconnect: msm8916: expand DEFINE_QNODE macros
  interconnect: icc-rpm: add support for QoS reg offset
  interconnect: sdm660: merge common code into icc-rpm
  interconnect: sdm660: drop default/unused values
  interconnect: sdm660: expand DEFINE_QNODE macros
  interconnect: icc-rpm: move bus clocks handling into qnoc_probe

2 years agoMerge tag 'fsi-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi...
Greg Kroah-Hartman [Fri, 22 Oct 2021 07:45:59 +0000 (09:45 +0200)]
Merge tag 'fsi-for-v5.16' of git://git./linux/kernel/git/joel/fsi into char-misc-next

Joel writes:

FSI changes for v5.16

 - SBEFIFO usersapce interfaces to perform FFDC (First Failure
   Data Capture) and detect timeouts

 - A fix to handle multiple messages in flight

* tag 'fsi-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi:
  fsi: sbefifo: Use interruptible mutex locking
  fsi: sbefifo: Add sysfs file indicating a timeout error
  docs: ABI: testing: Document the SBEFIFO timeout interface
  hwmon: (occ) Provide the SBEFIFO FFDC in binary sysfs
  docs: ABI: testing: Document the OCC hwmon FFDC binary interface
  fsi: occ: Store the SBEFIFO FFDC in the user response buffer
  fsi: occ: Use a large buffer for responses
  hwmon: (occ) Remove sequence numbering and checksum calculation
  fsi: occ: Force sequence numbering per OCC

2 years agofsi: sbefifo: Use interruptible mutex locking
Eddie James [Tue, 3 Aug 2021 21:30:16 +0000 (16:30 -0500)]
fsi: sbefifo: Use interruptible mutex locking

Some SBE operations have extremely large responses and can require
several minutes to process the response. During this time, the device
lock must be held. If another process attempts an operation, it will
wait for the mutex for longer than the kernel hung task watchdog
allows. Therefore, use the interruptible function to lock the mutex.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20210803213016.44739-1-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2 years agofsi: sbefifo: Add sysfs file indicating a timeout error
Eddie James [Tue, 19 Oct 2021 21:17:49 +0000 (16:17 -0500)]
fsi: sbefifo: Add sysfs file indicating a timeout error

The SBEFIFO timeout error requires special handling in userspace
to do recovery operations. Add a sysfs file to indicate a timeout
error, and notify pollers when a timeout occurs.

This will be used by the openpower-occ-control application.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20211019211749.38059-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2 years agodocs: ABI: testing: Document the SBEFIFO timeout interface
Eddie James [Tue, 19 Oct 2021 21:17:48 +0000 (16:17 -0500)]
docs: ABI: testing: Document the SBEFIFO timeout interface

Add documentation for the new sysfs entry that indicates whether or not
the SBE has timed out.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211019211749.38059-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2 years agohwmon: (occ) Provide the SBEFIFO FFDC in binary sysfs
Eddie James [Tue, 19 Oct 2021 20:53:07 +0000 (15:53 -0500)]
hwmon: (occ) Provide the SBEFIFO FFDC in binary sysfs

Save any FFDC provided by the OCC driver, and provide it to userspace
through a binary sysfs entry. Notify userspace pollers when there is an
error too.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20211019205307.36946-5-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2 years agodocs: ABI: testing: Document the OCC hwmon FFDC binary interface
Eddie James [Tue, 19 Oct 2021 20:53:06 +0000 (15:53 -0500)]
docs: ABI: testing: Document the OCC hwmon FFDC binary interface

Add documentation for the new binary sysfs that will dump the SBEFIFO
FFDC.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211019205307.36946-4-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2 years agofsi: occ: Store the SBEFIFO FFDC in the user response buffer
Eddie James [Tue, 19 Oct 2021 20:53:05 +0000 (15:53 -0500)]
fsi: occ: Store the SBEFIFO FFDC in the user response buffer

If the SBEFIFO response indicates an error, store the response in the
user buffer and return an error. Previously, the user had no way of
obtaining the SBEFIFO FFDC.

The user's buffer now contains data in the event of a failure. No change
in the event of a successful transfer.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211019205307.36946-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2 years agofsi: occ: Use a large buffer for responses
Eddie James [Tue, 19 Oct 2021 20:53:04 +0000 (15:53 -0500)]
fsi: occ: Use a large buffer for responses

Allocate a large buffer for each OCC to handle response data. This
removes memory allocation during an operation, and also allows for
the maximum amount of SBE FFDC.

Previously for the putsram and attn commands, only 32 words would have
been available, and for getsram, only up to the size of the transfer.
SBE FFDC might be up to 8Kb.

The SBE interface expects data to be specified in units of words (4
bytes), defined as OCC_MAX_RESP_WORDS.

This change allows the full FFDC capture to be implemented, where before
it was not available.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211019205307.36946-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2 years agodt-bindings: iio: frequency: add adrf6780 doc
Antoniu Miclaus [Thu, 21 Oct 2021 11:32:44 +0000 (14:32 +0300)]
dt-bindings: iio: frequency: add adrf6780 doc

Add device tree bindings for the ADRF6780 Upconverter.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://lore.kernel.org/r/20211021113244.56936-2-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: frequency: adrf6780: add support for ADRF6780
Antoniu Miclaus [Thu, 21 Oct 2021 11:32:43 +0000 (14:32 +0300)]
iio: frequency: adrf6780: add support for ADRF6780

The ADRF6780 is a silicon germanium (SiGe) design, wideband,
microwave upconverter optimized for point to point microwave
radio designs operating in the 5.9 GHz to 23.6 GHz frequency
range.

Datasheet:
https://www.analog.com/media/en/technical-documentation/data-sheets/ADRF6780.pdf

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://lore.kernel.org/r/20211021113244.56936-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: chemical: scd4x: Add a scale for the co2 concentration reading
Roan van Dijk [Thu, 21 Oct 2021 14:00:18 +0000 (16:00 +0200)]
iio: chemical: scd4x: Add a scale for the co2 concentration reading

This patch adds a scale for the co2 concentration reading. The reading is
expressed in percent after applying the scale to the raw value.

Signed-off-by: Roan van Dijk <roan@protonic.nl>
Link: https://lore.kernel.org/r/20211021140018.3051213-1-roan@protonic.nl
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: io-channel-mux: allow duplicate channel, labels
Peter Rosin [Fri, 8 Oct 2021 22:11:30 +0000 (00:11 +0200)]
dt-bindings: iio: io-channel-mux: allow duplicate channel, labels

This is needed since an empty channel label is used to indicate an
unused channel, and there can be more that one of those.

Fixes the following problem reported by dtbs_check:
envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements
arch/arm/boot/dts/at91-tse850-3.dt.yaml

Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: io-channel-mux: add optional #io-channel-cells
Peter Rosin [Fri, 8 Oct 2021 22:11:21 +0000 (00:11 +0200)]
dt-bindings: iio: io-channel-mux: add optional #io-channel-cells

Needed for in-kernel use of the child channels of the mux.

Fixes problems like this, reported by dtbs_check:
adc0mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

Suggested-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: adc128s052: Simplify adc128_probe()
Christophe JAILLET [Thu, 26 Aug 2021 18:36:22 +0000 (20:36 +0200)]
iio: adc: adc128s052: Simplify adc128_probe()

Turn 'adc128_probe()' into a full resource managed function to simplify the
code.

This way, the .remove function can be removed.
Doing so, the only 'spi_get_drvdata()' call is removed and the
corresponding 'spi_set_drvdata()' can be removed as well.

Suggested-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/4fa7fcc59c40e27af0569138d656c698a53dbd44.1630002770.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: multiplexer: iio-mux: Support settle-time-us property
Vincent Whitchurch [Thu, 7 Oct 2021 13:46:41 +0000 (15:46 +0200)]
iio: multiplexer: iio-mux: Support settle-time-us property

If the devicetree specifies that the hardware requires a settle time,
pass this time on to the mux APIs.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20211007134641.13417-4-vincent.whitchurch@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: io-channel-mux: Add property for settle time
Vincent Whitchurch [Thu, 7 Oct 2021 13:46:40 +0000 (15:46 +0200)]
dt-bindings: iio: io-channel-mux: Add property for settle time

Hardware may require some time for the muxed analog signals to settle
after the muxing is changed.  Allow this time to be specified in the
devicetree.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20211007134641.13417-3-vincent.whitchurch@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agomux: add support for delay after muxing
Vincent Whitchurch [Thu, 7 Oct 2021 13:46:39 +0000 (15:46 +0200)]
mux: add support for delay after muxing

Hardware may require some time for the muxed analog signals to settle
after the muxing is changed.  Allow users of the mux subsystem to
specify this delay with the new mux_control_select_delay() function (and
the _try equivalent).

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20211007134641.13417-2-vincent.whitchurch@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agocounter: Fix use-after-free race condition for events_queue_size write
William Breathitt Gray [Thu, 21 Oct 2021 10:35:40 +0000 (19:35 +0900)]
counter: Fix use-after-free race condition for events_queue_size write

A race condition is possible when writing to events_queue_size where the
events kfifo is freed during the execution of a kfifo_in(), resulting in
a use-after-free. This patch prevents such a scenario by protecting the
events queue in operation with a spinlock and locking before performing
the events queue size adjustment.

The existing events_lock mutex is renamed to events_out_lock to reflect
that it only protects events queue out operations. Because the events
queue in operations can occur in an interrupt context, a new
events_in_lock spinlock is introduced and utilized.

Fixes: feff17a550c7 ("counter: Implement events_queue_size sysfs attribute")
Cc: David Lechner <david@lechnology.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/20211021103540.955639-1-vilhelm.gray@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocounter: Cleanup lingering atomic.h includes
William Breathitt Gray [Thu, 21 Oct 2021 10:35:14 +0000 (19:35 +0900)]
counter: Cleanup lingering atomic.h includes

With the removal of the chrdev_lock atomic flag, the counter-sysfs.c and
counter-chrdev.c no longer needs to include the atomic.h header file.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/20211021103514.955622-1-vilhelm.gray@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoiio: buffer: Fix memory leak in iio_buffers_alloc_sysfs_and_mask()
Yang Yingliang [Mon, 18 Oct 2021 06:37:18 +0000 (14:37 +0800)]
iio: buffer: Fix memory leak in iio_buffers_alloc_sysfs_and_mask()

When 'iio_dev_opaque->buffer_ioctl_handler' alloc fails in
iio_buffers_alloc_sysfs_and_mask(), the 'attrs' allocated in
iio_buffer_register_legacy_sysfs_groups() will be leaked:

unreferenced object 0xffff888108568d00 (size 128):
  comm "88", pid 2014, jiffies 4294963294 (age 26.920s)
  hex dump (first 32 bytes):
    80 3e da 02 80 88 ff ff 00 3a da 02 80 88 ff ff  .>.......:......
    00 35 da 02 80 88 ff ff 00 38 da 02 80 88 ff ff  .5.......8......
  backtrace:
    [<0000000095a9e51e>] __kmalloc+0x1a3/0x2f0
    [<00000000faa3735e>] iio_buffers_alloc_sysfs_and_mask+0xfa3/0x1480 [industrialio]
    [<00000000a46384dc>] __iio_device_register+0x52e/0x1b40 [industrialio]
    [<00000000210af05e>] __devm_iio_device_register+0x22/0x80 [industrialio]
    [<00000000730d7b41>] adjd_s311_probe+0x195/0x200 [adjd_s311]
    [<00000000c0f70eb9>] i2c_device_probe+0xa07/0xbb0

The iio_buffer_register_legacy_sysfs_groups() is
called in __iio_buffer_alloc_sysfs_and_mask(),
so move the iio_buffer_unregister_legacy_sysfs_groups()
into __iio_buffer_free_sysfs_and_mask(), then the memory
will be freed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: d9a625744ed0 ("iio: core: merge buffer/ & scan_elements/ attributes")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20211018063718.1971240-1-yangyingliang@huawei.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agosoundwire: qcom: add debugfs entry for soundwire register dump
Srinivas Kandagatla [Tue, 7 Sep 2021 10:56:36 +0000 (11:56 +0100)]
soundwire: qcom: add debugfs entry for soundwire register dump

For debug purposes add an entry in debugfs to dump Qualcomm
SoundWire Controller registers.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210907105636.3171-1-srinivas.kandagatla@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agosoundwire: bus: stop dereferencing invalid slave pointer
Srinivas Kandagatla [Tue, 12 Oct 2021 10:15:21 +0000 (11:15 +0100)]
soundwire: bus: stop dereferencing invalid slave pointer

Slave pointer is invalid after end of list iteration, using this
would result in below Memory abort.

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000004
...
Call trace:
 __dev_printk+0x34/0x7c
 _dev_warn+0x6c/0x90
 sdw_bus_exit_clk_stop+0x194/0x1d0
 swrm_runtime_resume+0x13c/0x238
 pm_generic_runtime_resume+0x2c/0x48
 __rpm_callback+0x44/0x150
 rpm_callback+0x6c/0x78
 rpm_resume+0x314/0x558
 rpm_resume+0x378/0x558
 rpm_resume+0x378/0x558
 __pm_runtime_resume+0x3c/0x88

Use bus->dev instead to print this error message.

Fixes: b50bb8ba369cd ("soundwire: bus: handle -ENODATA errors in clock stop/start sequences")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211012101521.32087-1-srinivas.kandagatla@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2 years agoiio: adc: stm32-adc: use generic binding for sample-time
Olivier Moysan [Thu, 14 Oct 2021 13:12:28 +0000 (15:12 +0200)]
iio: adc: stm32-adc: use generic binding for sample-time

Add st,min-sample-time-nsecs to channel generic binding.
Sample time can be defined par channel node. If a channel
is configured as differential, the same sample time applies
for both inputs.
Keep support of legacy st,min-sample-time-nsecs property
for backward compatibility.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20211014131228.4692-8-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: stm32-adc: add vrefint calibration support
Olivier Moysan [Thu, 14 Oct 2021 13:12:27 +0000 (15:12 +0200)]
iio: adc: stm32-adc: add vrefint calibration support

Add support of vrefint calibration.
If a channel is labeled as vrefint, get vrefint calibration
from non volatile memory for this channel.
vrefint channel is exposed as a processed channel returning
the actual value of vrefp:
vrefp = 3.3 x vrefint_cal / vrefint_data

A conversion on vrefint channel allows to update scale
factor according to vrefint deviation, compared to vrefint
calibration value.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20211014131228.4692-7-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: stm32-adc: add support of internal channels
Olivier Moysan [Thu, 14 Oct 2021 13:12:26 +0000 (15:12 +0200)]
iio: adc: stm32-adc: add support of internal channels

Add support of ADC2 internal channels VDDCORE, VREFINT and VBAT.
The reserved label name "vddcore", "vrefint" and "vbat" must
be used in Device Tree channel node, to enable the corresponding
internal channel.

Note: This patch does not provide support of internal channels
for F4 and H7.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20211014131228.4692-6-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: stm32-adc: add support of generic channels binding
Olivier Moysan [Thu, 14 Oct 2021 13:12:25 +0000 (15:12 +0200)]
iio: adc: stm32-adc: add support of generic channels binding

Add support of generic IIO channel binding:
./devicetree/bindings/iio/adc/adc.yaml
Keep support of st,adc-channels and st,adc-diff-channels
for backward compatibility.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20211014131228.4692-5-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: stm32-adc: split channel init into several routines
Olivier Moysan [Thu, 14 Oct 2021 13:12:24 +0000 (15:12 +0200)]
iio: adc: stm32-adc: split channel init into several routines

Split stm32_adc_chan_of_init channel initialization function into
several routines to increase readability and prepare channel
generic binding handling.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20211014131228.4692-4-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: stm32-adc: add nvmem support for vrefint internal channel
Olivier Moysan [Thu, 14 Oct 2021 13:12:23 +0000 (15:12 +0200)]
dt-bindings: iio: stm32-adc: add nvmem support for vrefint internal channel

Add support of nvmem. This allows to retrieve calibration data from OTP
for vrefint internal channel.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20211014131228.4692-3-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: stm32-adc: add generic channel binding
Olivier Moysan [Thu, 14 Oct 2021 13:12:22 +0000 (15:12 +0200)]
dt-bindings: iio: stm32-adc: add generic channel binding

Add ADC generic channel binding. This binding should
be used as an alternate to legacy channel properties
whenever possible.
ADC generic channel binding allows to identify supported
internal channels through the following reserved label names:
"vddcore", "vrefint" and "vbat".
This binding also allows to set a different sampling time
for each channel.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20211014131228.4692-2-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.
Jonathan Cameron [Sun, 17 Oct 2021 16:03:03 +0000 (17:03 +0100)]
iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.

Whilst nice to get rid of this non obvious code, this also clears a
static checker warning:

drivers/iio/accel/sca3000.c:734 sca3000_read_raw()
warn: no-op. '((*val) << 19) >> 19'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20211017160303.72441-1-jic23@kernel.org
2 years agoiio: xilinx-xadc: Remove `irq` field from state struct
Lars-Peter Clausen [Sun, 17 Oct 2021 12:15:51 +0000 (14:15 +0200)]
iio: xilinx-xadc: Remove `irq` field from state struct

Since commit 2a9685d1a3b7 ("iio: adc: xilinx: use more devres helpers and
remove remove()") the `irq` field from XADC driver state struct is only
used in the `probe()` function.

Use the local `irq` variable throughout the `probe()` function and remove
the now unused field from the state struct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20211017121551.24063-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr()
Teng Qi [Mon, 11 Oct 2021 11:40:03 +0000 (19:40 +0800)]
iio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr()

The length of hw->settings->odr_table is 2 and ref_sensor->id is an enum
variable whose value is between 0 and 5.
However, the value ST_LSM6DSX_ID_MAX (i.e. 5) is not caught properly in
 switch (sensor->id) {

If ref_sensor->id is ST_LSM6DSX_ID_MAX, an array overflow will ocurrs in
function st_lsm6dsx_check_odr():
  odr_table = &sensor->hw->settings->odr_table[sensor->id];

and in function st_lsm6dsx_set_odr():
  reg = &hw->settings->odr_table[ref_sensor->id].reg;

To avoid this array overflow, handle ST_LSM6DSX_ID_GYRO explicitly and
return -EINVAL for the default case.

The enum value ST_LSM6DSX_ID_MAX is only present as an easy way to check
the limit and as such is never used, however this is not locally obvious.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Teng Qi <starmiku1207184332@gmail.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20211011114003.976221-1-starmiku1207184332@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: light: gp2ap002: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:26:54 +0000 (17:26 +0800)]
iio: light: gp2ap002: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092656.421-3-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: light: cm3605: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:26:52 +0000 (17:26 +0800)]
iio: light: cm3605: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20211008092656.421-1-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: ti-ads7950: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:57 +0000 (17:28 +0800)]
iio: adc: ti-ads7950: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-9-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: rockchip_saradc: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:56 +0000 (17:28 +0800)]
iio: adc: rockchip_saradc: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-8-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: qcom-pm8xxx-xoadc: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:55 +0000 (17:28 +0800)]
iio: adc: qcom-pm8xxx-xoadc: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

BTW, change the return value from 'ENXIO' to 'ENODEV',
perfer ENODEV which means no such device.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20211008092858.495-7-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: meson_saradc: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:54 +0000 (17:28 +0800)]
iio: adc: meson_saradc: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #Meson8b Odroid-C1
Link: https://lore.kernel.org/r/20211008092858.495-6-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1241: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:53 +0000 (17:28 +0800)]
iio: adc: max1241: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-5-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1118: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:52 +0000 (17:28 +0800)]
iio: adc: max1118: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-4-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: lpc18xx_adc: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:51 +0000 (17:28 +0800)]
iio: adc: lpc18xx_adc: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-3-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: imx7d_adc: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:50 +0000 (17:28 +0800)]
iio: adc: imx7d_adc: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-2-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: ab8500-gpadc: Make use of the helper function dev_err_probe()
Cai Huoqing [Fri, 8 Oct 2021 09:28:49 +0000 (17:28 +0800)]
iio: adc: ab8500-gpadc: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-1-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: buffer: Fix uninitialized variable ret
Colin Ian King [Fri, 15 Oct 2021 15:32:54 +0000 (16:32 +0100)]
iio: buffer: Fix uninitialized variable ret

When !iio_buffer_space_available(rb) is true and signal_pending(current)
is false the end of the do-while loop is reached and the uninitialized
variable ret is zero checked. Fix this by initializing variable ret to
zero.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 9eeee3b0bf19 ("iio: Add output buffer support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20211015153254.33783-1-colin.king@canonical.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: lpc18xx_adc: Convert probe to device managed version
André Gustavo Nakagomi Lopez [Fri, 15 Oct 2021 18:47:12 +0000 (15:47 -0300)]
iio: adc: lpc18xx_adc: Convert probe to device managed version

The remove function and the goto sections are not necessary if devm
functions are used.

Convert device register to devm version. Add hook functions to release
device resources, and use them inside probe with devm_add_action,
which will release resources on driver detach.

To maintain the order of which device resources were released/reseted,
register the hook functions as soon as resources are obtained/initialized.
Since devres actions are called on driver detach, the remove
function and the error-handling goto sections are no longer necessary.

Signed-off-by: André Gustavo Nakagomi Lopez <andregnl@usp.br>
Link: https://lore.kernel.org/r/YWnMsGlc/I35gYvy@Andryuu.br
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: light: ltr501: Add of_device_id table
Nikita Travkin [Wed, 6 Oct 2021 16:30:58 +0000 (21:30 +0500)]
iio: light: ltr501: Add of_device_id table

Add of_device_id table so the driver can be used on DT platforms without
relying on i2c_device_id fallback. (So DT schema validation is possible)

Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Link: https://lore.kernel.org/r/20211006163058.145842-4-nikita@trvn.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: light: ltr501: Add rudimentary regulator support
Nikita Travkin [Wed, 6 Oct 2021 16:30:57 +0000 (21:30 +0500)]
iio: light: ltr501: Add rudimentary regulator support

On some platforms the supply regulators must be enabled before the
sensor can work. Add vdd and vddio regulators for the sensor and IO bus
power respectively.

Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Link: https://lore.kernel.org/r/20211006163058.145842-3-nikita@trvn.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: light: Document ltr501 light sensor bindings
Nikita Travkin [Wed, 6 Oct 2021 16:30:56 +0000 (21:30 +0500)]
dt-bindings: iio: light: Document ltr501 light sensor bindings

Add devicetree bindings for ltr501, ltr559 and ltr301.

Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20211006163058.145842-2-nikita@trvn.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: vendor-prefixes: Document liteon vendor prefix
Nikita Travkin [Wed, 6 Oct 2021 16:30:55 +0000 (21:30 +0500)]
dt-bindings: vendor-prefixes: Document liteon vendor prefix

Add vendor prefix for LITE-ON Technology Corp.

Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20211006163058.145842-1-nikita@trvn.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoMAINTAINERS: Update the entry for MHI bus
Manivannan Sadhasivam [Tue, 19 Oct 2021 13:39:01 +0000 (19:09 +0530)]
MAINTAINERS: Update the entry for MHI bus

Since Hemant is not carrying out any maintainership duties let's make
him as a dedicated reviewer. Also add the new mailing lists dedicated
for MHI in subspace mailing list server.

Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20211019133901.173966-1-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoMerge tag 'iio-for-5.16a-split-take4' of https://git.kernel.org/pub/scm/linux/kernel...
Greg Kroah-Hartman [Tue, 19 Oct 2021 09:44:28 +0000 (11:44 +0200)]
Merge tag 'iio-for-5.16a-split-take4' of https://git./linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

First set of IIO new device and feature support for the 5.16 cycle

Counter subsystem changes now sent separately.

This has been a busy cycle, so lots here and a few more stragglers to
come next week.

Big new feature in this cycle is probably output buffer support.
This has been in the works for a very long time so it's great to see
Mihail pick up the challenge and build upon his predecessors work to finally
bring this feature to mainline.

New device support
------------------

* adi,adxl313
  - New driver and dt bindings for this low power accelerometer.
* adi,adxl355
  - New driver and dt bindings for this accelerometer.
  - Later series adds buffer support.
* asahi-kasei,ak8975
  - Minor additions to driver to support ak09916
* aspeed,aspeed-adc
  - Substantial rework plus feature additions to add support for the
    ast2600 including a new dt bindings doc.
* atmel,at91_sama5d2
  - Rework and support introduced for the sama7g5 parts.
* maxim,max31865
  - New driver and bindings for this RTD temperature sensor chip.
* nxp,imx8qxp
  - New driver and bindings for the ADC found on the i.MX 8QuadXPlus Soc.
* senseair,sunrise
  - New driver and bindings for this family of carbon dioxide gas sensors.
* sensiron,scd4x
  - New driver and bindings for this carbon dioxide gas sensor.

New features
------------

* Output buffer support.  Works in a similar fashion to input buffers, but
  in this case userspace pushes data into the kfifo which is then drained
  to the device when a trigger occurs.  Support added to the ad5766 DAC
  driver.
* Core, devm_iio_map_array_register() to avoid need for
  devm_add_action_or_reset() based cleanup in fully managed allocation
  drivers.
* Core iio_push_to_buffers_with_ts_unaligned() function to safely handle a
  few drivers where it really hard to ensure the correct data alignment in
  an iio_push_to_buffers_with_timestamp() call. Note this uses a bounce
  buffer so should be avoided whenever possible.  Used in the ti,adc108s102,
  invense,mpu3050 and adi,adis16400.  This closes the last   known set
  of drivers with alignment issues at this interface.
* maxim,max1027
  - Substantial rework to this driver main target of which was supporting
    use of other triggers than it's own EOC interrupt.
  - Transfer optimization.
* nxp,fxls8962af
  - Threshold even support including using it as a wakeup source.

Cleanups, minor fixes etc
-------------------------

Chances of a common type to multiple drivers:

* devm_ conversion and drop of .remove() callbacks in:
  - adi,ad5064
  - adi,ad7291
  - adi,ad7303
  - adi,ad7746
  - adi,ad9832
  - adi,adis16080
  - dialog,da9150-gpadc
  - intel,mrfld_adc
  - marvell,berlin2
  - maxim,max1363
  - maxim,max44000
  - nuvoton,nau7802
  - st_sensors (includes a lot of rework!)
  - ti,ads8344
  - ti,lp8788

* devm_platform_ioremap_resource() used to reduce boilerplate
  - cirrus,ep93xx
  - rockchip,saradc
  - stm,stm32-dac

* Use dev_err_probe() in more places to both not print on deferred probe and
  ensure a reason for the deferral is available for debug purposes.
  - adi,ad8801
  - capella,cm36651
  - linear,ltc1660
  - maxim,ds4424
  - maxim,max5821
  - microchip,mcp4922
  - nxp,lpc18xx
  - onnn,noa1305
  - st,lsm9ds0
  - st,st_sensors
  - st,stm32-dac
  - ti,afe4403
  - ti,afe4404
  - ti,dac7311

* Drop error returns in SPI and I2C remove() functions as they are ignored and
  long term plan is to change these all over to returning void. In some cases
  these patches just make it 'obvious' they always return 0 where it was the
  case before but not easy to tell.
  - adi,ad5380
  - adi,ad5446
  - adi,ad5686
  - adi,ad5592r
  - bosch,bma400
  - bosch,bmc150
  - fsl,mma7455
  - honeywell,hmc5843
  - kionix,kxsd9
  - maxim,max5487
  - meas,ms5611
  - ti,afe4403

Driver specific changes

* adi,ad5770r
  - Bring driver inline with documented bindings.
* adi,ad7746
  - Trivial style fix
* adi,ad7949
  - Express some magic values as the underlying parts via new #defines.
  - Make it work with SPI controllers that don't support 14 or 16 bit messages
  - Support selection of voltage reference from dt including expanding the
    dt-bindings to cover this new functionality.
* adi,ad799x
  - Implement selection of external reference voltage on AD7991, AD7995 and
    AD7999.
  - Add missing dt-bindings doc for devices supported by this driver.
* adi,adislib
  - Move interrupt startup to better location in startup flow.
  - Handle devices that cannot mask/unmask the drdy pin and must instead mask
    at the interrupt controller.  Applies to the adis16460 and adis16475 from
    which we then drop equivalent code.
* adi,ltc2983
  - Add support for optional reset pin.
  - Fail to probe if no channels specified in dt binding.
* asahi-kasei,ak8975
  - dt-binding additions of missing vid-supply regulator.
* aspeed,aspeed-adc
  - Typo fix.
* fsl,mma7660
  - Mark acpi_device_id table __maybe_unused to avoid build warning.
* fsl,imx25-gcq
  - Avoid initializing regulators that aren't used.
* invensense,mpu3050
  - Drop a dead protection against a clash with the old input driver.
* invensense,mpu6050
  - Rework code to not use strcpy() and hence avoid possibility of wrong sized
    buffers. Note this wasn't a bug, but the new code is a lot more readable.
  - Mark acpi_device_id table __maybe_unused to avoid build warning.
* kionix,kxcjk1013
  - dt-binding addition to note it supports interrupts.
* marvell,berlin2-adc
  - Enable COMPILE_TEST building.
* maxim,max1027
  - Avoid returning success in an error path.
* nxp,imx8qxp
  - Fix warning when runtime pm not enabled via __maybe_unused.
* ricoh,rn5t618
  - Use the new devm_iio_map_array_register() instead of open coding the same.
* samsung,exynos_adc
  - Improve kconfig help text.
* st,lsm6dsx
  - Move max_fifo_size into the fifo_ops structure where the other configuration
    parameters are found.
* st,st_sensors:
  - Reorder to ensure we turn the power off after removing userspace interfaces.
* senseair,sunrise
  - Add missing I2C dependency.
* ti,twl6030
  - Small code tidy up.

* tag 'iio-for-5.16a-split-take4' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (148 commits)
  iio: imx8qxp-adc: mark PM functions as __maybe_unused
  iio: pressure: ms5611: Make ms5611_remove() return void
  iio: potentiometer: max5487: Don't return an error in .remove()
  iio: magn: hmc5843: Make hmc5843_common_remove() return void
  iio: health: afe4403: Don't return an error in .remove()
  iio: dac: ad5686: Make ad5686_remove() return void
  iio: dac: ad5592r: Make ad5592r_remove() return void
  iio: dac: ad5446: Make ad5446_remove() return void
  iio: dac: ad5380: Make ad5380_remove() return void
  iio: accel: mma7455: Make mma7455_core_remove() return void
  iio: accel: kxsd9: Make kxsd9_common_remove() return void
  iio: accel: bmi088: Make bmi088_accel_core_remove() return void
  iio: accel: bmc150: Make bmc150_accel_core_remove() return void
  iio: accel: bma400: Make bma400_remove() return void
  drivers:iio:dac:ad5766.c: Add trigger buffer
  iio: triggered-buffer: extend support to configure output buffers
  iio: kfifo-buffer: Add output buffer support
  iio: Add output buffer support
  iio: documentation: Document scd4x calibration use
  drivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor
  ...

2 years agocounter: drop chrdev_lock
David Lechner [Sun, 17 Oct 2021 18:55:21 +0000 (13:55 -0500)]
counter: drop chrdev_lock

This removes the chrdev_lock from the counter subsystem. This was
intended to prevent opening the chrdev more than once. However, this
doesn't work in practice since userspace can duplicate file descriptors
and pass file descriptors to other processes. Since this protection
can't be relied on, it is best to just remove it.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: David Lechner <david@lechnology.com>
Link: https://lore.kernel.org/r/20211017185521.3468640-1-david@lechnology.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocounter/counter-sysfs: use sysfs_emit everywhere
David Lechner [Sun, 17 Oct 2021 19:01:06 +0000 (14:01 -0500)]
counter/counter-sysfs: use sysfs_emit everywhere

In the counter subsystem, we are already using sysfs_emit(), but there
were a few places where we were still using sprintf() in *_show()
functions. For consistency and added protections, use sysfs_emit()
everywhere.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: David Lechner <david@lechnology.com>
Link: https://lore.kernel.org/r/20211017190106.3472645-1-david@lechnology.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agochar: xillybus: fix msg_ep UAF in xillyusb_probe()
Ziyang Xuan [Sat, 16 Oct 2021 05:20:47 +0000 (13:20 +0800)]
char: xillybus: fix msg_ep UAF in xillyusb_probe()

When endpoint_alloc() return failed in xillyusb_setup_base_eps(),
'xdev->msg_ep' will be freed but not set to NULL. That lets program
enter fail handling to cleanup_dev() in xillyusb_probe(). Check for
'xdev->msg_ep' is invalid in cleanup_dev() because 'xdev->msg_ep' did
not set to NULL when was freed. So the UAF problem for 'xdev->msg_ep'
is triggered.

==================================================================
BUG: KASAN: use-after-free in fifo_mem_release+0x1f4/0x210
CPU: 0 PID: 166 Comm: kworker/0:2 Not tainted 5.15.0-rc5+ #19
Call Trace:
 dump_stack_lvl+0xe2/0x152
 print_address_description.constprop.0+0x21/0x140
 ? fifo_mem_release+0x1f4/0x210
 kasan_report.cold+0x7f/0x11b
 ? xillyusb_probe+0x530/0x700
 ? fifo_mem_release+0x1f4/0x210
 fifo_mem_release+0x1f4/0x210
 ? __sanitizer_cov_trace_pc+0x1d/0x50
 endpoint_dealloc+0x35/0x2b0
 cleanup_dev+0x90/0x120
 xillyusb_probe+0x59a/0x700
...

Freed by task 166:
 kasan_save_stack+0x1b/0x40
 kasan_set_track+0x1c/0x30
 kasan_set_free_info+0x20/0x30
 __kasan_slab_free+0x109/0x140
 kfree+0x117/0x4c0
 xillyusb_probe+0x606/0x700

Set 'xdev->msg_ep' to NULL after being freed in xillyusb_setup_base_eps()
to fix the UAF problem.

Fixes: a53d1202aef1 ("char: xillybus: Add driver for XillyUSB (Xillybus variant for USB)")
Cc: stable <stable@vger.kernel.org>
Acked-by: Eli Billauer <eli.billauer@gmail.com>
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Link: https://lore.kernel.org/r/20211016052047.1611983-1-william.xuanziyang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agobinder: don't detect sender/target during buffer cleanup
Todd Kjos [Fri, 15 Oct 2021 23:38:11 +0000 (16:38 -0700)]
binder: don't detect sender/target during buffer cleanup

When freeing txn buffers, binder_transaction_buffer_release()
attempts to detect whether the current context is the target by
comparing current->group_leader to proc->tsk. This is an unreliable
test. Instead explicitly pass an 'is_failure' boolean.

Detecting the sender was being used as a way to tell if the
transaction failed to be sent.  When cleaning up after
failing to send a transaction, there is no need to close
the fds associated with a BINDER_TYPE_FDA object. Now
'is_failure' can be used to accurately detect this case.

Fixes: 44d8047f1d87 ("binder: use standard functions to allocate fds")
Cc: stable <stable@vger.kernel.org>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Todd Kjos <tkjos@google.com>
Link: https://lore.kernel.org/r/20211015233811.3532235-1-tkjos@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoMerge tag 'misc-habanalabs-next-2021-10-18' of https://git.kernel.org/pub/scm/linux...
Greg Kroah-Hartman [Tue, 19 Oct 2021 07:37:59 +0000 (09:37 +0200)]
Merge tag 'misc-habanalabs-next-2021-10-18' of https://git./linux/kernel/git/ogabbay/linux into char-misc-next

Oded writes:

This tag contains habanalabs driver changes for v5.16:

- Add a new uAPI (under the memory ioctl) to request from the driver
  to export a DMA-BUF object that represents a memory region on
  the device's DRAM. This is needed to enable peer-to-peer over PCIe
  between habana device and an RDMA adapter (e.g. mlnx5 or efa
  rdma adapter).

- Add debugfs node to dynamically configure CS timeout. Up until now,
  it was only configurable through kernel module parameter.

- Fetch more comprehensive power information from the firmware.

- Always take timestamp when waiting for user interrupt, as the user
  needs that information to optimize the graph runtime compilation.

- Modify user interrupt to look on 64-bit user value as fence, instead
  of 32-bit.

- Bypass reset in case of repeated h/w error event after device reset.
  This is to prevent endless loop of resets to the device.

- Fix several bugs in multi CS completion code.

- Fix race condition in fd close/open.

- Update to latest firmware headers

- Add select CRC32 in kconfig

- Small fixes, cosmetics

* tag 'misc-habanalabs-next-2021-10-18' of https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux: (25 commits)
  habanalabs: refactor fence handling in hl_cs_poll_fences
  habanalabs: context cleanup cosmetics
  habanalabs: simplify wait for interrupt with timestamp flow
  habanalabs: initialize hpriv fields before adding new node
  habanalabs: Unify frequency set/get functionality
  habanalabs: select CRC32
  habanalabs: add support for dma-buf exporter
  habanalabs: define uAPI to export FD for DMA-BUF
  habanalabs: fix NULL pointer dereference
  habanalabs: fix race condition in multi CS completion
  habanalabs: use only u32
  habanalabs: update firmware files
  habanalabs: bypass reset for continuous h/w error event
  habanalabs: take timestamp on wait for interrupt
  habanalabs: prevent race between fd close/open
  habanalabs: refactor reset log message
  habanalabs: define soft-reset as inference op
  habanalabs: fix debugfs device memory MMU VA translation
  habanalabs: add support for a long interrupt target value
  habanalabs: remove redundant cs validity checks
  ...

2 years agoiio: imx8qxp-adc: mark PM functions as __maybe_unused
Arnd Bergmann [Wed, 13 Oct 2021 14:43:26 +0000 (16:43 +0200)]
iio: imx8qxp-adc: mark PM functions as __maybe_unused

Without CONFIG_PM_SLEEP, the runtime suspend/resume functions
are unused, producing a warning:

drivers/iio/adc/imx8qxp-adc.c:433:12: error: 'imx8qxp_adc_runtime_resume' defined but not used [-Werror=unused-function]
  433 | static int imx8qxp_adc_runtime_resume(struct device *dev)
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/iio/adc/imx8qxp-adc.c:419:12: error: 'imx8qxp_adc_runtime_suspend' defined but not used [-Werror=unused-function]
  419 | static int imx8qxp_adc_runtime_suspend(struct device *dev)
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Mark them as __maybe_unused to shut up the compiler.

Fixes: 1e23dcaa1a9f ("iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211013144338.2261316-1-arnd@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: pressure: ms5611: Make ms5611_remove() return void
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:23 +0000 (22:32 +0200)]
iio: pressure: ms5611: Make ms5611_remove() return void

Up to now ms5611_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-16-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: potentiometer: max5487: Don't return an error in .remove()
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:22 +0000 (22:32 +0200)]
iio: potentiometer: max5487: Don't return an error in .remove()

The only effect of returning an error in an spi .remove() callback is
that the spi core issues a generic warning message. Instead emit a more
specific error message and return 0 to not report the same issue twice.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-15-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: magn: hmc5843: Make hmc5843_common_remove() return void
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:21 +0000 (22:32 +0200)]
iio: magn: hmc5843: Make hmc5843_common_remove() return void

Up to now hmc5843_common_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-14-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: health: afe4403: Don't return an error in .remove()
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:19 +0000 (22:32 +0200)]
iio: health: afe4403: Don't return an error in .remove()

The only effect of returning an error in an spi .remove() callback is
that the spi core issues another warning message. Don't report the same
problem twice and return 0 unconditionally instead. Also degrade the log
level to warning, as nothing really bad is expected from a failure to
put the device in suspend mode.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-12-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>