linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Enric Balletbo Serra <eballetbo@gmail.com>
To: Gwendal Grignou <gwendal@chromium.org>
Cc: Benson Leung <bleung@chromium.org>,
	Lee Jones <lee.jones@linaro.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cros_ec: Use devm_kzalloc for private data
Date: Wed, 23 May 2018 18:35:51 +0200	[thread overview]
Message-ID: <CAFqH_50VYJC7aep6P+KtN4qmFeV66GEXvxmFy8KrNp1BRv33xg@mail.gmail.com> (raw)
In-Reply-To: <20180509230630.258755-1-gwendal@chromium.org>

Hi Gwendal,

2018-05-10 1:06 GMT+02:00 Gwendal Grignou <gwendal@chromium.org>:
> Use dev_kzmalloc, remove .release entry point.
>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> ---
>  drivers/mfd/cros_ec_dev.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index eafd06f62a3a..45d42511a3e5 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -262,13 +262,6 @@ static const struct file_operations fops = {
>  #endif
>  };
>
> -static void __remove(struct device *dev)
> -{
> -       struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev,
> -                                             class_dev);
> -       kfree(ec);
> -}
> -
>  static void cros_ec_sensors_register(struct cros_ec_dev *ec)
>  {
>         /*
> @@ -388,7 +381,7 @@ static int ec_device_probe(struct platform_device *pdev)
>         int retval = -ENOMEM;
>         struct device *dev = &pdev->dev;
>         struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
> -       struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
> +       struct cros_ec_dev *ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
>
>         if (!ec)
>                 return retval;
> @@ -410,7 +403,6 @@ static int ec_device_probe(struct platform_device *pdev)
>         ec->class_dev.devt = MKDEV(ec_major, pdev->id);
>         ec->class_dev.class = &cros_class;
>         ec->class_dev.parent = dev;
> -       ec->class_dev.release = __remove;
>
>         retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name);
>         if (retval) {
> --
> 2.17.0.441.gb46fe60e1d-goog
>

The patch looks good to me, however, the patch doesn't apply cleanly
if you have [1] already applied, and if not, then is this patch ([2])
which doesn't apply cleanly. To not have interdependencies I'd suggest
apply first this patch and remove the following from [1]

diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index eafd06f62a3a..cad12da7f884 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -264,8 +264,8 @@ static const struct file_operations fops = {

 static void __remove(struct device *dev)
 {
-       struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev,
-                                             class_dev);
+       struct cros_ec_dev *ec = to_cros_ec_dev(dev);
+
        kfree(ec);
 }

With this change, [1] can go through the Benson tree and [2] through
Lee tree independently. With the above change feel free to add my

Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

If you want I can do this rework for you.

Best regards,
 Enric

[1] https://patchwork.kernel.org/patch/10390959/
[2] https://patchwork.kernel.org/patch/10390965/

  reply	other threads:[~2018-05-23 16:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 23:06 [PATCH] cros_ec: Use devm_kzalloc for private data Gwendal Grignou
2018-05-23 16:35 ` Enric Balletbo Serra [this message]
2018-05-30 16:04   ` [PATCH v2] platform/chrome: Use to_cros_ec_dev more broadly Gwendal Grignou
2018-05-30 16:43     ` Enric Balletbo Serra
2018-05-30 19:06     ` Benson Leung
2018-05-30 16:54   ` [PATCH v2] cros_ec: Use devm_kzalloc for private data Gwendal Grignou
2018-06-04  7:42     ` Lee Jones
2018-06-05  6:59     ` Lee Jones

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=CAFqH_50VYJC7aep6P+KtN4qmFeV66GEXvxmFy8KrNp1BRv33xg@mail.gmail.com \
    --to=eballetbo@gmail.com \
    --cc=bleung@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).