public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Fabio Baltieri <fabiobaltieri@chromium.org>
Cc: "Benson Leung" <bleung@chromium.org>,
	"Guenter Roeck" <groeck@chromium.org>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lee Jones" <lee.jones@linaro.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	chrome-platform@lists.linux.dev, linux-pwm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] drivers: pwm: pwm-cros-ec: add channel type support
Date: Tue, 12 Apr 2022 15:32:01 +0800	[thread overview]
Message-ID: <YlUq8W+xjdxqYCo5@google.com> (raw)
In-Reply-To: <20220411152114.2165933-3-fabiobaltieri@chromium.org>

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.

  parent reply	other threads:[~2022-04-12  9:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 15:21 [PATCH v3 0/4] Add channel type support to pwm-cros-ec Fabio Baltieri
2022-04-11 15:21 ` [PATCH v3 1/4] dt-bindings: add mfd/cros_ec definitions Fabio Baltieri
2022-04-11 15:21 ` [PATCH v3 2/4] drivers: pwm: pwm-cros-ec: add channel type support Fabio Baltieri
2022-04-11 17:24   ` Fabio Baltieri
2022-04-12  7:32   ` Tzung-Bi Shih [this message]
2022-04-12  8:40     ` Fabio Baltieri
2022-04-11 15:21 ` [PATCH v3 3/4] dt-bindings: update google,cros-ec-pwm documentation Fabio Baltieri
2022-04-11 15:21 ` [PATCH v3 4/4] arm64: dts: address cros-ec-pwm channels by type Fabio Baltieri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YlUq8W+xjdxqYCo5@google.com \
    --to=tzungbi@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=devicetree@vger.kernel.org \
    --cc=fabiobaltieri@chromium.org \
    --cc=groeck@chromium.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox