platform/kernel/linux-rpi.git
3 years agostaging: most: Fix spelling mistake "tranceiver" -> "transceiver"
Colin Ian King [Thu, 26 Nov 2020 22:46:02 +0000 (22:46 +0000)]
staging: most: Fix spelling mistake "tranceiver" -> "transceiver"

There is a spelling mistake in the Kconfig help text. Fix it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201126224602.13878-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: qlge: remove duplicate word in comment
Nicholas Warfield [Tue, 8 Dec 2020 22:25:29 +0000 (14:25 -0800)]
staging: qlge: remove duplicate word in comment

This patch fixes the checkpatch warning:

WARNING: Possible repeated word: 'each'
1712: FILE: qlge.h:1712.h
+ * that are each each 64-bits in length. There are a total of

Signed-off-by: Nicholas Warfield <nick@nkwarfield.io>
Link: https://lore.kernel.org/r/X8/9WWP3S1GrVNaa@coffee.localdomain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: comedi: mf6x4: Fix AI end-of-conversion detection
Ian Abbott [Mon, 7 Dec 2020 14:58:06 +0000 (14:58 +0000)]
staging: comedi: mf6x4: Fix AI end-of-conversion detection

I have had reports from two different people that attempts to read the
analog input channels of the MF624 board fail with an `ETIMEDOUT` error.

After triggering the conversion, the code calls `comedi_timeout()` with
`mf6x4_ai_eoc()` as the callback function to check if the conversion is
complete.  The callback returns 0 if complete or `-EBUSY` if not yet
complete.  `comedi_timeout()` returns `-ETIMEDOUT` if it has not
completed within a timeout period which is propagated as an error to the
user application.

The existing code considers the conversion to be complete when the EOLC
bit is high.  However, according to the user manuals for the MF624 and
MF634 boards, this test is incorrect because EOLC is an active low
signal that goes high when the conversion is triggered, and goes low
when the conversion is complete.  Fix the problem by inverting the test
of the EOLC bit state.

Fixes: 04b565021a83 ("comedi: Humusoft MF634 and MF624 DAQ cards driver")
Cc: <stable@vger.kernel.org> # v4.4+
Cc: Rostislav Lisovy <lisovy@gmail.com>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20201207145806.4046-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: greybus: Add TODO item about modernizing the pwm code
Uwe Kleine-König [Tue, 8 Dec 2020 10:16:07 +0000 (11:16 +0100)]
staging: greybus: Add TODO item about modernizing the pwm code

drivers/staging/greybus/pwm.c uses the old style PWM callbacks, new drivers
should stick to the atomic API instead.

Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20201208101607.42785-1-uwe@kleine-koenig.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agopinctrl: ralink: add a pinctrl driver for the rt2880 family
Sergio Paracuellos [Tue, 8 Dec 2020 07:55:23 +0000 (08:55 +0100)]
pinctrl: ralink: add a pinctrl driver for the rt2880 family

These Socs have 1-3 banks of 8-32 gpios. Rather then setting the muxing of each
pin individually, these socs have mux groups that when set will effect 1-N pins.
Pin groups have a 2, 4 or 8 different muxes.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://lore.kernel.org/r/20201208075523.7060-3-sergio.paracuellos@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agodt-bindings: pinctrl: rt2880: add binding document
Sergio Paracuellos [Tue, 8 Dec 2020 07:55:22 +0000 (08:55 +0100)]
dt-bindings: pinctrl: rt2880: add binding document

The commit adds rt2880 compatible node in binding document.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://lore.kernel.org/r/20201208075523.7060-2-sergio.paracuellos@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: remove ELEMENT_ID enum
Ross Schmidt [Tue, 8 Dec 2020 04:07:33 +0000 (22:07 -0600)]
staging: rtl8723bs: remove ELEMENT_ID enum

The ELEMENT_ID enum is no longer used, remove it.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-22-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: remove unused macros
Ross Schmidt [Tue, 8 Dec 2020 04:07:32 +0000 (22:07 -0600)]
staging: rtl8723bs: remove unused macros

Remove many macros from wifi.h and ieee80211.h because they are unused.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-21-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace EID_EXTCapability
Ross Schmidt [Tue, 8 Dec 2020 04:07:31 +0000 (22:07 -0600)]
staging: rtl8723bs: replace EID_EXTCapability

Replace unique EID_EXTCapability constant with kernel provided
WLAN_EID_EXT_CAPABILITY from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-20-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace EID_BSSIntolerantChlReport
Ross Schmidt [Tue, 8 Dec 2020 04:07:30 +0000 (22:07 -0600)]
staging: rtl8723bs: replace EID_BSSIntolerantChlReport

Replace unique EID_BSSIntolerantChlReport constant with kernel provided
WLAN_EID_BSS_INTOLERANT_CHL_REPORT from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-19-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace EID_BSSCoexistence
Ross Schmidt [Tue, 8 Dec 2020 04:07:29 +0000 (22:07 -0600)]
staging: rtl8723bs: replace EID_BSSCoexistence

Replace unique EID_BSSCoexistence constant with kernel provided
WLAN_EID_BSS_COEX_2040 from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-18-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _MME_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:28 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _MME_IE_

Replace unique _MME_IE_ macro with kernel provided WLAN_EID_MMIE from
linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-17-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _WAPI_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:27 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _WAPI_IE_

Replace unique _WAPI_IE_ macro with kernel provided
WLAN_EID_BSS_AC_ACCESS_DELAY from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-16-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _EXT_SUPPORTEDRATES_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:26 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _EXT_SUPPORTEDRATES_IE_

Replace unique _EXT_SUPPORTEDRATES_IE_ macro with kernel provided
WLAN_EID_EXT_SUPP_RATES from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-15-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _ERPINFO_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:25 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _ERPINFO_IE_

Replace unique _ERPINFO_IE_ macro with kernel provided WLAN_EID_ERP_INFO
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-14-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _CHLGETXT_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:24 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _CHLGETXT_IE_

Replace unique _CHLGETXT_IE_ macro with kernel provided WLAN_EID_CHALLENGE
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-13-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _COUNTRY_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:23 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _COUNTRY_IE_

Replace unique _COUNTRY_IE_ macro with kernel provided WLAN_EID_COUNTRY
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-12-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _IBSS_PARA_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:22 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _IBSS_PARA_IE_

Replace unique _IBSS_PARA_IE_ macro with kernel provided
WLAN_EID_IBSS_PARAMS from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-11-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _TIM_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:21 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _TIM_IE_

Replace unique _TIM_IE_ macro with kernel provided WLAN_EID_DS_PARAMS
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-10-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _DSSET_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:20 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _DSSET_IE_

Replace unique _DSSET_IE_ macro with kernel provdied WLAN_EID_DS_PARAMS
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-9-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _SUPPORTEDRATES_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:19 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _SUPPORTEDRATES_IE_

Replace unique _SUPPORTEDRATES_IE_ macro with kernel provided
WLAN_EID_SUPP_RATES from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-8-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace _SSID_IE_
Ross Schmidt [Tue, 8 Dec 2020 04:07:18 +0000 (22:07 -0600)]
staging: rtl8723bs: replace _SSID_IE_

Replace unique _SSID_IE_ macro with kernel provided WLAN_EID_SSID from
linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-7-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace WLAN_EID_VHT_OP_MODE_NOTIFY
Ross Schmidt [Tue, 8 Dec 2020 04:07:17 +0000 (22:07 -0600)]
staging: rtl8723bs: replace WLAN_EID_VHT_OP_MODE_NOTIFY

Replace unique WLAN_EID_VHT_OP_MODE_NOFITY macro with kernel provided
WLAN_EID_OPMODE_NOTIF from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-6-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: use WLAN_EID_HT_OPERATION
Ross Schmidt [Tue, 8 Dec 2020 04:07:16 +0000 (22:07 -0600)]
staging: rtl8723bs: use WLAN_EID_HT_OPERATION

Replace unique _HT_EXTRA_INFO_IE_ and _HT_ADD_INFO_IE_ macros with kernel
provided WLAN_EID_HT_OPERATION from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-5-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: use WLAN_EID_RSN
Ross Schmidt [Tue, 8 Dec 2020 04:07:15 +0000 (22:07 -0600)]
staging: rtl8723bs: use WLAN_EID_RSN

Replace unique _WPA2_IE_ID_, EID_WPA2, and _RSN_IE_2_ with kernel provided
WLAN_EID_RSN from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-4-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: use WLAN_EID_VENDOR_SPECIFIC
Ross Schmidt [Tue, 8 Dec 2020 04:07:14 +0000 (22:07 -0600)]
staging: rtl8723bs: use WLAN_EID_VENDOR_SPECIFIC

Replace unique WLAN_EID_GENERIC, _WPA_IE_ID_, _SSN_IE_1_, and
_VENDOR_SPECIFIC_IE_ macros with kernel provided WLAN_EID_VENDOR_SPECIFIC
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-3-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: use WLAN_EID_HT_CAPABILITY
Ross Schmidt [Tue, 8 Dec 2020 04:07:13 +0000 (22:07 -0600)]
staging: rtl8723bs: use WLAN_EID_HT_CAPABILITY

Replace unique WLAN_EID_HT_CAP, _HT_CAPABILITY_IE_, and EID_HTCapability
with kernel provided WLAN_EID_HT_CAPABILITY from linux/ieee80211.h.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201208040733.379197-2-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: remove LIST_CONTAINOR
Ross Schmidt [Sun, 6 Dec 2020 03:45:16 +0000 (21:45 -0600)]
staging: rtl8723bs: remove LIST_CONTAINOR

Remove unnecessary macro for container_of and call it directly.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-9-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: remove unused macros
Ross Schmidt [Sun, 6 Dec 2020 03:45:15 +0000 (21:45 -0600)]
staging: rtl8723bs: remove unused macros

Remove many macros from wifi.h because they are unused.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-8-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK
Ross Schmidt [Sun, 6 Dec 2020 03:45:14 +0000 (21:45 -0600)]
staging: rtl8723bs: replace RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK

Replace unique macro RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK with kernel
provided IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK.  The other
IEEE80211_ADDBA_* and IEEE_DELBA_* macros are duplicates already defined
in linux/ieee80211.h, remove them.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-7-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: remove WLAN_HT_CAP_SM_PS_* macros
Ross Schmidt [Sun, 6 Dec 2020 03:45:13 +0000 (21:45 -0600)]
staging: rtl8723bs: remove WLAN_HT_CAP_SM_PS_* macros

The WLAN_HT_CAP_SM_PS_* macro family is already defined in
linux/ieee80211.h, remove them.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-6-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace OP_MODE_* and HT_INFO_OPERATION_MODE_* macros
Ross Schmidt [Sun, 6 Dec 2020 03:45:12 +0000 (21:45 -0600)]
staging: rtl8723bs: replace OP_MODE_* and HT_INFO_OPERATION_MODE_* macros

Replace unique OP_MODE_* and HT_INFO_OPERATION_MODE_* macro families
with kernel provided IEEE80211_HT_OP_MODE_* macros.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-5-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace HT_CAP_AMPDU_FACTOR
Ross Schmidt [Sun, 6 Dec 2020 03:45:11 +0000 (21:45 -0600)]
staging: rtl8723bs: replace HT_CAP_AMPDU_FACTOR

Replace unique HT_CAP_AMPDU_FACTOR enum with kernel provided
ieee80211_max_ampdu_length_exp enum.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-4-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace cap_* macros
Ross Schmidt [Sun, 6 Dec 2020 03:45:10 +0000 (21:45 -0600)]
staging: rtl8723bs: replace cap_* macros

Replace unique cap_* macros with kernel provided WLAN_CAPABILITY_*
macros.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-3-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace WIFI_REASON_CODE
Ross Schmidt [Sun, 6 Dec 2020 03:45:09 +0000 (21:45 -0600)]
staging: rtl8723bs: replace WIFI_REASON_CODE

Replace unique macros and WIFI_REASON_CODE enum with the kernel provided
ieee80211_reasoncode.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-2-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8723bs: replace unique macros and WIFI_STATUS_CODE
Ross Schmidt [Sun, 6 Dec 2020 03:45:08 +0000 (21:45 -0600)]
staging: rtl8723bs: replace unique macros and WIFI_STATUS_CODE

Replace many unique macros and WIFI_STATUS_CODE enum with kernel
provided ieee80211_statuscode. A duplicate
WLAN_STATUS_ASSOC_DENIED_NOSHORT macro is also removed.

Signed-off-by: Ross Schmidt <ross.schm.dev@gmail.com>
Link: https://lore.kernel.org/r/20201206034517.4276-1-ross.schm.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
Wang Hai [Sat, 5 Dec 2020 10:38:27 +0000 (18:38 +0800)]
staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls

In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error
will be returned directly, which will cause the rest to be unable to be freed,
resulting in leak.

This patch fixes the bug. If if one of them is not found, just skip and free the others.

Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Link: https://lore.kernel.org/r/20201205103827.31244-1-wanghai38@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: mt7621-pinctrl: stop using the deprecated 'pinctrl_add_gpio_range'
Sergio Paracuellos [Sun, 6 Dec 2020 10:53:33 +0000 (11:53 +0100)]
staging: mt7621-pinctrl: stop using the deprecated 'pinctrl_add_gpio_range'

If the gpio DT node has the 'gpio-ranges' property, the range will be
added by the gpio core and doesn't need to be added by the pinctrl
driver.

By having the gpio-ranges property, we can map every pin between
gpio node and pinctrl node and we can stop using the deprecated
pinctrl_add_gpio_range() function.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://lore.kernel.org/r/20201206105333.18428-1-sergio.paracuellos@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoStaging: rtl8723bs/core: add blank line after declarations
Brother Matthew De Angelis [Sun, 6 Dec 2020 02:59:45 +0000 (20:59 -0600)]
Staging: rtl8723bs/core: add blank line after declarations

Fix coding style issue.
Add blank line after variable declarations at all the locations found by
checkpatch.pl.

Signed-off-by: Brother Matthew De Angelis <matthew.v.deangelis@gmail.com>
Link: https://lore.kernel.org/r/20201206025945.GA464875@a
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoStaging: rtl8723bs/core: fix brace coding style issue
Brother Matthew De Angelis [Sat, 5 Dec 2020 23:26:13 +0000 (17:26 -0600)]
Staging: rtl8723bs/core: fix brace coding style issue

Remove unnecessary braces identified by checkpatch.pl at lines 740,
1039,1602,1922,1939.

Signed-off-by: Brother Matthew De Angelis <matthew.v.deangelis@gmail.com>
Link: https://lore.kernel.org/r/8ddd195a246696e9315dacfcce06b7ba7f9d7d1a.1607209336.git.matthew.v.deangelis@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoStaging: rtl8723bs/core: delete empty if statement
Brother Matthew De Angelis [Sat, 5 Dec 2020 23:23:14 +0000 (17:23 -0600)]
Staging: rtl8723bs/core: delete empty if statement

Delete an if statement that was not executing anything when true.
This has the side effect of removing one checkpatch warning about braces
not being necessary.

Signed-off-by: Brother Matthew De Angelis <matthew.v.deangelis@gmail.com>
Link: https://lore.kernel.org/r/1895dc8a7b44bfdcb6a46273703fabad80cbdf99.1607209336.git.matthew.v.deangelis@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: bcm2835: fix vchiq_mmal dependencies
Arnd Bergmann [Thu, 3 Dec 2020 22:38:30 +0000 (23:38 +0100)]
staging: bcm2835: fix vchiq_mmal dependencies

When the MMAL code is built-in but the vchiq core config is
set to =m, the mmal code never gets built, which in turn can
lead to link errors:

ERROR: modpost: "vchiq_mmal_port_set_format" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_port_disable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_port_parameter_set" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_component_finalise" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_port_connect_tunnel" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_component_enable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_finalise" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_component_init" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_component_disable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "mmal_vchi_buffer_init" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_port_enable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_version" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_submit_buffer" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_init" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "mmal_vchi_buffer_cleanup" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!
ERROR: modpost: "vchiq_mmal_port_parameter_get" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined!

Change the Kconfig to depend on BCM2835_VCHIQ like the other drivers,
and remove the now redundant dependencies.

Fixes: b18ee53ad297 ("staging: bcm2835: Break MMAL support out from camera")
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20201203223836.1362313-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoStaging: rtl8723bs/core fix brace coding style issues in rtw_ioctl_set.c
Brother Matthew De Angelis [Thu, 3 Dec 2020 02:58:36 +0000 (20:58 -0600)]
Staging: rtl8723bs/core fix brace coding style issues in rtw_ioctl_set.c

Fix all the brace code style warnings found by the checkpatch tool at the following lines:
rtw_ioctl_set.c:178: WARNING: braces {} are not necessary for any arm of this statement
rtw_ioctl_set.c:219: WARNING: braces {} are not necessary for any arm of this statement
rtw_ioctl_set.c:255: WARNING: braces {} are not necessary for any arm of this statement
rtw_ioctl_set.c:324: WARNING: braces {} are not necessary for any arm of this statement
rtw_ioctl_set.c:372: WARNING: braces {} are not necessary for any arm of this statement
rtw_ioctl_set.c:396: WARNING: braces {} are not necessary for any arm of this statement
rtw_ioctl_set.c:441: WARNING: braces {} are not necessary for single statement blocks
rtw_ioctl_set.c:527: WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Brother Matthew De Angelis <matthew.v.deangelis@gmail.com>
Link: https://lore.kernel.org/r/20201203025836.GA420974@a
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoMerge tag 'iio-for-5.11b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git...
Greg Kroah-Hartman [Thu, 3 Dec 2020 21:10:58 +0000 (22:10 +0100)]
Merge tag 'iio-for-5.11b-take2' of https://git./linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

2nd set of IIO device support, features, cleanups and yaml conversions for 5.11

v2: Fix some missing Sign offs from me that Greg found in v1.

Includes low priority/late breaking/long standing bug fixes.

Note this includes the last few patches that were listed in the description
for the previous pull request but weren't actually in the PULL.

New devices support
* bosch,bmc150-accel
  - Support for BMA222, including adding binding doc that was previously
    missing.
* st,lsm6dsx
  - Support LSM6DSOP accelerometer + gyroscope sensor.

yaml-conversions by manufacturer
* core
  - adc
  - iio-binding (drop as now in dt-schema)
  - temperature (drop as not clear it is generic)
* generic (no specific manufacturer)
  - dpot-dac
  - current-sense-amplifier
  - current-sense-shunt
  - envelope-detector
  - voltage-divider
* adi,ad5592r adi,ad7124 adi,ad7292 adi,adf4350
* atmel,sama9260-adc
* bosch,bma180 bosch,bmg180
* brcm,iproc-static-adc
* capella,cm3605
* fsl,mma8452
* kionix,kxcjk1013
* maxim,max1027 (from trivial)
* mediatek,mt2701-auxdac
* microchip,mcp4531 (from trivial)
* qcom,pm8018-adc qcom,spi-iadc
* st,st-sensors
* ti,ads124s08 ti,afe4403 ti,afe4404 ti,lmp91000 ti,palmas-gpadc

Features
* bosch,bmc150
  - Handle unusual ACPI binding where two devices are provided in a single
    ACPI device (BOSC0200).
  - ACPI based mount matrix handling
* st,hts221
  - regulator control
* st,lsm6dsx
  - regulator control

Cleanup + minor fixes
* core
  - Reduce duplication in iio_format_avail_{list,range}() and iio_format_list()
  - Fix an issue in the demux update code that could lead to misaligned data.
    Possible no existing driver hits this. Been there a very long time with
    no bug reports.
  - Improve iio_map_array_register() error handling.
  - Avoid polling driver again if try_reenable() callback returns non 0.
    Only users of this were bugs so also drop the return value.
* core/cb_buffer
  - Return an error if no callback provided (include adding a dummy for one
    unusual case where no callback is valid).
* trigger/hrtimer-trig, sysfs-trig
  - Fix an issue seen with PREEMPT_RT by marking irq_work as expiring in hard
    interrupt context.
* adi,ad_sigma_delta library
  - Avoid putting SPI transfer buffers on stack for DMA safety reasons
* adi,ad5272
  - Fix discrepancy in polarity of reset line between binding documentation
    (which was right) and driver.
* adi,ad7298
  - Use devm for all of probe
* atmel,at91_adc
  - Drop at91_adc_ids as only support DT probe
  - Simplify resolution selection and bindings
  - Drop binding for triggers and move into driver based on compatible.
  - Merge at91_adc_probe_dt() into main at91_adc_probe()
* bosch,bmc150
  - Drop unused structure member.
* bosch,bmi160
  - Fix overly long buffer due to wrong channel count.
  - Fix potential buffer alignment into iio_push_to_buffers_with_timestamp()
* fsl,mag3110
  - Fix potential buffer alignment into iio_push_to_buffers_with_timestamp()
* fsl,mpl3115
  - Fix potential buffer alignment into iio_push_to_buffers_with_timestamp()
* invn,mpu3050
  - Use 64 bit local variable and FIELD_GET to simplify code that extracts
    values from OTP.
* qcom,spmi-vadc
  - Drop wrong use of io-channel-ranges in binding doc.
* rockchip,saradc
  - Fix a missing clk_disable_unprepare() in an error path.
* rohm,rpr0521
  - Fix potential buffer alignment into iio_push_to_buffers_with_timestamp()
* samsung,exynos-adc
  - Drop wrong use of io-channel-ranges in binding doc.
* st,lsm6dsx
  - Reduce duplication in the chip model specific tables.
  - Fix an issue with missed edge-interrupts that can occur when using
    the FIFO.
* st,uvis21
  - Fix potential buffer alignment into iio_push_to_buffers_with_timestamp()
* ti,adc084s021
  - Tidy up endian types to clear a warning.
* ti,ads124s08
  - Fix too long a buffer.
  - Fix potential buffer alignment into iio_push_to_buffers_with_timestamp()

Counter
* microchip,tcb-counter
  - Add Kamel Bouhara to MAINTAINERS
  - Fix CMR value check

* tag 'iio-for-5.11b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (80 commits)
  iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume
  iio: imu: st_lsm6dsx: fix edge-trigger interrupts
  counter: microchip-tcb-capture: Fix CMR value check
  iio: sysfs-trigger: Mark irq_work to expire in hardirq context
  iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context
  iio: accel: bmc150: Get mount-matrix from ACPI
  iio: accel: bmc150: Check for a second ACPI device for BOSC0200
  iio: accel: bmc150: Removed unused bmc150_accel_dat irq member
  iio:gyro:mpu3050 Treat otp value as a __le64 and use FIELD_GET() to break up
  iio:adc:ti-ads124s08: Fix alignment and data leak issues.
  iio:adc:ti-ads124s08: Fix buffer being too long.
  iio:pressure:mpl3115: Force alignment of buffer
  iio:imu:bmi160: Fix alignment and data leak issues
  iio:imu:bmi160: Fix too large a buffer.
  iio:magnetometer:mag3110: Fix alignment and data leak issues.
  iio:light:st_uvis25: Fix timestamp alignment and prevent data leak.
  iio:light:rpr0521: Fix timestamp alignment and prevent data leak.
  iio:adc:ti-adc084s021 Tidy up endian types
  iio:trigger: rename try_reenable() to reenable() plus return void
  iio: Fix: Do not poll the driver again if try_reenable() callback returns non 0.
  ...

3 years agoiio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_s...
Qinglang Miao [Tue, 3 Nov 2020 12:07:43 +0000 (20:07 +0800)]
iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume

Fix the missing clk_disable_unprepare() of info->pclk
before return from rockchip_saradc_resume in the error
handling case when fails to prepare and enable info->clk.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc")
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201103120743.110662-1-miaoqinglang@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: imu: st_lsm6dsx: fix edge-trigger interrupts
Lorenzo Bianconi [Sat, 14 Nov 2020 18:39:05 +0000 (19:39 +0100)]
iio: imu: st_lsm6dsx: fix edge-trigger interrupts

If we are using edge IRQs, new samples can arrive while processing
current interrupt since there are no hw guarantees the irq line
stays "low" long enough to properly detect the new interrupt.
In this case the new sample will be missed.
Polling FIFO status register in st_lsm6dsx_handler_thread routine
allow us to read new samples even if the interrupt arrives while
processing previous data and the timeslot where the line is "low"
is too short to be properly detected.

Fixes: 89ca88a7cdf2 ("iio: imu: st_lsm6dsx: support active-low interrupts")
Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/5e93cda7dc1e665f5685c53ad8e9ea71dbae782d.1605378871.git.lorenzo@kernel.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agocounter: microchip-tcb-capture: Fix CMR value check
William Breathitt Gray [Sat, 14 Nov 2020 23:28:05 +0000 (18:28 -0500)]
counter: microchip-tcb-capture: Fix CMR value check

The ATMEL_TC_ETRGEDG_* defines are not masks but rather possible values
for CMR. This patch fixes the action_get() callback to properly check
for these values rather than mask them.

Fixes: 106b104137fd ("counter: Add microchip TCB capture counter")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Kamel Bouhara <kamel.bouhara@bootlin.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201114232805.253108-1-vilhelm.gray@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: sysfs-trigger: Mark irq_work to expire in hardirq context
Lars-Peter Clausen [Tue, 17 Nov 2020 10:37:51 +0000 (11:37 +0100)]
iio: sysfs-trigger: Mark irq_work to expire in hardirq context

Mark the IIO sysfs-trigger irq_work with IRQ_WORK_HARD_IRQ to ensure that
it is always executed in hard interrupt context, even with PREEMPT_RT=y.

The IIO sysfs-trigger irq_work needs to run in hard interrupt context since
it will end up calling generic_handle_irq() which has the requirement to
run in hard interrupt context.

Note that the IRQ_WORK_HARD_IRQ flag, while it exists, does not seem to do
anything in the mainline kernel yet. It does have an effect in the RT
patchset though and presumably this is sooner or later going to be added to
mainline as well.

Reported-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20201117103751.16131-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context
Lars-Peter Clausen [Tue, 17 Nov 2020 10:37:50 +0000 (11:37 +0100)]
iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context

On PREEMPT_RT enabled kernels unmarked hrtimers are moved into soft
interrupt expiry mode by default.

The IIO hrtimer-trigger needs to run in hard interrupt context since it
will end up calling generic_handle_irq() which has the requirement to run
in hard interrupt context.

Explicitly specify that the timer needs to run in hard interrupt context by
using the HRTIMER_MODE_REL_HARD flag.

Fixes: f5c2f0215e36 ("hrtimer: Move unmarked hrtimers to soft interrupt expiry on RT")
Reported-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20201117103751.16131-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: bmc150: Get mount-matrix from ACPI
Hans de Goede [Mon, 30 Nov 2020 14:19:54 +0000 (15:19 +0100)]
iio: accel: bmc150: Get mount-matrix from ACPI

bmc150 accelerometers with an ACPI hardware-id of BOSC0200 have an ACPI
method providing their mount-matrix, add support for retrieving this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20201130141954.339805-3-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: bmc150: Check for a second ACPI device for BOSC0200
Jeremy Cline [Mon, 30 Nov 2020 14:19:53 +0000 (15:19 +0100)]
iio: accel: bmc150: Check for a second ACPI device for BOSC0200

Some BOSC0200 acpi_device-s describe two accelerometers in a single ACPI
device. Normally we would handle this by letting the special
drivers/platform/x86/i2c-multi-instantiate.c driver handle the BOSC0200
ACPI id and let it instantiate 2 bmc150_accel type i2c_client-s for us.

But doing so changes the modalias for the first accelerometer
(which is already supported and used on many devices) from
acpi:BOSC0200 to i2c:bmc150_accel. The modalias is not only used
to load the driver, but is also used by hwdb matches in
/lib/udev/hwdb.d/60-sensor.hwdb which provide a mountmatrix to
userspace by setting the ACCEL_MOUNT_MATRIX udev property.

Switching the handling of the BOSC0200 over to i2c-multi-instantiate.c
will break the hwdb matches causing the ACCEL_MOUNT_MATRIX udev prop
to no longer be set. So switching over to i2c-multi-instantiate.c is
not an option.

Changes by Hans de Goede:
-Add explanation to the commit message why i2c-multi-instantiate.c
 cannot be used
-Also set the dev_name, fwnode and irq i2c_board_info struct members
 for the 2nd client

Signed-off-by: Jeremy Cline <jeremy@jcline.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20201130141954.339805-2-hdegoede@redhat.com
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=198671
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: bmc150: Removed unused bmc150_accel_dat irq member
Hans de Goede [Mon, 30 Nov 2020 14:19:52 +0000 (15:19 +0100)]
iio: accel: bmc150: Removed unused bmc150_accel_dat irq member

The bmc150_accel_dat struct irq member is only ever used inside
bmc150_accel_core_probe, drop it and just use the function argument
directly.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20201130141954.339805-1-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio:gyro:mpu3050 Treat otp value as a __le64 and use FIELD_GET() to break up
Jonathan Cameron [Sun, 29 Nov 2020 18:44:59 +0000 (18:44 +0000)]
iio:gyro:mpu3050 Treat otp value as a __le64 and use FIELD_GET() to break up

Inspired by Andy Shevchenko's proposal to use get_unaligned_leXX().

The whole one time programable memory is treated as a single 64bit
little endian value.  Thus we can avoid a lot of messy handling
of fields overlapping byte boundaries by just loading and manipulating
it as an __le64 converted to a u64.  That lets us just use FIELD_GET()
and GENMASK() to extract the values desired.

Note only build tested. We need to use GENMASK_ULL and %llX formatters
to account for the larger types used in computing the various fields.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201128185156.428327-1-jic23@kernel.org
Link: https://lore.kernel.org/r/20201129184459.647538-1-jic23@kernel.org
3 years agoiio:adc:ti-ads124s08: Fix alignment and data leak issues.
Jonathan Cameron [Sun, 20 Sep 2020 11:27:42 +0000 (12:27 +0100)]
iio:adc:ti-ads124s08: Fix alignment and data leak issues.

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable structure in the iio_priv() data with alignment
explicitly requested.  This data is allocated with kzalloc() so no
data can leak apart from previous readings.

In this driver the timestamp can end up in various different locations
depending on what other channels are enabled.  As a result, we don't
use a structure to specify it's position as that would be misleading.

Fixes: e717f8c6dfec ("iio: adc: Add the TI ads124s08 ADC code")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-9-jic23@kernel.org
3 years agoiio:adc:ti-ads124s08: Fix buffer being too long.
Jonathan Cameron [Sun, 20 Sep 2020 11:27:41 +0000 (12:27 +0100)]
iio:adc:ti-ads124s08: Fix buffer being too long.

The buffer is expressed as a u32 array, yet the extra space for
the s64 timestamp was expressed as sizeof(s64)/sizeof(u16).
This will result in 2 extra u32 elements.
Fix by dividing by sizeof(u32).

Fixes: e717f8c6dfec ("iio: adc: Add the TI ads124s08 ADC code")
Signed-off-by: Jonathan Cameron<Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-8-jic23@kernel.org
3 years agoiio:pressure:mpl3115: Force alignment of buffer
Jonathan Cameron [Sun, 20 Sep 2020 11:27:40 +0000 (12:27 +0100)]
iio:pressure:mpl3115: Force alignment of buffer

Whilst this is another case of the issue Lars reported with
an array of elements of smaller than 8 bytes being passed
to iio_push_to_buffers_with_timestamp(), the solution here is
a bit different from the other cases and relies on __aligned
working on the stack (true since 4.6?)

This one is unusual.  We have to do an explicit memset() each time
as we are reading 3 bytes into a potential 4 byte channel which
may sometimes be a 2 byte channel depending on what is enabled.
As such, moving the buffer to the heap in the iio_priv structure
doesn't save us much.  We can't use a nice explicit structure
on the stack either as the data channels have different storage
sizes and are all separately controlled.

Fixes: cc26ad455f57 ("iio: Add Freescale MPL3115A2 pressure / temperature sensor driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-7-jic23@kernel.org
3 years agoiio:imu:bmi160: Fix alignment and data leak issues
Jonathan Cameron [Sun, 20 Sep 2020 11:27:39 +0000 (12:27 +0100)]
iio:imu:bmi160: Fix alignment and data leak issues

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable array in the iio_priv() data with alignment
explicitly requested.  This data is allocated with kzalloc() so no
data can leak apart from previous readings.

In this driver, depending on which channels are enabled, the timestamp
can be in a number of locations.  Hence we cannot use a structure
to specify the data layout without it being misleading.

Fixes: 77c4ad2d6a9b ("iio: imu: Add initial support for Bosch BMI160")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-6-jic23@kernel.org
3 years agoiio:imu:bmi160: Fix too large a buffer.
Jonathan Cameron [Sun, 20 Sep 2020 11:27:38 +0000 (12:27 +0100)]
iio:imu:bmi160: Fix too large a buffer.

The comment implies this device has 3 sensor types, but it only
has an accelerometer and a gyroscope (both 3D).  As such the
buffer does not need to be as long as stated.

Note I've separated this from the following patch which fixes
the alignment for passing to iio_push_to_buffers_with_timestamp()
as they are different issues even if they affect the same line
of code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-5-jic23@kernel.org
3 years agoiio:magnetometer:mag3110: Fix alignment and data leak issues.
Jonathan Cameron [Sun, 20 Sep 2020 11:27:37 +0000 (12:27 +0100)]
iio:magnetometer:mag3110: Fix alignment and data leak issues.

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable structure in the iio_priv() data.
This data is allocated with kzalloc() so no data can leak apart from
previous readings.

The explicit alignment of ts is not necessary in this case but
does make the code slightly less fragile so I have included it.

Fixes: 39631b5f9584 ("iio: Add Freescale mag3110 magnetometer driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-4-jic23@kernel.org
3 years agoiio:light:st_uvis25: Fix timestamp alignment and prevent data leak.
Jonathan Cameron [Sun, 20 Sep 2020 11:27:36 +0000 (12:27 +0100)]
iio:light:st_uvis25: Fix timestamp alignment and prevent data leak.

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable structure in the iio_priv()

This data is allocated with kzalloc() so no data can leak apart
from previous readings.

A local unsigned int variable is used for the regmap call so it
is clear there is no potential issue with writing into the padding
of the structure.

Fixes: 3025c8688c1e ("iio: light: add support for UVIS25 sensor")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-3-jic23@kernel.org
3 years agoiio:light:rpr0521: Fix timestamp alignment and prevent data leak.
Jonathan Cameron [Sun, 20 Sep 2020 11:27:35 +0000 (12:27 +0100)]
iio:light:rpr0521: Fix timestamp alignment and prevent data leak.

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable structure in the iio_priv().
This data is allocated with kzalloc() so no data can leak apart
from previous readings and in this case the status byte from the device.

The forced alignment of ts is not necessary in this case but it
potentially makes the code less fragile.

>From personal communications with Mikko:

We could probably split the reading of the int register, but it
would mean a significant performance cost of 20 i2c clock cycles.

Fixes: e12ffd241c00 ("iio: light: rpr0521 triggered buffer")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-2-jic23@kernel.org
3 years agoiio:adc:ti-adc084s021 Tidy up endian types
Jonathan Cameron [Wed, 22 Jul 2020 15:50:58 +0000 (16:50 +0100)]
iio:adc:ti-adc084s021 Tidy up endian types

By adding a few local variables and avoiding a void * for
a parameter we can easily make all the endian types explicit and
get rid of the warnings from sparse:

  CHECK   drivers/iio/adc/ti-adc084s021.c
drivers/iio/adc/ti-adc084s021.c:84:26: warning: incorrect type in assignment (different base types)
drivers/iio/adc/ti-adc084s021.c:84:26:    expected unsigned short [usertype]
drivers/iio/adc/ti-adc084s021.c:84:26:    got restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200722155103.979802-23-jic23@kernel.org
3 years agoiio:trigger: rename try_reenable() to reenable() plus return void
Jonathan Cameron [Sun, 20 Sep 2020 13:25:48 +0000 (14:25 +0100)]
iio:trigger: rename try_reenable() to reenable() plus return void

As we no longer support a try again if we cannot reenable the trigger
rename the function to reflect this.   Also we don't do anything with
the value returned so stop it returning anything.  For the few drivers
that didn't already print an error message in this patch, add such
a print.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Christian Oder <me@myself5.de>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Nishant Malpani <nish.malpani25@gmail.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Link: https://lore.kernel.org/r/20200920132548.196452-3-jic23@kernel.org
3 years agoiio: Fix: Do not poll the driver again if try_reenable() callback returns non 0.
Jonathan Cameron [Sun, 20 Sep 2020 13:25:47 +0000 (14:25 +0100)]
iio: Fix: Do not poll the driver again if try_reenable() callback returns non 0.

The original reason for this behaviour is long gone and no current
drivers are making use of this function correctly. Note however, that
you would be very unlucky to actually hit the problem as it would
require a bus comms failure in the callback.

This dates back a long way.  The original board on which I did a lot
of early IIO development only supported edge interrupts, but some of the
sensors were level interrupt based.  As such, the lis3l02dq driver did
a dance with checking a GPIO to identify if it should retrigger.
That was an unsustainable hack so we later just stopped supporting interrupts
for that particular combination.

There are a number of drivers where a fault on a bus read in the
try_reenable() callback will result in them returning non 0 and
incorrectly then causing iio_trigger_poll() to be called.

Anyhow, this handling is unused and causing issues so let us rip it out.
Link: https://lore.kernel.org/linux-iio/20200813075358.13310-1-lars@metafoo.de/
After this the try_reenable() naming makes no sense, so as a follow up
patch I'll rename it to simply reenable().  I haven't done that here
as it will add noise to the fix for backporting.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Christian Eggers <ceggers@arri.de>
Link: https://lore.kernel.org/r/20200920132548.196452-2-jic23@kernel.org
3 years agoio:core: In iio_map_array_register() cleanup in case of error
Lino Sanfilippo [Sat, 28 Nov 2020 13:44:19 +0000 (14:44 +0100)]
io:core: In iio_map_array_register() cleanup in case of error

In function iio_map_array_register() properly rewind in case of error.

Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1606571059-13974-2-git-send-email-LinoSanfilippo@gmx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio:core: Introduce unlocked version of iio_map_array_unregister()
Lino Sanfilippo [Sat, 28 Nov 2020 13:44:18 +0000 (14:44 +0100)]
iio:core: Introduce unlocked version of iio_map_array_unregister()

Introduce an unlocked version of iio_map_array_unregister(). This function
can help to unwind in case of error while the iio_map_list_lock mutex is
held.

Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1606571059-13974-1-git-send-email-LinoSanfilippo@gmx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: iio: imu: st_lsm6dsx: add lsm6dsop device bindings
Lorenzo Bianconi [Sun, 29 Nov 2020 09:43:07 +0000 (10:43 +0100)]
dt-bindings: iio: imu: st_lsm6dsx: add lsm6dsop device bindings

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/501ff8187d2df584ec978c7e7ec5c445c3d0741c.1606642528.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: imu: st_lsm6dsx: add support to LSM6DSOP
Lorenzo Bianconi [Sun, 29 Nov 2020 09:43:06 +0000 (10:43 +0100)]
iio: imu: st_lsm6dsx: add support to LSM6DSOP

Add support to STM LSM6DSOP (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsop.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/d3c459ad945ccd1a256f4a217128be214b0c024e.1606642528.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: imu: st_lsmdsx: compact st_lsm6dsx_sensor_settings table
Lorenzo Bianconi [Sat, 28 Nov 2020 10:08:01 +0000 (11:08 +0100)]
iio: imu: st_lsmdsx: compact st_lsm6dsx_sensor_settings table

Shrink st_lsm6dsx_sensor_settings table size moving wai address info in
id array and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/c43286938b2fe03ab3abdb5fc095ea6b950abcb1.1606557946.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: at91_adc: merge at91_adc_probe_dt back in at91_adc_probe
Alexandre Belloni [Sat, 28 Nov 2020 22:28:15 +0000 (23:28 +0100)]
iio: adc: at91_adc: merge at91_adc_probe_dt back in at91_adc_probe

at91_adc_probe_dt is now small enough to be merged back in at91_adc_probe.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Link: https://lore.kernel.org/r/20201128222818.1910764-8-alexandre.belloni@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:adc:remove triggers
Alexandre Belloni [Sat, 28 Nov 2020 22:28:14 +0000 (23:28 +0100)]
dt-bindings:iio:adc:remove triggers

The trigger child nodes are not necessary anymore as they are defined
directly by the driver, depending on the compatible string.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Rob Herring <robh+dt@kernel.org>
Link: https://lore.kernel.org/r/20201128222818.1910764-7-alexandre.belloni@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: at91_adc: rework trigger definition
Alexandre Belloni [Sat, 28 Nov 2020 22:28:13 +0000 (23:28 +0100)]
iio: adc: at91_adc: rework trigger definition

Move the available trigger definition back in the driver to stop cluttering
the device tree. There is no functional change except that it actually
fixes the available triggers for at91sam9rl as it inherited the list from
at91sam9260 but actually has the triggers from at91sam9x5.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Link: https://lore.kernel.org/r/20201128222818.1910764-6-alexandre.belloni@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:adc:atmel, sama9260-adc: conversion to yaml from at91_adc.txt
Jonathan Cameron [Sat, 28 Nov 2020 22:28:12 +0000 (23:28 +0100)]
dt-bindings:iio:adc:atmel, sama9260-adc: conversion to yaml from at91_adc.txt

There are a few things we would do differently in an ADC binding if we
were starting from scratch but we are stuck with what we have (which
made sense back when this was written!)

We may be able to tighten up some elements of this binding in the future
by careful checking of what values properties can actually take.

Note the unusual sign off chain is representative of the path this patch
took.

Jonathan wrote the patch, which was then included in a series by
Alexandre and ultimately applied by Jonathan.

[Alexandre Belloni: add sama5d3, remove atmel,adc-res and atmel,adc-res-names]

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20201128222818.1910764-5-alexandre.belloni@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:adc:remove atmel, adc-res and atmel, adc-res-names
Alexandre Belloni [Sat, 28 Nov 2020 22:28:11 +0000 (23:28 +0100)]
dt-bindings:iio:adc:remove atmel, adc-res and atmel, adc-res-names

Remove atmel,adc-res and atmel,adc-res-names as they are not necessary and
are handled by the driver. Also add sama5d3 to the list of possible chips.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Rob Herring <robh+dt@kernel.org>
Link: https://lore.kernel.org/r/20201128222818.1910764-4-alexandre.belloni@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: at91_adc: rework resolution selection
Alexandre Belloni [Sat, 28 Nov 2020 22:28:10 +0000 (23:28 +0100)]
iio: adc: at91_adc: rework resolution selection

Move the possible resolution values back to the driver. This removes the
atmel,adc-res and atmel,adc-res-names properties, leaving only
atmel,adc-use-res. As atmel,adc-res-names had to contain "lowres" and
"highres", those where already the only allowed values for
atmel,adc-use-res.

Also introduce a new compatible string for the sama5d3 as this is the only
one with a different resolution. Also it doesn't even have the LOWRES
bit.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Link: https://lore.kernel.org/r/20201128222818.1910764-3-alexandre.belloni@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: at91_adc: remove at91_adc_ids
Alexandre Belloni [Sat, 28 Nov 2020 22:28:09 +0000 (23:28 +0100)]
iio: adc: at91_adc: remove at91_adc_ids

The driver is DT only since commit ead1c9f376db ("iio: adc: at91_adc:
remove platform data and move defs in driver file"). Remove the leftover
platform_device_id array.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201128222818.1910764-2-alexandre.belloni@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:potentiostat:ti,lmp91000: txt to yaml conversion.
Jonathan Cameron [Sat, 31 Oct 2020 18:12:42 +0000 (18:12 +0000)]
dt-bindings:iio:potentiostat:ti,lmp91000: txt to yaml conversion.

There were a few parts of the example that did not conform to the
binding description and would not have worked with the Linux driver
as a result.  Fixed them whilst doing this conversion.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20201031181242.742301-11-jic23@kernel.org
3 years agodt-bindings:iio:light:capella,cm3605: txt to yaml conversion.
Jonathan Cameron [Sat, 31 Oct 2020 18:12:41 +0000 (18:12 +0000)]
dt-bindings:iio:light:capella,cm3605: txt to yaml conversion.

Simple conversion using the new iio-consumers.yaml binding in the
dt-schema.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201031181242.742301-10-jic23@kernel.org
3 years agodt-bindings:iio:afe:voltage-divider: txt to yaml conversion
Jonathan Cameron [Sat, 31 Oct 2020 18:12:40 +0000 (18:12 +0000)]
dt-bindings:iio:afe:voltage-divider: txt to yaml conversion

Simple binding so straight forward conversion, though did require
adding a separate binding document for the max1027 to reflect
its abilities to provide channels to consumers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20201031181242.742301-9-jic23@kernel.org
3 years agodt-bindings:iio:adc:maxim,max1027: Pull out to separate binding doc.
Jonathan Cameron [Sat, 31 Oct 2020 18:12:39 +0000 (18:12 +0000)]
dt-bindings:iio:adc:maxim,max1027: Pull out to separate binding doc.

The afe/voltage-divider.yaml example uses this device with 2 properties
not provided by trivial-devices.yaml (spi-max-frequency and #io-channel-cells)

Solve that by creating a more specific binding doc.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Philippe Reynes <tremyfr@yahoo.fr>
Link: https://lore.kernel.org/r/20201031181242.742301-8-jic23@kernel.org
3 years agodt-bindings:iio:afe:current-sense-shunt: txt to yaml conversion.
Jonathan Cameron [Sat, 31 Oct 2020 18:12:38 +0000 (18:12 +0000)]
dt-bindings:iio:afe:current-sense-shunt: txt to yaml conversion.

Very simple binding. As such straight forward conversion.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20201031181242.742301-7-jic23@kernel.org
3 years agodt-bindings:iio:afe:current-sense-amplifier: txt to yaml conversion.
Jonathan Cameron [Sat, 31 Oct 2020 18:12:37 +0000 (18:12 +0000)]
dt-bindings:iio:afe:current-sense-amplifier: txt to yaml conversion.

Note this includes a fix in the example where we had *-mul instead of
*-mult.  The binding doc and driver agree that it should be *-mult

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20201031181242.742301-6-jic23@kernel.org
3 years agodt-bindings:iio:adc:envelope-detector: txt to yaml conversion.
Jonathan Cameron [Sat, 31 Oct 2020 18:12:36 +0000 (18:12 +0000)]
dt-bindings:iio:adc:envelope-detector: txt to yaml conversion.

Straight forward format conversion.  The example in here is fun in
that it has 2 separate provider / consumer pairs.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20201031181242.742301-5-jic23@kernel.org
3 years agodt-bindings:iio:potentiometer: give microchip,mcp4531 its own binding
Jonathan Cameron [Sat, 31 Oct 2020 18:12:35 +0000 (18:12 +0000)]
dt-bindings:iio:potentiometer: give microchip,mcp4531 its own binding

We use this part in an example for the envelope detector. That showed
that we need to allow for the #io-channel-cells property which
trivial-devices.yaml does not.

It doesn't make sense to add that property to trivial-devices as
it only applies for those devices that can provide some sort of
DAC or ADC service to another device driver.  Hence solution will
be to pull some IIO devices out to have their own file on a case
by case basis.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20201031181242.742301-4-jic23@kernel.org
3 years agodt-bindings:iio:dac:dpot-dac: yaml conversion.
Jonathan Cameron [Sat, 31 Oct 2020 18:12:34 +0000 (18:12 +0000)]
dt-bindings:iio:dac:dpot-dac: yaml conversion.

Txt to yaml format conversion.  I dropped the example section
describing the measurement ADC, as that isn't strictly part
of this binding.

Uses the new dt-schema/schema/iio/iio-consumer.yaml schema.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20201031181242.742301-3-jic23@kernel.org
3 years agodt-bindings:iio:iio-binding.txt Drop file as content now in dt-schema
Jonathan Cameron [Sat, 31 Oct 2020 18:12:33 +0000 (18:12 +0000)]
dt-bindings:iio:iio-binding.txt Drop file as content now in dt-schema

File contained generic IIO wide bindings.
Now part of the external dt-schema repository.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201031181242.742301-2-jic23@kernel.org
3 years agodt-bindings:iio:adc:adi,ad7292: Use new adc.yaml binding for channels.
Jonathan Cameron [Sat, 31 Oct 2020 18:24:23 +0000 (18:24 +0000)]
dt-bindings:iio:adc:adi,ad7292: Use new adc.yaml binding for channels.

Also add additionalProperties: false for the child nodes.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://lore.kernel.org/r/20201031182423.742798-4-jic23@kernel.org
3 years agodt-bindings:iio:adc:adi,ad7124: Use the new adc.yaml channel binding
Jonathan Cameron [Sat, 31 Oct 2020 18:24:22 +0000 (18:24 +0000)]
dt-bindings:iio:adc:adi,ad7124: Use the new adc.yaml channel binding

This both ensures this binding is compliant with the generic properties
and reduces the amount we need to specify in this separate binding.

Whilst here mark the child node as additionalProperties: false

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Link: https://lore.kernel.org/r/20201031182423.742798-3-jic23@kernel.org
3 years agodt-bindings:iio:adc: convert adc.txt to yaml
Jonathan Cameron [Sat, 31 Oct 2020 18:24:21 +0000 (18:24 +0000)]
dt-bindings:iio:adc: convert adc.txt to yaml

Each driver that uses this will need to use a $ref
We can't always enable it like most of the generic bindings due to
channel@X matching far more widely than IIO.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201031182423.742798-2-jic23@kernel.org
3 years agodt-bindings:iio:health:ti,afe4404: txt to yaml conversion
Jonathan Cameron [Sat, 31 Oct 2020 18:48:16 +0000 (18:48 +0000)]
dt-bindings:iio:health:ti,afe4404: txt to yaml conversion

This basically has same questions as for the afe4403.  We could combine
the two bindings, but as the drivers are separate and it would be a little
fiddly due to different buses let's keep the separating.
To repeat questions from the ti,afe4403 binding.

A few questions came up whilst converting this one.
1) What is actually required?
   - Checking Linux driver, interrupt is not, and the tx-supply could
     be supplied by a stub regulator as long as it's always on.
     As such I have reduced the required list to just compatible and reg.
2) What is the regulator called?
   - It's tx-supply in the binding doc, but the driver request tx_sup
     I will shortly send out a fix for the driver to match the binding
     doc which is the better choice of naming.

As Andrew's email is bouncing, I've put myself as temporary maintainer
for this binding until someone else steps up.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201031184854.745828-9-jic23@kernel.org
3 years agodt-bindings:iio:health:ti,afe4403: txt to yaml binding
Jonathan Cameron [Sat, 31 Oct 2020 18:48:15 +0000 (18:48 +0000)]
dt-bindings:iio:health:ti,afe4403: txt to yaml binding

A few questions came up whilst converting this one.
1) What is actually required?
  - Checking Linux driver, interrupt is not, and the tx-supply could
    be supplied by a stub regulator as long as it's always on.
    As such I have reduced the required list to just compatible and reg.
2) What is the regulator called?
  - It's tx-supply in the binding doc, but the driver requests tx_sup.
    I'll post a fix patch to change the driver to fix this as it makes
    little sense.

Andrew's email is bouncing so until someone else steps up I have
listed myself as maintainer for this binding.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201031184854.745828-8-jic23@kernel.org
3 years agoiio: buffer: Fix demux update
Nuno Sá [Thu, 12 Nov 2020 14:43:22 +0000 (15:43 +0100)]
iio: buffer: Fix demux update

When updating the buffer demux, we will skip a scan element from the
device in the case `in_ind != out_ind` and we enter the while loop.
in_ind should only be refreshed with `find_next_bit()` in the end of the
loop.

Note, to cause problems we need a situation where we are skippig over
an element (channel not enabled) that happens to not have the same size
as the next element.   Whilst this is a possible situation we haven't
actually identified any cases in mainline where it happens as most drivers
have consistent channel storage sizes with the exception of the timestamp
which is the last element and hence never skipped over.

Fixes: 5ada4ea9be16 ("staging:iio: add demux optionally to path from device to buffer")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20201112144323.28887-1-nuno.sa@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: core: Simplify iio_format_list()
Lars-Peter Clausen [Sat, 14 Nov 2020 12:00:00 +0000 (13:00 +0100)]
iio: core: Simplify iio_format_list()

iio_format_list() has two branches in a switch statement that are almost
identical. They only differ in the stride that is used to iterate through
the item list.

Consolidate this into a common code path to simplify the code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201114120000.6533-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: core: Consolidate iio_format_avail_{list,range}()
Lars-Peter Clausen [Sat, 14 Nov 2020 11:59:59 +0000 (12:59 +0100)]
iio: core: Consolidate iio_format_avail_{list,range}()

The iio_format_avail_list() and iio_format_avail_range() functions are
almost identical. The only differences are that iio_format_avail_range()
expects a fixed amount of items and adds brackets "[ ]" around the output.

Refactor them into a common helper function. This improves the
maintainability of the code as it makes it easier to modify the
implementation of these functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201114120000.6533-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:samsung, exynos-adc: drop missuse of io-channel-ranges
Jonathan Cameron [Sun, 15 Nov 2020 19:29:44 +0000 (19:29 +0000)]
dt-bindings:iio:samsung, exynos-adc: drop missuse of io-channel-ranges

io-channel-ranges is a property for consumers of io-channels, not
providers.  Hence it is not relevant in this binding or the examples
given.

Recent changes to dt-schema result in this being reported as an error
as a dependency is enforced between this property and io-channels.

Reported-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20201115192951.1073632-3-jic23@kernel.org
3 years agodt-bindings:iio:qcom-spmi-vadc drop incorrect io-channel-ranges from example
Jonathan Cameron [Sun, 15 Nov 2020 19:29:43 +0000 (19:29 +0000)]
dt-bindings:iio:qcom-spmi-vadc drop incorrect io-channel-ranges from example

io-channel-ranges is a property for io-channel consumers. Here
it is in an example of a provider of channels so doesn't do anything
useful.

Recent additions to dt-schema check this property is only provided
alongside io-channels which is not true here and hence an error is
reported.

Reported-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Andy Gross <agross@kernel.org>
Cc: Jishnu Prakash <jprakash@codeaurora.org>
Link: https://lore.kernel.org/r/20201115192951.1073632-2-jic23@kernel.org
3 years agoiio: potentiometer: ad5272: Correct polarity of reset
Phil Reid [Tue, 24 Nov 2020 05:00:14 +0000 (13:00 +0800)]
iio: potentiometer: ad5272: Correct polarity of reset

The driver should assert reset by setting the gpio high, and
then release it by setting it the gpio low. This allows the
device tree (or other hardware definition) to specify how the
gpio is configured.

For example as open drain or push-pull depending on the
connected hardware.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Link: https://lore.kernel.org/r/20201124050014.4453-1-preid@electromag.com.au
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: bmc150-accel: Add rudimentary regulator support
Linus Walleij [Sun, 15 Nov 2020 20:57:45 +0000 (21:57 +0100)]
iio: accel: bmc150-accel: Add rudimentary regulator support

These Bosch accelerometers have two supplies, VDD and VDDIO.
Add some rudimentary support to obtain and enable these
regulators during probe() and disable them during remove()
or on the errorpath.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201115205745.618455-3-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: bmc150-accel: Add support for BMA222
Linus Walleij [Sun, 15 Nov 2020 20:57:44 +0000 (21:57 +0100)]
iio: accel: bmc150-accel: Add support for BMA222

This adds support for the BMA222 version of this sensor,
found in for example the Samsung GT-I9070 mobile phone.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201115205745.618455-2-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: bmc150-accel: Add DT bindings
Linus Walleij [Sun, 15 Nov 2020 20:57:43 +0000 (21:57 +0100)]
iio: accel: bmc150-accel: Add DT bindings

These accelerometers have bindings used in the kernel and
several device trees but no proper bindings documentation.
Add it.

Also add a compatible for the BMA222 that I am right now
adding support for in the driver.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: devicetree@vger.kernel.org
Link: https://lore.kernel.org/r/20201115205745.618455-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>