LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Prashant Malani <pmalani@chromium.org>, linux-kernel@vger.kernel.org
Cc: furquan@chromium.org, Benson Leung <bleung@chromium.org>
Subject: Re: [PATCH 1/3] platform/chrome: notify: Add driver data struct
Date: Fri, 13 Mar 2020 13:41:20 +0100	[thread overview]
Message-ID: <06d90fc3-c792-b85f-c4aa-923c5a7f5eea@collabora.com> (raw)
In-Reply-To: <20200312100809.21153-2-pmalani@chromium.org>

Hi Prashant,

On 12/3/20 11:08, Prashant Malani wrote:
> Introduce a device driver data structure, cros_usbpd_notify_data, in
> which we can store the notifier block object and pointers to the struct
> cros_ec_device and struct device objects.
> 
> This will make it more convenient to access these pointers when
> executing both platform and ACPI callbacks.
> 
> While we are here, also add a dev_info print declaring successful device
> registration at the end of the platform probe function.
> 

This info can be obtained by other means, i.e function tracing or
initcall_debug. There is no need to repeat the same explicitly in the driver.

> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---
>  drivers/platform/chrome/cros_usbpd_notify.c | 30 ++++++++++++++-------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
> index 3851bbd6e9a39..edcb346024b07 100644
> --- a/drivers/platform/chrome/cros_usbpd_notify.c
> +++ b/drivers/platform/chrome/cros_usbpd_notify.c
> @@ -16,6 +16,12 @@
>  
>  static BLOCKING_NOTIFIER_HEAD(cros_usbpd_notifier_list);
>  
> +struct cros_usbpd_notify_data {
> +	struct device *dev;
> +	struct cros_ec_device *ec;
> +	struct notifier_block nb;
> +};
> +
>  /**
>   * cros_usbpd_register_notify - Register a notifier callback for PD events.
>   * @nb: Notifier block pointer to register
> @@ -98,23 +104,28 @@ static int cros_usbpd_notify_probe_plat(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent);
> -	struct notifier_block *nb;
> +	struct cros_usbpd_notify_data *pdnotify;
>  	int ret;
>  
> -	nb = devm_kzalloc(dev, sizeof(*nb), GFP_KERNEL);
> -	if (!nb)
> +	pdnotify = devm_kzalloc(dev, sizeof(*pdnotify), GFP_KERNEL);
> +	if (!pdnotify)
>  		return -ENOMEM;
>  
> -	nb->notifier_call = cros_usbpd_notify_plat;
> -	dev_set_drvdata(dev, nb);
> +	pdnotify->dev = dev;
> +	pdnotify->ec = ecdev->ec_dev;
> +	pdnotify->nb.notifier_call = cros_usbpd_notify_plat;
> +
> +	dev_set_drvdata(dev, pdnotify);
>  
>  	ret = blocking_notifier_chain_register(&ecdev->ec_dev->event_notifier,
> -					       nb);
> +					       &pdnotify->nb);
>  	if (ret < 0) {
>  		dev_err(dev, "Failed to register notifier\n");
>  		return ret;
>  	}
>  
> +	dev_info(dev, "Chrome EC PD notify device registered.\n");
> +

This is only noise to the kernel log, remove it.

>  	return 0;
>  }
>  
> @@ -122,10 +133,11 @@ static int cros_usbpd_notify_remove_plat(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent);
> -	struct notifier_block *nb =
> -		(struct notifier_block *)dev_get_drvdata(dev);
> +	struct cros_usbpd_notify_data *pdnotify =
> +		(struct cros_usbpd_notify_data *)dev_get_drvdata(dev);
>  
> -	blocking_notifier_chain_unregister(&ecdev->ec_dev->event_notifier, nb);
> +	blocking_notifier_chain_unregister(&ecdev->ec_dev->event_notifier,
> +					   &pdnotify->nb);
>  
>  	return 0;
>  }
> 

  reply	other threads:[~2020-03-13 12:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 10:08 [PATCH 0/3] platform/chrome: notify: Use PD_HOST_EVENT_STATUS Prashant Malani
2020-03-12 10:08 ` [PATCH 1/3] platform/chrome: notify: Add driver data struct Prashant Malani
2020-03-13 12:41   ` Enric Balletbo i Serra [this message]
2020-03-12 10:08 ` [PATCH 2/3] platform/chrome: notify: Amend ACPI driver to plat Prashant Malani
2020-03-13 12:42   ` Enric Balletbo i Serra
2020-03-15 21:38     ` Prashant Malani
2020-03-16  7:34       ` Prashant Malani
2020-03-12 10:08 ` [PATCH 3/3] platform/chrome: notify: Pull PD_HOST_EVENT status Prashant Malani
2020-03-13 12:43   ` Enric Balletbo i Serra
2020-03-15 21:41     ` Prashant Malani

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=06d90fc3-c792-b85f-c4aa-923c5a7f5eea@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=bleung@chromium.org \
    --cc=furquan@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmalani@chromium.org \
    --subject='Re: [PATCH 1/3] platform/chrome: notify: Add driver data struct' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).