Skip to content

Commit

Permalink
net: wwan: make WWAN_PORT_MAX meaning less surprised
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sergey Ryazanov authored and David S. Miller committed Jun 8, 2021
1 parent 9ee23f4 commit b64d76b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wwan/wwan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions include/linux/wwan.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@
* @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,
WWAN_PORT_MBIM,
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;
Expand Down

0 comments on commit b64d76b

Please sign in to comment.