Re: [PATCH] counter: stm32-lptimer-cnt: remove iio counter abi

2021-01-23 Thread William Breathitt Gray
On Fri, Jan 22, 2021 at 04:03:23PM +0100, Fabrice Gasnier wrote:
> Currently, the STM32 LP Timer counter driver registers into both IIO and
> counter subsystems, which is redundant.
> 
> Remove the IIO counter ABI and IIO registration from the STM32 LP Timer
> counter driver since it's been superseded by the Counter subsystem
> as discussed in [1].
> 
> Keep only the counter subsystem related part.
> Move a part of the ABI documentation into a driver comment.
> 
> This also removes a duplicate ABI warning
> $ scripts/get_abi.pl validate
> ...
> /sys/bus/iio/devices/iio:deviceX/in_count0_preset is defined 2 times:
>   ./Documentation/ABI/testing/sysfs-bus-iio-timer-stm32:100
>   ./Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32:0
> 
> [1] https://lkml.org/lkml/2021/1/19/347
> 
> Signed-off-by: Fabrice Gasnier 

Acked-by: William Breathitt Gray 

I'll also submit a patchset removing the IIO code from the 104-quad-8
driver and the rest of the IIO counter ABI documentation.

William Breathitt Gray


signature.asc
Description: PGP signature


[PATCH] counter: stm32-lptimer-cnt: remove iio counter abi

2021-01-22 Thread Fabrice Gasnier
Currently, the STM32 LP Timer counter driver registers into both IIO and
counter subsystems, which is redundant.

Remove the IIO counter ABI and IIO registration from the STM32 LP Timer
counter driver since it's been superseded by the Counter subsystem
as discussed in [1].

Keep only the counter subsystem related part.
Move a part of the ABI documentation into a driver comment.

This also removes a duplicate ABI warning
$ scripts/get_abi.pl validate
...
/sys/bus/iio/devices/iio:deviceX/in_count0_preset is defined 2 times:
  ./Documentation/ABI/testing/sysfs-bus-iio-timer-stm32:100
  ./Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32:0

[1] https://lkml.org/lkml/2021/1/19/347

Signed-off-by: Fabrice Gasnier 
---
 .../ABI/testing/sysfs-bus-iio-lptimer-stm32|  62 -
 drivers/counter/stm32-lptimer-cnt.c| 297 +++--
 2 files changed, 36 insertions(+), 323 deletions(-)
 delete mode 100644 Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32

diff --git a/Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32 
b/Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32
deleted file mode 100644
index 73498ff..
--- a/Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32
+++ /dev/null
@@ -1,62 +0,0 @@
-What:  /sys/bus/iio/devices/iio:deviceX/in_count0_preset
-KernelVersion: 4.13
-Contact:   fabrice.gasn...@st.com
-Description:
-   Reading returns the current preset value. Writing sets the
-   preset value. Encoder counts continuously from 0 to preset
-   value, depending on direction (up/down).
-
-What:  
/sys/bus/iio/devices/iio:deviceX/in_count_quadrature_mode_available
-KernelVersion: 4.13
-Contact:   fabrice.gasn...@st.com
-Description:
-   Reading returns the list possible quadrature modes.
-
-What:  /sys/bus/iio/devices/iio:deviceX/in_count0_quadrature_mode
-KernelVersion: 4.13
-Contact:   fabrice.gasn...@st.com
-Description:
-   Configure the device counter quadrature modes:
-
-   - non-quadrature:
-   Encoder IN1 input servers as the count input (up
-   direction).
-
-   - quadrature:
-   Encoder IN1 and IN2 inputs are mixed to get direction
-   and count.
-
-What:  /sys/bus/iio/devices/iio:deviceX/in_count_polarity_available
-KernelVersion: 4.13
-Contact:   fabrice.gasn...@st.com
-Description:
-   Reading returns the list possible active edges.
-
-What:  /sys/bus/iio/devices/iio:deviceX/in_count0_polarity
-KernelVersion: 4.13
-Contact:   fabrice.gasn...@st.com
-Description:
-   Configure the device encoder/counter active edge:
-
-   - rising-edge
-   - falling-edge
-   - both-edges
-
-   In non-quadrature mode, device counts up on active edge.
-
-   In quadrature mode, encoder counting scenarios are as follows:
-
-   +-+--+++
-   | Active  | Level on |  IN1 signal| IN2 signal |
-   | edge| opposite +--+-+--+-+
-   | | signal   |  Rising  | Falling |  Rising  | Falling |
-   +-+--+--+-+--+-+
-   | Rising  | High ->  |   Down   |-|   Up |-|
-   | edge| Low  ->  |   Up |-|   Down   |-|
-   +-+--+--+-+--+-+
-   | Falling | High ->  |- |   Up|- |   Down  |
-   | edge| Low  ->  |- |   Down  |- |   Up|
-   +-+--+--+-+--+-+
-   | Both| High ->  |   Down   |   Up|   Up |   Down  |
-   | edges   | Low  ->  |   Up |   Down  |   Down   |   Up|
-   +-+--+--+-+--+-+
diff --git a/drivers/counter/stm32-lptimer-cnt.c 
b/drivers/counter/stm32-lptimer-cnt.c
index fd6828e..9374396 100644
--- a/drivers/counter/stm32-lptimer-cnt.c
+++ b/drivers/counter/stm32-lptimer-cnt.c
@@ -12,8 +12,8 @@
 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -107,249 +107,27 @@ static int stm32_lptim_setup(struct stm32_lptim_cnt 
*priv, int enable)
return regmap_update_bits(priv->regmap, STM32_LPTIM_CFGR, mask, val);
 }
 
-static int stm32_lptim_write_raw(struct iio_dev *indio_dev,
-struct iio_chan_spec const *chan,
-int val, int val2, long mask)
-{
-   struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
-   int ret;
-
-   switch (mask) {
-   case IIO_CHAN_INFO_ENABLE:
-   if (val <