All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
Cc: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>,
	Stephane Grosjean <s.grosjean@peak-system.com>,
	Jimmy Assarsson <extja@kvaser.com>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Max Staudt <max@enpas.org>
Subject: Re: [PATCH v1 10/24] can: tree-wide: implement ethtool_ops::get_drvinfo()
Date: Tue, 26 Jul 2022 11:21:00 +0200	[thread overview]
Message-ID: <CABGWkvqA5p=h7fHabH4iKoppvrypedonEnLnohgm0j+Nm-70NA@mail.gmail.com> (raw)
In-Reply-To: <CAMZ6Rq+Wd412aFSiuLsjPE=aT0UQVNqp9FEZCEkjdU71hVWR0Q@mail.gmail.com>

Hi Vincent,

On Tue, Jul 26, 2022 at 10:42 AM Vincent MAILHOL
<mailhol.vincent@wanadoo.fr> wrote:
>
> Hi Dario,
>
> On Tue. 26 Jul. 2022 at 16:41, Dario Binacchi
> <dario.binacchi@amarulasolutions.com> wrote:
> > Hi Vincent,
> >
> > On Mon, Jul 25, 2022 at 3:32 PM Vincent Mailhol
> > <mailhol.vincent@wanadoo.fr> wrote:
> > >
> > > For all CAN drivers, implement the get_drvinfo() function.
> > >
> > > After this patch, it is now possible to retrieve basic information by
> > > doing:
> > >
> > > | $ ethtool -i canX
> > >
> > > Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> > > ---
> > >  drivers/net/can/at91_can.c                       | 12 ++++++++++++
> > >  drivers/net/can/c_can/c_can_main.c               | 12 ++++++++++++
> > >  drivers/net/can/can327.c                         | 11 +++++++++++
> > >  drivers/net/can/cc770/cc770.c                    | 12 ++++++++++++
> > >  drivers/net/can/ctucanfd/ctucanfd_base.c         | 12 ++++++++++++
> > >  drivers/net/can/flexcan/flexcan-core.c           | 12 ++++++++++++
> > >  drivers/net/can/grcan.c                          | 12 ++++++++++++
> > >  drivers/net/can/ifi_canfd/ifi_canfd.c            | 12 ++++++++++++
> > >  drivers/net/can/janz-ican3.c                     | 12 ++++++++++++
> > >  drivers/net/can/kvaser_pciefd.c                  | 12 ++++++++++++
> > >  drivers/net/can/m_can/m_can.c                    | 12 ++++++++++++
> > >  drivers/net/can/mscan/mscan.c                    |  1 +
> > >  drivers/net/can/pch_can.c                        | 12 ++++++++++++
> > >  drivers/net/can/peak_canfd/peak_canfd.c          | 12 ++++++++++++
> > >  drivers/net/can/rcar/rcar_can.c                  | 12 ++++++++++++
> > >  drivers/net/can/rcar/rcar_canfd.c                | 12 ++++++++++++
> > >  drivers/net/can/sja1000/sja1000.c                | 12 ++++++++++++
> > >  drivers/net/can/slcan/slcan-core.c               | 12 ++++++++++++
> > >  drivers/net/can/softing/softing_main.c           | 12 ++++++++++++
> > >  drivers/net/can/spi/hi311x.c                     | 12 ++++++++++++
> > >  drivers/net/can/spi/mcp251x.c                    | 12 ++++++++++++
> > >  drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c   | 12 ++++++++++++
> > >  drivers/net/can/sun4i_can.c                      | 12 ++++++++++++
> > >  drivers/net/can/ti_hecc.c                        | 12 ++++++++++++
> > >  drivers/net/can/usb/ems_usb.c                    | 12 ++++++++++++
> > >  drivers/net/can/usb/esd_usb.c                    | 12 ++++++++++++
> > >  drivers/net/can/usb/etas_es58x/es58x_core.c      | 12 ++++++++++++
> > >  drivers/net/can/usb/gs_usb.c                     |  8 ++++++++
> > >  drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 12 ++++++++++++
> > >  drivers/net/can/usb/mcba_usb.c                   | 12 ++++++++++++
> > >  drivers/net/can/usb/peak_usb/pcan_usb_core.c     |  6 ++++++
> > >  drivers/net/can/usb/peak_usb/pcan_usb_core.h     |  2 ++
> > >  drivers/net/can/usb/peak_usb/pcan_usb_fd.c       |  1 +
> > >  drivers/net/can/usb/peak_usb/pcan_usb_pro.c      |  1 +
> > >  drivers/net/can/usb/ucan.c                       | 12 ++++++++++++
> > >  drivers/net/can/usb/usb_8dev.c                   | 12 ++++++++++++
> > >  drivers/net/can/vcan.c                           | 12 ++++++++++++
> > >  drivers/net/can/vxcan.c                          | 12 ++++++++++++
> > >  drivers/net/can/xilinx_can.c                     | 12 ++++++++++++
> > >  39 files changed, 414 insertions(+)
>
> (...)
>
> > > diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
> > > index d1562f9474c9..1b86001c85f8 100644
> > > --- a/drivers/net/can/slcan/slcan-core.c
> > > +++ b/drivers/net/can/slcan/slcan-core.c
> > > @@ -46,6 +46,7 @@
> > >  #include <linux/string.h>
> > >  #include <linux/tty.h>
> > >  #include <linux/errno.h>
> > > +#include <linux/ethtool.h>
> > >  #include <linux/netdevice.h>
> > >  #include <linux/skbuff.h>
> > >  #include <linux/rtnetlink.h>
> > > @@ -790,6 +791,16 @@ static const struct net_device_ops slc_netdev_ops = {
> > >         .ndo_change_mtu         = slcan_change_mtu,
> > >  };
> > >
> > > +static void slcan_get_drvinfo(struct net_device *netdev,
> > > +                             struct ethtool_drvinfo *drvinfo)
> > > +{
> > > +       strscpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
> > > +}
> > > +
> >
> > Please put the function inside the slcan-ethtool.c.
> >
> > > +static const struct ethtool_ops slcan_ethtool_ops = {
> > > +       .get_drvinfo = slcan_get_drvinfo,
> > > +};
> > > +
> >
> > slcan_ethtool_ops is is already defined in slcan-ethtool.c
> >
> > >  /******************************************
> > >   *  Routines looking at TTY side.
> > >   ******************************************/
> > > @@ -869,6 +880,7 @@ static struct slcan *slc_alloc(void)
> > >
> > >         snprintf(dev->name, sizeof(dev->name), DRV_NAME "%d", i);
> > >         dev->netdev_ops = &slc_netdev_ops;
> > > +       dev->ethtool_ops = &slcan_ethtool_ops;
> > >         dev->base_addr  = i;
> > >         slcan_set_ethtool_ops(dev);
> >
> > It already sets dev->ethtool_ops.
>
> Indeed. I did not realise this. I was looking for an assignment on
> dev->ethtool_ops and missed the call to slcan_set_ethtool_ops().
>
> I am not convinced by the slcan_set_ethtool_ops(). It introduces a
> function call for no specific reasons. Instead, I am thinking to just
> export slcan_ethtool_ops like that:
>
>
> diff --git a/drivers/net/can/slcan/slcan-core.c
> b/drivers/net/can/slcan/slcan-core.c
> index d4dbeb849432..c98567c711ae 100644
> --- a/drivers/net/can/slcan/slcan-core.c
> +++ b/drivers/net/can/slcan/slcan-core.c
> @@ -868,8 +868,8 @@ static struct slcan *slc_alloc(void)
>
>         snprintf(dev->name, sizeof(dev->name), "slcan%d", i);
>         dev->netdev_ops = &slc_netdev_ops;
> +       dev->ethtool_ops = &slcan_ethtool_ops;
>         dev->base_addr  = i;
> -       slcan_set_ethtool_ops(dev);
>         sl = netdev_priv(dev);
>
>         /* Initialize channel control data */
> diff --git a/drivers/net/can/slcan/slcan-ethtool.c
> b/drivers/net/can/slcan/slcan-ethtool.c
> index bf0afdc4e49d..328ae1fb065b 100644
> --- a/drivers/net/can/slcan/slcan-ethtool.c
> +++ b/drivers/net/can/slcan/slcan-ethtool.c
> @@ -52,14 +52,9 @@ static int slcan_get_sset_count(struct net_device
> *netdev, int sset)
>         }
>  }
>
> -static const struct ethtool_ops slcan_ethtool_ops = {
> +const struct ethtool_ops slcan_ethtool_ops = {
>         .get_strings = slcan_get_strings,
>         .get_priv_flags = slcan_get_priv_flags,
>         .set_priv_flags = slcan_set_priv_flags,
>         .get_sset_count = slcan_get_sset_count,
>  };
> -
> -void slcan_set_ethtool_ops(struct net_device *netdev)
> -{
> -       netdev->ethtool_ops = &slcan_ethtool_ops;
> -}
> diff --git a/drivers/net/can/slcan/slcan.h b/drivers/net/can/slcan/slcan.h
> index d463c8d99e22..85cedf856db3 100644
> --- a/drivers/net/can/slcan/slcan.h
> +++ b/drivers/net/can/slcan/slcan.h
> @@ -13,6 +13,7 @@
>
>  bool slcan_err_rst_on_open(struct net_device *ndev);
>  int slcan_enable_err_rst_on_open(struct net_device *ndev, bool on);
> -void slcan_set_ethtool_ops(struct net_device *ndev);
> +
> +extern const struct ethtool_ops slcan_ethtool_ops;
>
>  #endif /* _SLCAN_H */
>
>
>
> Does it make sense?
>
>

I have already used this scheme in the c_can driver. I used this
scheme because I saw that it was used a lot
(git grep set_ethtool_ops) in the kernel. By doing so you can define
slcan_ethtool_ops as a static variable
and if possible I prefer to export functions rather than data. But it
can be a matter of taste.

Thanks and regards,
Dario

> Yours sincerely,
> Vincent Mailhol



-- 

Dario Binacchi

Embedded Linux Developer

dario.binacchi@amarulasolutions.com

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
info@amarulasolutions.com

www.amarulasolutions.com

  reply	other threads:[~2022-07-26  9:21 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25 13:31 [PATCH v1 00/24] can: add ethtool support and reporting of timestamping capabilities Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 01/24] can: can327: use KBUILD_MODNAME instead of hard coded name Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 02/24] can: ems_ubs: " Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 03/24] can: slcan: add DRV_NAME and define pr_fmt to replace hardcoded names Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 04/24] can: softing: add DRV_NAME " Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 05/24] can: esd_usb: use KBUILD_MODNAME instead of hard coded name Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 06/24] can: gs_ubs: " Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 07/24] can: softing: add DRV_NAME to replace hardcoded names Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 08/24] can: ubs_8dev: use KBUILD_MODNAME instead of hard coded name Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 09/24] can: etas_es58x: remove DRV_VERSION Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 10/24] can: tree-wide: implement ethtool_ops::get_drvinfo() Vincent Mailhol
2022-07-25 14:09   ` Marc Kleine-Budde
2022-07-25 14:29     ` Vincent MAILHOL
2022-07-26  7:29   ` Dario Binacchi
2022-07-26  8:42     ` Vincent MAILHOL
2022-07-26  9:21       ` Dario Binacchi [this message]
2022-07-26  9:59         ` Vincent MAILHOL
2022-07-27  8:19           ` Marc Kleine-Budde
2022-07-27  9:05             ` Vincent MAILHOL
2022-07-27 11:19               ` Marc Kleine-Budde
2022-07-25 13:31 ` [PATCH v1 11/24] can: can327: add software tx timestamps Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 12/24] can: janz-ican3: add software tx timestamp Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 13/24] can: slcan: add software tx timestamps Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 14/24] can: v(x)can: " Vincent Mailhol
2022-07-25 13:31 ` [PATCH v1 15/24] can: tree-wide: advertise software timestamping capabilities Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 16/24] can: dev: add hardware TX timestamp Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 17/24] can: dev: add generic function can_ethtool_op_get_ts_info_hwts() Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 18/24] can: dev: add generic function can_eth_ioctl_hwts() Vincent Mailhol
2022-07-25 14:22   ` Marc Kleine-Budde
2022-07-25 14:41     ` Vincent MAILHOL
2022-07-25 16:19       ` Marc Kleine-Budde
2022-07-25 13:32 ` [PATCH v1 19/24] can: mcp251xfd: advertise timestamping capabilities and add ioctl support Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 20/24] can: etas_es58x: " Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 21/24] can: kvaser_pciefd: " Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 22/24] can: kvaser_usb: " Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 23/24] can: peak_canfd: " Vincent Mailhol
2022-07-25 13:32 ` [PATCH v1 24/24] can: peak_usb: " Vincent Mailhol
2022-07-25 13:53 ` [PATCH v1 00/24] can: add ethtool support and reporting of timestamping capabilities Vincent MAILHOL
2022-07-25 15:53 ` [PATCH v2 00/14] " Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 01/14] can: can327: add software tx timestamps Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 02/14] can: janz-ican3: add software tx timestamp Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 03/14] can: slcan: add software tx timestamps Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 04/14] can: v(x)can: " Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 05/14] can: tree-wide: advertise software timestamping capabilities Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 06/14] can: dev: add hardware TX timestamp Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 07/14] can: dev: add generic function can_ethtool_op_get_ts_info_hwts() Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 08/14] can: dev: add generic function can_eth_ioctl_hwts() Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 09/14] can: mcp251xfd: advertise timestamping capabilities and add ioctl support Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 10/14] can: etas_es58x: " Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 11/14] can: kvaser_pciefd: " Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 12/14] can: kvaser_usb: " Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 13/14] can: peak_canfd: " Vincent Mailhol
2022-07-25 15:53   ` [PATCH v2 14/14] can: peak_usb: " Vincent Mailhol
2022-07-26 10:24 ` [PATCH v3 00/14] Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 01/14] can: can327: add software tx timestamps Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 02/14] can: janz-ican3: add software tx timestamp Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 03/14] can: slcan: add software tx timestamps Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 04/14] can: v(x)can: " Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 05/14] can: tree-wide: advertise software timestamping capabilities Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 06/14] can: dev: add hardware TX timestamp Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 07/14] can: dev: add generic function can_ethtool_op_get_ts_info_hwts() Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 08/14] can: dev: add generic function can_eth_ioctl_hwts() Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 09/14] can: mcp251xfd: advertise timestamping capabilities and add ioctl support Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 10/14] can: etas_es58x: " Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 11/14] can: kvaser_pciefd: " Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 12/14] can: kvaser_usb: " Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 13/14] can: peak_canfd: " Vincent Mailhol
2022-07-26 10:24   ` [PATCH v3 14/14] can: peak_usb: " Vincent Mailhol
2022-07-27  8:06     ` Marc Kleine-Budde
2022-07-27  8:29       ` Vincent MAILHOL
2022-07-27  8:42         ` Marc Kleine-Budde
2022-07-27  9:17           ` Vincent MAILHOL
2022-07-27 10:16 ` [PATCH v4 00/14] can: add ethtool support and reporting of timestamping capabilities Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 01/14] can: can327: add software tx timestamps Vincent Mailhol
2022-07-27 20:24     ` Max Staudt
2022-07-27 10:16   ` [PATCH v4 02/14] can: janz-ican3: add software tx timestamp Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 03/14] can: slcan: add software tx timestamps Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 04/14] can: v(x)can: " Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 05/14] can: tree-wide: advertise software timestamping capabilities Vincent Mailhol
2022-07-28  9:38     ` Marc Kleine-Budde
2022-07-28 13:28       ` Vincent MAILHOL
2022-07-28 13:35         ` Marc Kleine-Budde
2022-07-27 10:16   ` [PATCH v4 06/14] can: dev: add hardware TX timestamp Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 07/14] can: dev: add generic function can_ethtool_op_get_ts_info_hwts() Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 08/14] can: dev: add generic function can_eth_ioctl_hwts() Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 09/14] can: mcp251xfd: advertise timestamping capabilities and add ioctl support Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 10/14] can: etas_es58x: " Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 11/14] can: kvaser_pciefd: " Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 12/14] can: kvaser_usb: " Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 13/14] can: peak_canfd: " Vincent Mailhol
2022-07-27 10:16   ` [PATCH v4 14/14] can: peak_usb: " Vincent Mailhol
2022-07-28 10:09   ` [PATCH v4 00/14] can: add ethtool support and reporting of timestamping capabilities Marc Kleine-Budde

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='CABGWkvqA5p=h7fHabH4iKoppvrypedonEnLnohgm0j+Nm-70NA@mail.gmail.com' \
    --to=dario.binacchi@amarulasolutions.com \
    --cc=extja@kvaser.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=max@enpas.org \
    --cc=mkl@pengutronix.de \
    --cc=s.grosjean@peak-system.com \
    --cc=socketcan@hartkopp.net \
    /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.