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: <20190807181858.GB26047@lunn.ch>
Date:   Wed, 7 Aug 2019 20:18:58 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Matthias Kaehlcke <mka@...omium.org>
Cc:     "David S . Miller" <davem@...emloft.net>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Heiner Kallweit <hkallweit1@...il.com>, netdev@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        Douglas Anderson <dianders@...omium.org>
Subject: Re: [PATCH v5 2/4] net: phy: Add support for generic LED
 configuration through the DT

> +static void of_phy_config_leds(struct phy_device *phydev)
> +{
> +	struct device_node *np, *child;
> +	struct phy_led_config cfg;
> +	const char *trigger;
> +	int ret;
> +
> +	if (!IS_ENABLED(CONFIG_OF_MDIO) || !phydev->drv->config_led)
> +		return;
> +
> +	np = of_find_node_by_name(phydev->mdio.dev.of_node, "leds");
> +	if (!np)
> +		return;
> +
> +	for_each_child_of_node(np, child) {
> +		u32 led;
> +
> +		if (of_property_read_u32(child, "reg", &led))
> +			goto skip_config;
> +
> +		ret = of_property_read_string(child, "linux,default-trigger",
> +					      &trigger);
> +		if (ret)
> +			trigger = "none";
> +
> +		memset(&cfg, 0, sizeof(cfg));
> +
> +		if (!strcmp(trigger, "none")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_NONE;
> +		} else if (!strcmp(trigger, "phy-link")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK;
> +		} else if (!strcmp(trigger, "phy-link-10m")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_10M;
> +		} else if (!strcmp(trigger, "phy-link-100m")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_100M;
> +		} else if (!strcmp(trigger, "phy-link-1g")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_1G;
> +		} else if (!strcmp(trigger, "phy-link-10g")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_10G;
> +		} else if (!strcmp(trigger, "phy-link-activity")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK;
> +			cfg.trigger.activity = true;
> +		} else if (!strcmp(trigger, "phy-link-10m-activity")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_10M;
> +			cfg.trigger.activity = true;
> +		} else if (!strcmp(trigger, "phy-link-100m-activity")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_100M;
> +			cfg.trigger.activity = true;
> +		} else if (!strcmp(trigger, "phy-link-1g-activity")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_1G;
> +			cfg.trigger.activity = true;
> +		} else if (!strcmp(trigger, "phy-link-10g-activity")) {
> +			cfg.trigger.t = PHY_LED_TRIGGER_LINK_10G;
> +			cfg.trigger.activity = true;
> +		} else {
> +			phydev_warn(phydev, "trigger '%s' for LED%d is invalid\n",
> +				    trigger, led);
> +			goto skip_config;
> +		}
> +
> +		phydev->drv->config_led(phydev, led, &cfg);

We should not ignore the return value. I expect drivers will return
-EINVAL, or EOPNOTSUPP if asked to configure an LED in a way they
don't support. We need to report this. So i would add a phydev_warn:

> +			phydev_warn(phydev, "trigger '%s' for LED%d not supported\n",
> +				    trigger, led);

  Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ