net: wwan: core: make port names more user-friendly
authorSergey Ryazanov <ryazanov.s.a@gmail.com>
Tue, 8 Jun 2021 04:02:37 +0000 (07:02 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Jun 2021 21:33:43 +0000 (14:33 -0700)
commitf458709ff40b0d992fec496952f79c7820dd3fde
tree89efba33e82c0c10e11872c4d4c502c1906dce59
parent392c26f7f133b9f09e5f58db1ce6ef4b3b4df49f
net: wwan: core: make port names more user-friendly

At the moment, the port name is allocated based on the parent device
name, port id and the port type. Where the port id specifies nothing but
the ports registration order and is only used to make the port name
unique.

Most likely, to configure a WWAN device, the user will look for a port
of a specific type (e.g. AT port or MBIM port, etc.). The current naming
scheme can make it difficult to find a port of a specific type.

Consider a WWAN device that has 3 ports: AT port, MBIM port, and another
one AT port. With the global port index, the port names will be:
* wwan0p1at
* wwan0p2mbim
* wwan0p3at

To find the MBIM port, user should know in advance the device ports
composition (i.e. the user should know that the MBIM port is the 2nd
one) or carefully examine the whole ports list. It is not unusual for
USB modems to have a different composition, even if they are build on a
same chipset. Moreover, some modems able to change the ports composition
based on the user's configuration. All this makes port names fully
unpredictable.

To make naming more user-friendly, remove the global port id and
enumerate ports by its type. E.g.:
* wwan0p1at   -> wwan0at0
* wwan0p2mbim -> wwan0mbim0
* wwan0p3at   -> wwan0at1

With this naming scheme, the first AT port name will always be wwanXat0,
the first MBIM port name will always be wwanXmbim0, etc.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wwan/wwan_core.c