* [PATCH net] net: wwan: Add WWAN port type attribute
@ 2021-05-17 9:53 Loic Poulain
2021-05-17 22:50 ` patchwork-bot+netdevbpf
2021-05-17 23:43 ` Sergey Ryazanov
0 siblings, 2 replies; 4+ messages in thread
From: Loic Poulain @ 2021-05-17 9:53 UTC (permalink / raw)
To: kuba, davem; +Cc: netdev, dcbw, aleksander, Loic Poulain
The port type is by default part of the WWAN port device name.
However device name can not be considered as a 'stable' API and
may be subject to change in the future. This change adds a proper
device attribute that can be used to determine the WWAN protocol/
type.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
drivers/net/wwan/wwan_core.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
index cff04e5..92a8a6f 100644
--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -169,6 +169,30 @@ static void wwan_remove_dev(struct wwan_device *wwandev)
/* ------- WWAN port management ------- */
+/* Keep aligned with wwan_port_type enum */
+static const char * const wwan_port_type_str[] = {
+ "AT",
+ "MBIM",
+ "QMI",
+ "QCDM",
+ "FIREHOSE"
+};
+
+static ssize_t type_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct wwan_port *port = to_wwan_port(dev);
+
+ return sprintf(buf, "%s\n", wwan_port_type_str[port->type]);
+}
+static DEVICE_ATTR_RO(type);
+
+static struct attribute *wwan_port_attrs[] = {
+ &dev_attr_type.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(wwan_port);
+
static void wwan_port_destroy(struct device *dev)
{
struct wwan_port *port = to_wwan_port(dev);
@@ -182,6 +206,7 @@ static void wwan_port_destroy(struct device *dev)
static const struct device_type wwan_port_dev_type = {
.name = "wwan_port",
.release = wwan_port_destroy,
+ .groups = wwan_port_groups,
};
static int wwan_port_minor_match(struct device *dev, const void *minor)
@@ -201,15 +226,6 @@ static struct wwan_port *wwan_port_get_by_minor(unsigned int minor)
return to_wwan_port(dev);
}
-/* Keep aligned with wwan_port_type enum */
-static const char * const wwan_port_type_str[] = {
- "AT",
- "MBIM",
- "QMI",
- "QCDM",
- "FIREHOSE"
-};
-
struct wwan_port *wwan_create_port(struct device *parent,
enum wwan_port_type type,
const struct wwan_port_ops *ops,
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: wwan: Add WWAN port type attribute
2021-05-17 9:53 [PATCH net] net: wwan: Add WWAN port type attribute Loic Poulain
@ 2021-05-17 22:50 ` patchwork-bot+netdevbpf
2021-05-17 23:43 ` Sergey Ryazanov
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-17 22:50 UTC (permalink / raw)
To: Loic Poulain; +Cc: kuba, davem, netdev, dcbw, aleksander
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Mon, 17 May 2021 11:53:34 +0200 you wrote:
> The port type is by default part of the WWAN port device name.
> However device name can not be considered as a 'stable' API and
> may be subject to change in the future. This change adds a proper
> device attribute that can be used to determine the WWAN protocol/
> type.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
>
> [...]
Here is the summary with links:
- [net] net: wwan: Add WWAN port type attribute
https://git.kernel.org/netdev/net-next/c/b3e22e10fdda
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: wwan: Add WWAN port type attribute
2021-05-17 9:53 [PATCH net] net: wwan: Add WWAN port type attribute Loic Poulain
2021-05-17 22:50 ` patchwork-bot+netdevbpf
@ 2021-05-17 23:43 ` Sergey Ryazanov
2021-05-18 10:31 ` Loic Poulain
1 sibling, 1 reply; 4+ messages in thread
From: Sergey Ryazanov @ 2021-05-17 23:43 UTC (permalink / raw)
To: Loic Poulain; +Cc: Jakub Kicinski, David Miller, netdev, dcbw, aleksander
Hello Loic,
On Mon, May 17, 2021 at 12:48 PM Loic Poulain <loic.poulain@linaro.org> wrote:
> The port type is by default part of the WWAN port device name.
> However device name can not be considered as a 'stable' API and
> may be subject to change in the future. This change adds a proper
> device attribute that can be used to determine the WWAN protocol/
> type.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
> drivers/net/wwan/wwan_core.c | 34 +++++++++++++++++++++++++---------
> 1 file changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
> index cff04e5..92a8a6f 100644
> --- a/drivers/net/wwan/wwan_core.c
> +++ b/drivers/net/wwan/wwan_core.c
> @@ -169,6 +169,30 @@ static void wwan_remove_dev(struct wwan_device *wwandev)
>
> /* ------- WWAN port management ------- */
>
> +/* Keep aligned with wwan_port_type enum */
> +static const char * const wwan_port_type_str[] = {
> + "AT",
> + "MBIM",
> + "QMI",
> + "QCDM",
> + "FIREHOSE"
> +};
A small nitpick, maybe this array should be defined in a such way:
static const char * const wwan_port_type_str[WWAN_PORT_MAX] = {
[WWAN_PORT_AT] = "AT",
[WWAN_PORT_MBIM] = "MBIM",
[WWAN_PORT_QMI] = "QMI",
[WWAN_PORT_QCDM] = "QCDM",
[WWAN_PORT_FIREHOSE] = "FIREHOSE",
};
So the array index will be clear without additional notes.
--
Sergey
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: wwan: Add WWAN port type attribute
2021-05-17 23:43 ` Sergey Ryazanov
@ 2021-05-18 10:31 ` Loic Poulain
0 siblings, 0 replies; 4+ messages in thread
From: Loic Poulain @ 2021-05-18 10:31 UTC (permalink / raw)
To: Sergey Ryazanov
Cc: Jakub Kicinski, David Miller, Network Development, dcbw,
Aleksander Morgado
Hi Sergey,
On Tue, 18 May 2021 at 01:44, Sergey Ryazanov <ryazanov.s.a@gmail.com> wrote:
>
> Hello Loic,
>
> On Mon, May 17, 2021 at 12:48 PM Loic Poulain <loic.poulain@linaro.org> wrote:
> > The port type is by default part of the WWAN port device name.
> > However device name can not be considered as a 'stable' API and
> > may be subject to change in the future. This change adds a proper
> > device attribute that can be used to determine the WWAN protocol/
> > type.
> >
> > Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> > ---
> > drivers/net/wwan/wwan_core.c | 34 +++++++++++++++++++++++++---------
> > 1 file changed, 25 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
> > index cff04e5..92a8a6f 100644
> > --- a/drivers/net/wwan/wwan_core.c
> > +++ b/drivers/net/wwan/wwan_core.c
> > @@ -169,6 +169,30 @@ static void wwan_remove_dev(struct wwan_device *wwandev)
> >
> > /* ------- WWAN port management ------- */
> >
> > +/* Keep aligned with wwan_port_type enum */
> > +static const char * const wwan_port_type_str[] = {
> > + "AT",
> > + "MBIM",
> > + "QMI",
> > + "QCDM",
> > + "FIREHOSE"
> > +};
>
> A small nitpick, maybe this array should be defined in a such way:
>
> static const char * const wwan_port_type_str[WWAN_PORT_MAX] = {
> [WWAN_PORT_AT] = "AT",
> [WWAN_PORT_MBIM] = "MBIM",
> [WWAN_PORT_QMI] = "QMI",
> [WWAN_PORT_QCDM] = "QCDM",
> [WWAN_PORT_FIREHOSE] = "FIREHOSE",
> };
>
> So the array index will be clear without additional notes.
You're right, it would indeed be more robust.
I'll submit that change in a subsequent patch.
Thanks,
Loic
>
> --
> Sergey
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-18 10:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 9:53 [PATCH net] net: wwan: Add WWAN port type attribute Loic Poulain
2021-05-17 22:50 ` patchwork-bot+netdevbpf
2021-05-17 23:43 ` Sergey Ryazanov
2021-05-18 10:31 ` Loic Poulain
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.