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] [day] [month] [year] [list]
Date: Mon, 25 Mar 2024 13:38:42 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Luiz Angelo Daros de Luca <luizluca@...il.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
	Alvin Šipraga <alsi@...g-olufsen.dk>,
	Florian Fainelli <f.fainelli@...il.com>,
	Vladimir Oltean <olteanv@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 4/4] net: dsa: realtek: add LED drivers for
 rtl8366rb

> static int rtl8366rb_setup(struct dsa_switch *ds)
> {
>        (...)
>        if (priv->leds_disabled) {

         if (!priv->leds_disable)
	    return;
	    
Saves you one level of indentation.

or

static int rtl8366rb_setup_all_off(foo *priv)
{

>                /* Turn everything off */
>                regmap_update_bits(priv->map,
>                                   RTL8366RB_INTERRUPT_CONTROL_REG,
>                                   RTL8366RB_P4_RGMII_LED,
>                                   0);
> 
>                for (i = 0; i < RTL8366RB_NUM_LEDGROUPS; i++) {
>                        ret = rb8366rb_set_ledgroup_mode(priv, i,
>                                                         RTL8366RB_LEDGROUP_OFF);
>                        if (ret)
>                                return ret;
>                }
>         }
> }

This is what i meant by small helpers. And the function names replaces
the need for the comment.

This is part of the thinking behind the coding style. Function names
can replace comments. And the higher level functions becomes easier to
follow because you don't need to dig into the details to understand:

        if (priv->leds_disabled)
	     rtl8366rb_setup_all_off(priv);

     Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ