lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230522-tattling-drum-b02b6c6bf76a-mkl@pengutronix.de>
Date:   Mon, 22 May 2023 10:19:30 +0200
From:   Marc Kleine-Budde <mkl@...gutronix.de>
To:     Vincent MAILHOL <mailhol.vincent@...adoo.fr>
Cc:     Frank Jungclaus <frank.jungclaus@....eu>,
        linux-can@...r.kernel.org, Wolfgang Grandegger <wg@...ndegger.com>,
        Stefan Mätje <stefan.maetje@....eu>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/6] can: esd_usb: Replace initializer macros used for
 struct can_bittiming_const

On 21.05.2023 18:16:17, Vincent MAILHOL wrote:
> Thanks for the patch.
> 
> On Sat. 20 May 2023 at 04:57, Frank Jungclaus <frank.jungclaus@....eu> wrote:
> > Replace the macros used to initialize the members of struct
> > can_bittiming_const with direct values. Then also use those struct
> > members to do the calculations in esd_usb2_set_bittiming().
> >
> > Link: https://lore.kernel.org/all/CAMZ6RqLaDNy-fZ2G0+QMhUEckkXLL+ZyELVSDFmqpd++aBzZQg@mail.gmail.com/
> > Suggested-by: Vincent MAILHOL <mailhol.vincent@...adoo.fr>
> > Signed-off-by: Frank Jungclaus <frank.jungclaus@....eu>
> > ---
> >  drivers/net/can/usb/esd_usb.c | 33 +++++++++++++--------------------
> >  1 file changed, 13 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
> > index 32354cfdf151..2eecf352ec47 100644
> > --- a/drivers/net/can/usb/esd_usb.c
> > +++ b/drivers/net/can/usb/esd_usb.c
> > @@ -60,18 +60,10 @@ MODULE_LICENSE("GPL v2");
> >  #define ESD_USB_NO_BAUDRATE    GENMASK(30, 0) /* bit rate unconfigured */
> >
> >  /* bit timing CAN-USB/2 */
> > -#define ESD_USB2_TSEG1_MIN     1
> > -#define ESD_USB2_TSEG1_MAX     16
> >  #define ESD_USB2_TSEG1_SHIFT   16
> > -#define ESD_USB2_TSEG2_MIN     1
> > -#define ESD_USB2_TSEG2_MAX     8
> >  #define ESD_USB2_TSEG2_SHIFT   20
> > -#define ESD_USB2_SJW_MAX       4
> >  #define ESD_USB2_SJW_SHIFT     14
> >  #define ESD_USBM_SJW_SHIFT     24
> > -#define ESD_USB2_BRP_MIN       1
> > -#define ESD_USB2_BRP_MAX       1024
> > -#define ESD_USB2_BRP_INC       1
> >  #define ESD_USB2_3_SAMPLES     BIT(23)
> >
> >  /* esd IDADD message */
> > @@ -909,19 +901,20 @@ static const struct ethtool_ops esd_usb_ethtool_ops = {
> >
> >  static const struct can_bittiming_const esd_usb2_bittiming_const = {
> >         .name = "esd_usb2",
> > -       .tseg1_min = ESD_USB2_TSEG1_MIN,
> > -       .tseg1_max = ESD_USB2_TSEG1_MAX,
> > -       .tseg2_min = ESD_USB2_TSEG2_MIN,
> > -       .tseg2_max = ESD_USB2_TSEG2_MAX,
> > -       .sjw_max = ESD_USB2_SJW_MAX,
> > -       .brp_min = ESD_USB2_BRP_MIN,
> > -       .brp_max = ESD_USB2_BRP_MAX,
> > -       .brp_inc = ESD_USB2_BRP_INC,
> > +       .tseg1_min = 1,
> > +       .tseg1_max = 16,
> > +       .tseg2_min = 1,
> > +       .tseg2_max = 8,
> > +       .sjw_max = 4,
> > +       .brp_min = 1,
> > +       .brp_max = 1024,
> > +       .brp_inc = 1,
> >  };
> >
> >  static int esd_usb2_set_bittiming(struct net_device *netdev)
> >  {
> >         struct esd_usb_net_priv *priv = netdev_priv(netdev);
> > +       const struct can_bittiming_const *btc = priv->can.bittiming_const;
> 
> I initially suggested doing:
> 
>           const struct can_bittiming_const *btc = priv->can.bittiming_const;
> 
> But now that I think again about it, doing:
> 
>           const struct can_bittiming_const *btc = &esd_usb2_bittiming_const;
> 
> is slightly better as it will allow the compiler to fold the integer
> constant expressions such as btc->brp_max - 1. The compiler is not
> smart enough to figure out what values are held in
> priv->can.bittiming_const at compile time.
> 
> Sorry for not figuring this the first time.

Good suggestion! Fixed up while applying.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ