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: <YlUq8W+xjdxqYCo5@google.com>
Date:   Tue, 12 Apr 2022 15:32:01 +0800
From:   Tzung-Bi Shih <tzungbi@...nel.org>
To:     Fabio Baltieri <fabiobaltieri@...omium.org>
Cc:     Benson Leung <bleung@...omium.org>,
        Guenter Roeck <groeck@...omium.org>,
        Thierry Reding <thierry.reding@...il.com>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>, Lee Jones <lee.jones@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        chrome-platform@...ts.linux.dev, linux-pwm@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/4] drivers: pwm: pwm-cros-ec: add channel type
 support

On Mon, Apr 11, 2022 at 03:21:12PM +0000, Fabio Baltieri wrote:
> Add support for EC_PWM_TYPE_DISPLAY_LIGHT and EC_PWM_TYPE_KB_LIGHT pwm
> types to the PWM cros_ec_pwm driver. This allows specifying one of these
> PWM channel by functionality, and let the EC firmware pick the correct
> channel, thus abstracting the hardware implementation from the kernel
> driver.
> 
> To use it, define the node with the "google,cros-ec-pwm-type"
> compatible.

Not sure whether you decide to leave the prefix as is or not[1], just another
reminder: to be neat, suggest to remove "drivers: " prefix from the commit
title.

[1]: https://patchwork.kernel.org/project/chrome-platform/patch/20220331125818.3776912-3-fabiobaltieri@chromium.org/

> +#ifdef CONFIG_OF
> +static const struct of_device_id cros_ec_pwm_of_match[] = {
> +	{
> +		.compatible = "google,cros-ec-pwm",
> +	},
> +	{
> +		.compatible = "google,cros-ec-pwm-type",
> +		.data = OF_CROS_EC_PWM_TYPE,
> +	},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, cros_ec_pwm_of_match);
> +#else
> +#define cros_ec_pwm_of_match NULL
> +#endif
> +
>  static int cros_ec_pwm_probe(struct platform_device *pdev)
>  {
>  	struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent);
>  	struct device *dev = &pdev->dev;
> +	const struct of_device_id *id;
>  	struct cros_ec_pwm_device *ec_pwm;
>  	struct pwm_chip *chip;
>  	int ret;
> @@ -251,17 +312,27 @@ static int cros_ec_pwm_probe(struct platform_device *pdev)
>  	chip = &ec_pwm->chip;
>  	ec_pwm->ec = ec;
>  
> +	id = of_match_device(cros_ec_pwm_of_match, dev);
> +	if (id && id->data == OF_CROS_EC_PWM_TYPE)
> +		ec_pwm->use_pwm_type = true;
> +
[...]
> -#ifdef CONFIG_OF
> -static const struct of_device_id cros_ec_pwm_of_match[] = {
> -	{ .compatible = "google,cros-ec-pwm" },
> -	{},
> -};
> -MODULE_DEVICE_TABLE(of, cros_ec_pwm_of_match);
> -#endif
> -

Use dev->driver->of_match_table to access the table so that the table
declaration doesn't actually need a move.  Instead, the helper function
of_device_get_match_data() is preferred.

Alternatively, it could use
of_device_is_compatible(..."google,cros-ec-pwm-type") so that it doesn't
need to introduce OF_CROS_EC_PWM_TYPE and reduce some bits.  I would prefer
this way.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ