linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18
@ 2022-03-15 19:38 William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 1/6] counter: 104-quad-8: Add COMPILE_TEST depends William Breathitt Gray
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: William Breathitt Gray @ 2022-03-15 19:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, linux-iio, William Breathitt Gray

First set of new Counter updates, cleanups, and features for 5.18

Only a few changes this cycle, but we do see the addition of a new
COUNTER_EVENT_CHANGE_OF_STATE event type that allows userspace to watch
counter pulses.

Features
* Add new COUNTER_EVENT_CHANGE_OF_STATE. This adds new counter event to
  notify user space about every new counter pulse. The interrupt-cnt
  driver is the first to use this new feature.

Cleanups
- Add Counter subsystem git tree to MAINTAINERS file.
- Set counter device name. This provides a convenient way to identify
  the counter device in devres_log events and similar situations.
- Add defaults to switch-statements. This pacifies warning messages from
  Clang static analysis reports.

Driver Updates
* 104-quad-8
  - Add COMPILE_TEST depends
* interrupt-cnt
  - Add counter_push_event()

Oleksij Rempel (2):
  counter: add new COUNTER_EVENT_CHANGE_OF_STATE
  counter: interrupt-cnt: add counter_push_event()

Tom Rix (1):
  counter: add defaults to switch-statements

William Breathitt Gray (3):
  counter: 104-quad-8: Add COMPILE_TEST depends
  counter: Set counter device name
  MAINTAINERS: Add Counter subsystem git tree

 MAINTAINERS                      |  1 +
 drivers/counter/Kconfig          |  2 +-
 drivers/counter/counter-chrdev.c |  4 ++++
 drivers/counter/counter-core.c   | 12 +++++++++++-
 drivers/counter/interrupt-cnt.c  |  7 +++++--
 include/uapi/linux/counter.h     |  2 ++
 6 files changed, 24 insertions(+), 4 deletions(-)


base-commit: 7e57714cd0ad2d5bb90e50b5096a0e671dec1ef3
-- 
2.35.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RESEND PATCH 1/6] counter: 104-quad-8: Add COMPILE_TEST depends
  2022-03-15 19:38 [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18 William Breathitt Gray
@ 2022-03-15 19:38 ` William Breathitt Gray
  2022-03-16  7:39   ` Syed Nayyar Waris
  2022-03-15 19:38 ` [RESEND PATCH 2/6] counter: Set counter device name William Breathitt Gray
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: William Breathitt Gray @ 2022-03-15 19:38 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, linux-iio, William Breathitt Gray,
	Uwe Kleine-König, Syed Nayyar Waris

104_QUAD_8 depends on X86, but compiles fine on ARCH=arm. This patch
adds support for COMPILE_TEST which is useful for compile testing code
changes to the driver and Counter subsystem.

Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Syed Nayyar Waris <syednwaris@gmail.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220105094137.259111-1-vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/counter/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/counter/Kconfig b/drivers/counter/Kconfig
index 3dcdb681c4e4..5edd155f1911 100644
--- a/drivers/counter/Kconfig
+++ b/drivers/counter/Kconfig
@@ -14,7 +14,7 @@ if COUNTER
 
 config 104_QUAD_8
 	tristate "ACCES 104-QUAD-8 driver"
-	depends on PC104 && X86
+	depends on (PC104 && X86) || COMPILE_TEST
 	select ISA_BUS_API
 	help
 	  Say yes here to build support for the ACCES 104-QUAD-8 quadrature
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH 2/6] counter: Set counter device name
  2022-03-15 19:38 [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18 William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 1/6] counter: 104-quad-8: Add COMPILE_TEST depends William Breathitt Gray
@ 2022-03-15 19:38 ` William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 3/6] counter: add new COUNTER_EVENT_CHANGE_OF_STATE William Breathitt Gray
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: William Breathitt Gray @ 2022-03-15 19:38 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, linux-iio, William Breathitt Gray, Uwe Kleine-König

Naming the counter device provides a convenient way to identify it in
devres_log events and similar situations. This patch names the counter
device by combining the prefix "counter" with the counter device's
unique ID.

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220204084551.16397-1-vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/counter/counter-core.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c
index 869894b74741..938651f9e9e0 100644
--- a/drivers/counter/counter-core.c
+++ b/drivers/counter/counter-core.c
@@ -22,6 +22,8 @@
 #include "counter-chrdev.h"
 #include "counter-sysfs.h"
 
+#define COUNTER_NAME	"counter"
+
 /* Provides a unique ID for each counter device */
 static DEFINE_IDA(counter_ida);
 
@@ -113,8 +115,15 @@ struct counter_device *counter_alloc(size_t sizeof_priv)
 
 	device_initialize(dev);
 
+	err = dev_set_name(dev, COUNTER_NAME "%d", dev->id);
+	if (err)
+		goto err_dev_set_name;
+
 	return counter;
 
+err_dev_set_name:
+
+	counter_chrdev_remove(counter);
 err_chrdev_add:
 
 	ida_free(&counter_ida, dev->id);
@@ -247,7 +256,8 @@ static int __init counter_init(void)
 	if (err < 0)
 		return err;
 
-	err = alloc_chrdev_region(&counter_devt, 0, COUNTER_DEV_MAX, "counter");
+	err = alloc_chrdev_region(&counter_devt, 0, COUNTER_DEV_MAX,
+				  COUNTER_NAME);
 	if (err < 0)
 		goto err_unregister_bus;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH 3/6] counter: add new COUNTER_EVENT_CHANGE_OF_STATE
  2022-03-15 19:38 [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18 William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 1/6] counter: 104-quad-8: Add COMPILE_TEST depends William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 2/6] counter: Set counter device name William Breathitt Gray
@ 2022-03-15 19:38 ` William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 4/6] counter: interrupt-cnt: add counter_push_event() William Breathitt Gray
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: William Breathitt Gray @ 2022-03-15 19:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, linux-iio, Oleksij Rempel, William Breathitt Gray

From: Oleksij Rempel <o.rempel@pengutronix.de>

Add new counter event to notify user space about every new counter
pulse.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20220203135727.2374052-2-o.rempel@pengutronix.de
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 include/uapi/linux/counter.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/counter.h b/include/uapi/linux/counter.h
index d0aa95aeff7b..96c5ffd368ad 100644
--- a/include/uapi/linux/counter.h
+++ b/include/uapi/linux/counter.h
@@ -61,6 +61,8 @@ enum counter_event_type {
 	COUNTER_EVENT_THRESHOLD,
 	/* Index signal detected */
 	COUNTER_EVENT_INDEX,
+	/* State of counter is changed */
+	COUNTER_EVENT_CHANGE_OF_STATE,
 };
 
 /**
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH 4/6] counter: interrupt-cnt: add counter_push_event()
  2022-03-15 19:38 [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18 William Breathitt Gray
                   ` (2 preceding siblings ...)
  2022-03-15 19:38 ` [RESEND PATCH 3/6] counter: add new COUNTER_EVENT_CHANGE_OF_STATE William Breathitt Gray
@ 2022-03-15 19:38 ` William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 5/6] MAINTAINERS: Add Counter subsystem git tree William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 6/6] counter: add defaults to switch-statements William Breathitt Gray
  5 siblings, 0 replies; 9+ messages in thread
From: William Breathitt Gray @ 2022-03-15 19:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, linux-iio, Oleksij Rempel, William Breathitt Gray

From: Oleksij Rempel <o.rempel@pengutronix.de>

Add counter_push_event() to notify user space about new pulses

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20220203135727.2374052-3-o.rempel@pengutronix.de
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/counter/interrupt-cnt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
index 9e99702470c2..3b13f56bbb11 100644
--- a/drivers/counter/interrupt-cnt.c
+++ b/drivers/counter/interrupt-cnt.c
@@ -26,10 +26,13 @@ struct interrupt_cnt_priv {
 
 static irqreturn_t interrupt_cnt_isr(int irq, void *dev_id)
 {
-	struct interrupt_cnt_priv *priv = dev_id;
+	struct counter_device *counter = dev_id;
+	struct interrupt_cnt_priv *priv = counter_priv(counter);
 
 	atomic_inc(&priv->count);
 
+	counter_push_event(counter, COUNTER_EVENT_CHANGE_OF_STATE, 0);
+
 	return IRQ_HANDLED;
 }
 
@@ -209,7 +212,7 @@ static int interrupt_cnt_probe(struct platform_device *pdev)
 	irq_set_status_flags(priv->irq, IRQ_NOAUTOEN);
 	ret = devm_request_irq(dev, priv->irq, interrupt_cnt_isr,
 			       IRQF_TRIGGER_RISING | IRQF_NO_THREAD,
-			       dev_name(dev), priv);
+			       dev_name(dev), counter);
 	if (ret)
 		return ret;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH 5/6] MAINTAINERS: Add Counter subsystem git tree
  2022-03-15 19:38 [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18 William Breathitt Gray
                   ` (3 preceding siblings ...)
  2022-03-15 19:38 ` [RESEND PATCH 4/6] counter: interrupt-cnt: add counter_push_event() William Breathitt Gray
@ 2022-03-15 19:38 ` William Breathitt Gray
  2022-03-15 19:38 ` [RESEND PATCH 6/6] counter: add defaults to switch-statements William Breathitt Gray
  5 siblings, 0 replies; 9+ messages in thread
From: William Breathitt Gray @ 2022-03-15 19:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, linux-iio, William Breathitt Gray

The Counter subsystem tree is now separate from the IIO tree.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 1ba1e4af2cbc..f4875a9faa2d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4951,6 +4951,7 @@ COUNTER SUBSYSTEM
 M:	William Breathitt Gray <vilhelm.gray@gmail.com>
 L:	linux-iio@vger.kernel.org
 S:	Maintained
+T:	git git@gitlab.com:vilhelmgray/counter.git
 F:	Documentation/ABI/testing/sysfs-bus-counter
 F:	Documentation/driver-api/generic-counter.rst
 F:	drivers/counter/
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND PATCH 6/6] counter: add defaults to switch-statements
  2022-03-15 19:38 [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18 William Breathitt Gray
                   ` (4 preceding siblings ...)
  2022-03-15 19:38 ` [RESEND PATCH 5/6] MAINTAINERS: Add Counter subsystem git tree William Breathitt Gray
@ 2022-03-15 19:38 ` William Breathitt Gray
  2022-03-16  7:37   ` Syed Nayyar Waris
  5 siblings, 1 reply; 9+ messages in thread
From: William Breathitt Gray @ 2022-03-15 19:38 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, linux-iio, Tom Rix, Jonathan Cameron,
	William Breathitt Gray

From: Tom Rix <trix@redhat.com>

Clang static analysis reports this representative problem
counter-chrdev.c:482:3: warning: Undefined or garbage value
  returned to caller
  return ret;
  ^~~~~~~~~~

counter_get_data() has a multilevel switches, some without
defaults, so ret is sometimes not set.
Add returning -EINVAL similar to other defaults.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220227161746.82776-1-trix@redhat.com
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/counter/counter-chrdev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
index b7c62f957a6a..69d340be9c93 100644
--- a/drivers/counter/counter-chrdev.c
+++ b/drivers/counter/counter-chrdev.c
@@ -477,6 +477,8 @@ static int counter_get_data(struct counter_device *const counter,
 		case COUNTER_SCOPE_COUNT:
 			ret = comp->count_u8_read(counter, parent, &value_u8);
 			break;
+		default:
+			return -EINVAL;
 		}
 		*value = value_u8;
 		return ret;
@@ -496,6 +498,8 @@ static int counter_get_data(struct counter_device *const counter,
 		case COUNTER_SCOPE_COUNT:
 			ret = comp->count_u32_read(counter, parent, &value_u32);
 			break;
+		default:
+			return -EINVAL;
 		}
 		*value = value_u32;
 		return ret;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RESEND PATCH 6/6] counter: add defaults to switch-statements
  2022-03-15 19:38 ` [RESEND PATCH 6/6] counter: add defaults to switch-statements William Breathitt Gray
@ 2022-03-16  7:37   ` Syed Nayyar Waris
  0 siblings, 0 replies; 9+ messages in thread
From: Syed Nayyar Waris @ 2022-03-16  7:37 UTC (permalink / raw)
  To: William Breathitt Gray
  Cc: gregkh, Linux Kernel Mailing List, linux-iio, Tom Rix, Jonathan Cameron

On Wed, Mar 16, 2022 at 12:43 PM William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:
>
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this representative problem
> counter-chrdev.c:482:3: warning: Undefined or garbage value
>   returned to caller
>   return ret;
>   ^~~~~~~~~~
>
> counter_get_data() has a multilevel switches, some without
> defaults, so ret is sometimes not set.
> Add returning -EINVAL similar to other defaults.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Link: https://lore.kernel.org/r/20220227161746.82776-1-trix@redhat.com
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> ---
>  drivers/counter/counter-chrdev.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
> index b7c62f957a6a..69d340be9c93 100644
> --- a/drivers/counter/counter-chrdev.c
> +++ b/drivers/counter/counter-chrdev.c
> @@ -477,6 +477,8 @@ static int counter_get_data(struct counter_device *const counter,
>                 case COUNTER_SCOPE_COUNT:
>                         ret = comp->count_u8_read(counter, parent, &value_u8);
>                         break;
> +               default:
> +                       return -EINVAL;
>                 }
>                 *value = value_u8;
>                 return ret;
> @@ -496,6 +498,8 @@ static int counter_get_data(struct counter_device *const counter,
>                 case COUNTER_SCOPE_COUNT:
>                         ret = comp->count_u32_read(counter, parent, &value_u32);
>                         break;
> +               default:
> +                       return -EINVAL;
>                 }
>                 *value = value_u32;
>                 return ret;
> --
> 2.35.1
>

Acked-by: Syed Nayyar Waris <syednwaris@gmail.com>

Thanks

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND PATCH 1/6] counter: 104-quad-8: Add COMPILE_TEST depends
  2022-03-15 19:38 ` [RESEND PATCH 1/6] counter: 104-quad-8: Add COMPILE_TEST depends William Breathitt Gray
@ 2022-03-16  7:39   ` Syed Nayyar Waris
  0 siblings, 0 replies; 9+ messages in thread
From: Syed Nayyar Waris @ 2022-03-16  7:39 UTC (permalink / raw)
  To: William Breathitt Gray
  Cc: gregkh, Linux Kernel Mailing List, linux-iio, Uwe Kleine-König

On Wed, Mar 16, 2022 at 1:09 AM William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:
>
> 104_QUAD_8 depends on X86, but compiles fine on ARCH=arm. This patch
> adds support for COMPILE_TEST which is useful for compile testing code
> changes to the driver and Counter subsystem.
>
> Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Syed Nayyar Waris <syednwaris@gmail.com>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Link: https://lore.kernel.org/r/20220105094137.259111-1-vilhelm.gray@gmail.com
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> ---
>  drivers/counter/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/counter/Kconfig b/drivers/counter/Kconfig
> index 3dcdb681c4e4..5edd155f1911 100644
> --- a/drivers/counter/Kconfig
> +++ b/drivers/counter/Kconfig
> @@ -14,7 +14,7 @@ if COUNTER
>
>  config 104_QUAD_8
>         tristate "ACCES 104-QUAD-8 driver"
> -       depends on PC104 && X86
> +       depends on (PC104 && X86) || COMPILE_TEST
>         select ISA_BUS_API
>         help
>           Say yes here to build support for the ACCES 104-QUAD-8 quadrature
> --
> 2.35.1
>

Acked-by: Syed Nayyar Waris <syednwaris@gmail.com>

Thanks

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-03-16  7:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 19:38 [RESEND PATCH 0/6] Counter updates, cleanups, and features for 5.18 William Breathitt Gray
2022-03-15 19:38 ` [RESEND PATCH 1/6] counter: 104-quad-8: Add COMPILE_TEST depends William Breathitt Gray
2022-03-16  7:39   ` Syed Nayyar Waris
2022-03-15 19:38 ` [RESEND PATCH 2/6] counter: Set counter device name William Breathitt Gray
2022-03-15 19:38 ` [RESEND PATCH 3/6] counter: add new COUNTER_EVENT_CHANGE_OF_STATE William Breathitt Gray
2022-03-15 19:38 ` [RESEND PATCH 4/6] counter: interrupt-cnt: add counter_push_event() William Breathitt Gray
2022-03-15 19:38 ` [RESEND PATCH 5/6] MAINTAINERS: Add Counter subsystem git tree William Breathitt Gray
2022-03-15 19:38 ` [RESEND PATCH 6/6] counter: add defaults to switch-statements William Breathitt Gray
2022-03-16  7:37   ` Syed Nayyar Waris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).