All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
To: Loic Poulain <loic.poulain@linaro.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org
Subject: [PATCH 03/10] net: wwan: make WWAN_PORT_MAX meaning less surprised
Date: Tue,  8 Jun 2021 07:02:34 +0300	[thread overview]
Message-ID: <20210608040241.10658-4-ryazanov.s.a@gmail.com> (raw)
In-Reply-To: <20210608040241.10658-1-ryazanov.s.a@gmail.com>

It is quite unusual when some value can not be equal to a defined range
max value. Also most subsystems defines FOO_TYPE_MAX as a maximum valid
value. So turn the WAN_PORT_MAX meaning from the number of supported
port types to the maximum valid port type.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 drivers/net/wwan/wwan_core.c |  2 +-
 include/linux/wwan.h         | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
index 6e8f19c71a9e..632ff86398ac 100644
--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -250,7 +250,7 @@ struct wwan_port *wwan_create_port(struct device *parent,
 	struct wwan_port *port;
 	int minor, err = -ENOMEM;
 
-	if (type >= WWAN_PORT_MAX || !ops)
+	if (type > WWAN_PORT_MAX || !ops)
 		return ERR_PTR(-EINVAL);
 
 	/* A port is always a child of a WWAN device, retrieve (allocate or
diff --git a/include/linux/wwan.h b/include/linux/wwan.h
index 7216c114d758..fa33cc16d931 100644
--- a/include/linux/wwan.h
+++ b/include/linux/wwan.h
@@ -15,8 +15,10 @@
  * @WWAN_PORT_QMI: Qcom modem/MSM interface for modem control
  * @WWAN_PORT_QCDM: Qcom Modem diagnostic interface
  * @WWAN_PORT_FIREHOSE: XML based command protocol
- * @WWAN_PORT_UNKNOWN: Unknown port type
- * @WWAN_PORT_MAX: Number of supported port types
+ *
+ * @WWAN_PORT_MAX: Highest supported port types
+ * @WWAN_PORT_UNKNOWN: Special value to indicate an unknown port type
+ * @__WWAN_PORT_MAX: Internal use
  */
 enum wwan_port_type {
 	WWAN_PORT_AT,
@@ -24,8 +26,12 @@ enum wwan_port_type {
 	WWAN_PORT_QMI,
 	WWAN_PORT_QCDM,
 	WWAN_PORT_FIREHOSE,
+
+	/* Add new port types above this line */
+
+	__WWAN_PORT_MAX,
+	WWAN_PORT_MAX = __WWAN_PORT_MAX - 1,
 	WWAN_PORT_UNKNOWN,
-	WWAN_PORT_MAX = WWAN_PORT_UNKNOWN,
 };
 
 struct wwan_port;
-- 
2.26.3


  parent reply	other threads:[~2021-06-08  4:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08  4:02 [PATCH 00/10] net: WWAN subsystem improvements Sergey Ryazanov
2021-06-08  4:02 ` [PATCH 01/10] wwan_hwsim: WWAN device simulator Sergey Ryazanov
2021-06-08  4:02 ` [PATCH 02/10] wwan_hwsim: add debugfs management interface Sergey Ryazanov
2021-06-08  4:02 ` Sergey Ryazanov [this message]
2021-06-08  8:35   ` [PATCH 03/10] net: wwan: make WWAN_PORT_MAX meaning less surprised Loic Poulain
2021-06-08  4:02 ` [PATCH 04/10] net: wwan: core: init port type string array using enum values Sergey Ryazanov
2021-06-08  8:36   ` Loic Poulain
2021-06-08  4:02 ` [PATCH 05/10] net: wwan: core: spell port device name in lowercase Sergey Ryazanov
2021-06-08  8:37   ` Loic Poulain
2021-06-08  4:02 ` [PATCH 06/10] net: wwan: core: make port names more user-friendly Sergey Ryazanov
2021-06-08  4:02 ` [PATCH 07/10] net: wwan: core: expand ports number limit Sergey Ryazanov
2021-06-08  8:47   ` Loic Poulain
2021-06-08  4:02 ` [PATCH 08/10] net: wwan: core: implement TIOCINQ ioctl Sergey Ryazanov
2021-06-08  8:51   ` Loic Poulain
2021-06-08  4:02 ` [PATCH 09/10] net: wwan: core: implement terminal ioctls for AT port Sergey Ryazanov
2021-06-08  4:02 ` [PATCH 10/10] net: wwan: core: purge rx queue on port close Sergey Ryazanov
2021-06-08 21:50 ` [PATCH 00/10] net: WWAN subsystem improvements patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608040241.10658-4-ryazanov.s.a@gmail.com \
    --to=ryazanov.s.a@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.