Message ID | 20210608040241.10658-6-ryazanov.s.a@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 392c26f7f133b9f09e5f58db1ce6ef4b3b4df49f |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: WWAN subsystem improvements | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | warning | Target tree name not specified in the subject |
netdev/cc_maintainers | warning | 1 maintainers not CCed: leon@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 52 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On Tue, 8 Jun 2021 at 06:02, Sergey Ryazanov <ryazanov.s.a@gmail.com> wrote: > > Usually a device name is spelled in lowercase, let us follow this > practice in the WWAN subsystem as well. The bottom line is that such > name is easier to type. > > To keep the device type attribute contents more natural (i.e., spell > abbreviations in uppercase), while making the device name lowercase, > turn the port type strings array to an array of structure that contains > both the port type name and the device name suffix. > > Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c index 97d77b06d222..ba4392d71b80 100644 --- a/drivers/net/wwan/wwan_core.c +++ b/drivers/net/wwan/wwan_core.c @@ -184,12 +184,30 @@ static void wwan_remove_dev(struct wwan_device *wwandev) /* ------- WWAN port management ------- */ -static const char * const wwan_port_type_str[WWAN_PORT_MAX + 1] = { - [WWAN_PORT_AT] = "AT", - [WWAN_PORT_MBIM] = "MBIM", - [WWAN_PORT_QMI] = "QMI", - [WWAN_PORT_QCDM] = "QCDM", - [WWAN_PORT_FIREHOSE] = "FIREHOSE", +static const struct { + const char * const name; /* Port type name */ + const char * const devsuf; /* Port devce name suffix */ +} wwan_port_types[WWAN_PORT_MAX + 1] = { + [WWAN_PORT_AT] = { + .name = "AT", + .devsuf = "at", + }, + [WWAN_PORT_MBIM] = { + .name = "MBIM", + .devsuf = "mbim", + }, + [WWAN_PORT_QMI] = { + .name = "QMI", + .devsuf = "qmi", + }, + [WWAN_PORT_QCDM] = { + .name = "QCDM", + .devsuf = "qcdm", + }, + [WWAN_PORT_FIREHOSE] = { + .name = "FIREHOSE", + .devsuf = "firehose", + }, }; static ssize_t type_show(struct device *dev, struct device_attribute *attr, @@ -197,7 +215,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, { struct wwan_port *port = to_wwan_port(dev); - return sprintf(buf, "%s\n", wwan_port_type_str[port->type]); + return sprintf(buf, "%s\n", wwan_port_types[port->type].name); } static DEVICE_ATTR_RO(type); @@ -285,7 +303,7 @@ struct wwan_port *wwan_create_port(struct device *parent, /* create unique name based on wwan device id, port index and type */ dev_set_name(&port->dev, "wwan%up%u%s", wwandev->id, atomic_inc_return(&wwandev->port_id), - wwan_port_type_str[port->type]); + wwan_port_types[port->type].devsuf); err = device_register(&port->dev); if (err)
Usually a device name is spelled in lowercase, let us follow this practice in the WWAN subsystem as well. The bottom line is that such name is easier to type. To keep the device type attribute contents more natural (i.e., spell abbreviations in uppercase), while making the device name lowercase, turn the port type strings array to an array of structure that contains both the port type name and the device name suffix. Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> --- drivers/net/wwan/wwan_core.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)