All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Benson Leung <bleung@chromium.org>,
	Tzung-Bi Shih <tzungbi@kernel.org>,
	Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] mfd: cros_ec: Add a helper to retrieve the EC device from the MFD parent
Date: Fri, 24 Apr 2026 08:58:36 +0100	[thread overview]
Message-ID: <20260424075836.GH170138@google.com> (raw)
In-Reply-To: <20260404-cros_kbd_led-cleanup-v1-4-0dc1100d54e3@weissschuh.net>

On Sat, 04 Apr 2026, Thomas Weißschuh wrote:

> The 'struct cros_ec_dev' needs to be retrieved from the MFD parent
> device through a non-typesafe API. This logic is duplicated over all
> CrOS EC drivers and it is not obvious what is going on.

I don't agree with this at all.

dev_get_drvdata(pdev->dev.parent) is way more transparent than what is
being offered by cros_ec_mfd_get_ec_dev(pdev).

The aforementioned call clearly states that it's fetching the parent's
driver data.  This is better.

> Add a dedicated helper function which makes clear what is happening.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  include/linux/mfd/cros_ec.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
> new file mode 100644
> index 000000000000..ea5b007accfc
> --- /dev/null
> +++ b/include/linux/mfd/cros_ec.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef __LINUX_MFD_CROS_EC_H
> +#define __LINUX_MFD_CROS_EC_H
> +
> +#include <linux/compiler_attributes.h>
> +
> +struct cros_ec_dev;
> +struct platform_device;
> +
> +static __always_inline struct cros_ec_dev *cros_ec_mfd_get_ec_dev(struct platform_device *pdev)
> +{
> +	return dev_get_drvdata(pdev->dev.parent);
> +}
> +
> +#endif /* __LINUX_MFD_CROS_EC_H */
> 
> -- 
> 2.53.0
> 

-- 
Lee Jones

  reply	other threads:[~2026-04-24  7:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-04  7:55 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: Some cleanups Thomas Weißschuh
2026-04-04  7:55 ` [PATCH 1/5] platform/chrome: cros_kbd_led_backlight: Drop max_brightness from driver data Thomas Weißschuh
2026-04-04  7:55 ` [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: Pass keyboard_led as parameter Thomas Weißschuh
2026-04-04  7:55 ` [PATCH 3/5] platform/chrome: cros_kbd_led_backlight: Drop CONFIG_MFD_CROS_EC_DEV ifdeffery Thomas Weißschuh
2026-04-04  7:55 ` [PATCH 4/5] mfd: cros_ec: Add a helper to retrieve the EC device from the MFD parent Thomas Weißschuh
2026-04-24  7:58   ` Lee Jones [this message]
2026-04-04  7:55 ` [PATCH 5/5] platform/chrome: cros_kbd_led_backlight: Use cros_ec_mfd_get_ec_dev() Thomas Weißschuh
2026-04-07  6:19 ` [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: Some cleanups Tzung-Bi Shih
2026-04-27  2:34 ` (subset) " Tzung-Bi Shih

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=20260424075836.GH170138@google.com \
    --to=lee@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=tzungbi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.