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: <8a01a0afc344e9c7d259355aec190af63ea79393.camel@microchip.com>
Date:   Thu, 15 Dec 2022 03:54:23 +0000
From:   <Arun.Ramadoss@...rochip.com>
To:     <olteanv@...il.com>, <andrew@...n.ch>, <robh+dt@...nel.org>,
        <corbet@....net>, <linux-kernel@...r.kernel.org>,
        <tharvey@...eworks.com>, <linux-leds@...r.kernel.org>,
        <devicetree@...r.kernel.org>, <john@...ozen.org>,
        <f.fainelli@...il.com>, <pavel@....cz>,
        <rmk+kernel@...linux.org.uk>, <kuba@...nel.org>,
        <ansuelsmth@...il.com>, <pabeni@...hat.com>, <edumazet@...gle.com>,
        <netdev@...r.kernel.org>, <krzysztof.kozlowski+dt@...aro.org>,
        <davem@...emloft.net>, <linux-doc@...r.kernel.org>,
        <alexander.stein@...tq-group.com>, <rasmus.villemoes@...vas.dk>
Subject: Re: [PATCH v7 10/11] net: dsa: qca8k: add LEDs support

Hi Christian,

On Thu, 2022-12-15 at 00:54 +0100, Christian Marangi wrote:
> Add LEDs support for qca8k Switch Family. This will provide the LEDs
> hardware API to permit the PHY LED to support hardware mode.
> Each port have at least 3 LEDs and they can HW blink, set on/off or
> follow blink modes configured with the LED in hardware mode.
> Adds support for leds netdev trigger to support hardware triggers.
> 
> Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
> ---
>  drivers/net/dsa/qca/Kconfig      |   9 +
>  drivers/net/dsa/qca/Makefile     |   1 +
>  drivers/net/dsa/qca/qca8k-8xxx.c |   4 +
>  drivers/net/dsa/qca/qca8k-leds.c | 406
> +++++++++++++++++++++++++++++++
>  drivers/net/dsa/qca/qca8k.h      |  62 +++++
>  5 files changed, 482 insertions(+)
>  create mode 100644 drivers/net/dsa/qca/qca8k-leds.c
> 
> 
> diff --git a/drivers/net/dsa/qca/qca8k-leds.c
> b/drivers/net/dsa/qca/qca8k-leds.c
> new file mode 100644
> index 000000000000..b51cdcae31b2
> --- /dev/null
> +++ b/drivers/net/dsa/qca/qca8k-leds.c
> @@ -0,0 +1,406 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <net/dsa.h>
> +#include <linux/regmap.h>

Alphabatical order

> +
> +#include "qca8k.h"
> +
> +static int
> +qca8k_get_enable_led_reg(int port_num, int led_num, struct
> qca8k_led_pattern_en *reg_info)
> +{
> +	int shift;
> +
> +	switch (port_num) {
> +	case 0:
> +		reg_info->reg = QCA8K_LED_CTRL_REG(led_num);
> +		reg_info->shift = 14;

Any macros other than magic number for 14, 30 

> +		break;
> +	case 1:
> +	case 2:
> +	case 3:
> +		reg_info->reg = QCA8K_LED_CTRL_REG(3);
> +		shift = 2 * led_num + (6 * (port_num - 1));
> +
> +		reg_info->shift = 8 + shift;
> +
> +		break;
> +	case 4:
> +		reg_info->reg = QCA8K_LED_CTRL_REG(led_num);
> +		reg_info->shift = 30;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> 
> +
> +static void
> +qca8k_led_brightness_set(struct qca8k_led *led,
> +			 enum led_brightness b)

variable name other than b to have readability in code

> +{
> +	struct qca8k_led_pattern_en reg_info;
> +	struct qca8k_priv *priv = led->priv;
> +	u32 val = QCA8K_LED_ALWAYS_OFF;
> +
> +	qca8k_get_enable_led_reg(led->port_num, led->led_num,
> &reg_info);
> +
> +	if (b)
> +		val = QCA8K_LED_ALWAYS_ON;
> +
> +	regmap_update_bits(priv->regmap, reg_info.reg,
> +			   GENMASK(1, 0) << reg_info.shift,

GENMASK(1, 0) used in multiple place, replace with macro for
readability

> +			   val << reg_info.shift);
> +}
> +
> 
> +
> +static int
> +qca8k_cled_trigger_offload(struct led_classdev *ldev, bool enable)
> +{
> +	struct qca8k_led *led = container_of(ldev, struct qca8k_led,
> cdev);
> +

Blank line

> +	struct qca8k_led_pattern_en reg_info;
> +	struct qca8k_priv *priv = led->priv;
> +	u32 val = QCA8K_LED_ALWAYS_OFF;
> +
> +	qca8k_get_enable_led_reg(led->port_num, led->led_num,
> &reg_info);
> +
> +	if (enable)
> +		val = QCA8K_LED_RULE_CONTROLLED;
> +
> +	return regmap_update_bits(priv->regmap, reg_info.reg,
> +				  GENMASK(1, 0) << reg_info.shift,
> +				  val << reg_info.shift);
> +}
> +
> 
> +static bool
> +qca8k_cled_hw_control_status(struct led_classdev *ldev)
> +{
> +	struct qca8k_led *led = container_of(ldev, struct qca8k_led,
> cdev);
> +

Blank line

> +	struct qca8k_led_pattern_en reg_info;
> +	struct qca8k_priv *priv = led->priv;
> +	u32 val;
> +
> +	qca8k_get_enable_led_reg(led->port_num, led->led_num,
> &reg_info);
> +
> +	regmap_read(priv->regmap, reg_info.reg, &val);
> +
> +	val >>= reg_info.shift;
> +	val &= GENMASK(1, 0);
> +
> +	return val == QCA8K_LED_RULE_CONTROLLED;
> +}
> +
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ