From: Rong Zhang <i@rong.moe>
To: "Derek J. Clark" <derekjohn.clark@gmail.com>,
"Mark Pearson" <mpearson-lenovo@squebb.ca>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Armin Wolf" <W_Armin@gmx.de>
Cc: Charles <hanker007@gmail.com>,
Navon John Lukose <navonjohnlukose@gmail.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 03/12] platform/x86: lenovo-wmi-capdata: Only allocate sub-master info when necessary
Date: Fri, 09 Oct 2026 23:45:26 +0800 [thread overview]
Message-ID: <faa1eb31890107b8bdd2386e9361f929d4cd881d.camel@rong.moe> (raw)
In-Reply-To: <807F11B7-33B6-454F-B550-F516E974703B@gmail.com>
Hi Derek,
Thanks for your review.
On Fri, 2026-10-09 at 08:15 -0700, Derek J. Clark wrote:
> On October 9, 2026 5:53:45 AM PDT, Rong Zhang <i@rong.moe> wrote:
> > When capdata00 declares no fan test support, there is no need to
> > allocate sub-master info as it's basically unused except for the
> > priv->sub_master->sub_component_list == ERR_PTR(-ENODEV) placeholder.
> >
> > Therefore, only allocate priv->sub_master when necessary, otherwise its
> > absence implies the absence of sub-component. With that,
> > PTR_ERR(sub_component_list) == -ENODEV is repurposed for the following
> > changes to represent stubbed sub-component.
> >
> > Signed-off-by: Rong Zhang <i@rong.moe>
> > ---
> > drivers/platform/x86/lenovo/wmi-capdata.c | 36 ++++++++++++++++++-------------
> > 1 file changed, 21 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/platform/x86/lenovo/wmi-capdata.c b/drivers/platform/x86/lenovo/wmi-capdata.c
> > index 58787da959b4..3a823aee608a 100644
> > --- a/drivers/platform/x86/lenovo/wmi-capdata.c
> > +++ b/drivers/platform/x86/lenovo/wmi-capdata.c
> > @@ -101,9 +101,11 @@ struct lwmi_cd_priv {
> > struct lwmi_cd_sub_master_priv {
> > struct device *master_dev;
> > cd_list_cb_t master_cb;
> > - struct cd_list *sub_component_list; /* ERR_PTR(-ENODEV) implies no sub-component. */
> > + struct cd_list *sub_component_list; /* ERR_PTR(-ENODEV) implies stubbed
> > + * sub-component.
> > + */
>
> Hi Rong,
>
> Hitting the column limit here looks ugly and harms readability IMO. Perhaps we could rename the variable (sc_list?) or be less explicit about the full error signature?
Makes sense. Will rephrase it into:
struct cd_list *sub_component_list; /* ERR_PTR(-ENODEV): stubbed sub-component. */
Thanks,
Rong
> - Derek
>
> > bool registered; /* Has the sub-master been registered? */
> > - } *sub_master;
> > + } *sub_master; /* NULL impLnlies no sub-component. */
> > };
> >
> > struct cd_list {
> > @@ -258,6 +260,12 @@ static int lwmi_cd_component_bind(struct device *cd_dev,
> > case LENOVO_CAPABILITY_DATA_00:
> > binder->cd00_list = priv->list;
> >
> > + /* Missing sub-master info implies missing sub-component. */
> > + if (!priv->sub_master) {
> > + binder->cd_fan_list_cb(om_dev, NULL);
> > + break;
> > + }
> > +
> > priv->sub_master->master_dev = om_dev;
> > priv->sub_master->master_cb = binder->cd_fan_list_cb;
> > lwmi_cd_call_master_cb(priv);
> > @@ -288,13 +296,9 @@ static void lwmi_cd_component_unbind(struct device *cd_dev,
> > {
> > struct lwmi_cd_priv *priv = dev_get_drvdata(cd_dev);
> >
> > - switch (priv->list->type) {
> > - case LENOVO_CAPABILITY_DATA_00:
> > + if (priv->sub_master) {
> > priv->sub_master->master_dev = NULL;
> > priv->sub_master->master_cb = NULL;
> > - return;
> > - default:
> > - return;
> > }
> > }
> >
> > @@ -369,17 +373,19 @@ static int lwmi_cd_sub_master_add(struct lwmi_cd_priv *priv,
> > struct component_match *master_match = NULL;
> > int ret;
> >
> > + /*
> > + * If the sub-master has no sub-component, there is no need to allocate
> > + * or register the sub-master. The master callback will be called with
> > + * NULL on master <-> sub-master bind to inform the master about the
> > + * absence of sub-component.
> > + */
> > + if (sub_component_type == CD_TYPE_NONE)
> > + return 0;
> > +
> > priv->sub_master = devm_kzalloc(&priv->wdev->dev, sizeof(*priv->sub_master), GFP_KERNEL);
> > if (!priv->sub_master)
> > return -ENOMEM;
> >
> > - if (sub_component_type == CD_TYPE_NONE) {
> > - /* The master callback will be called with NULL on bind. */
> > - priv->sub_master->sub_component_list = ERR_PTR(-ENODEV);
> > - priv->sub_master->registered = false;
> > - return 0;
> > - }
> > -
> > /*
> > * lwmi_cd_match() needs a pointer to enum lwmi_cd_type, but on-stack
> > * data cannot be used here. Steal one from lwmi_cd_table.
> > @@ -404,7 +410,7 @@ static int lwmi_cd_sub_master_add(struct lwmi_cd_priv *priv,
> > */
> > static void lwmi_cd_sub_master_del(struct lwmi_cd_priv *priv)
> > {
> > - if (!priv->sub_master->registered)
> > + if (!priv->sub_master || !priv->sub_master->registered)
> > return;
> >
> > component_master_del(&priv->wdev->dev, &lwmi_cd_sub_master_ops);
> >
next prev parent reply other threads:[~2026-10-09 15:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 12:53 [PATCH v2 00/12] platform/x86: lenovo-wmi-{other,capdata,helpers}: Improve robustness on faulty firmware Rong Zhang
2026-10-09 12:53 ` [PATCH v2 01/12] platform/wmi: Introduce wmidev_exists() Rong Zhang
2026-10-09 20:25 ` Mark Pearson
2026-10-09 12:53 ` [PATCH v2 02/12] platform/x86: lenovo-wmi-capdata: Do not stop the AC notifier chain on error Rong Zhang
2026-10-09 12:53 ` [PATCH v2 03/12] platform/x86: lenovo-wmi-capdata: Only allocate sub-master info when necessary Rong Zhang
2026-10-09 15:15 ` Derek J. Clark
2026-10-09 15:45 ` Rong Zhang [this message]
2026-10-09 12:53 ` [PATCH v2 04/12] platform/x86: lenovo-wmi-capdata: Store a pointer to component info Rong Zhang
2026-10-09 12:53 ` [PATCH v2 05/12] platform/x86: lenovo-wmi-capdata: Defer mutex initialization Rong Zhang
2026-10-09 12:53 ` [PATCH v2 06/12] platform/x86: lenovo-wmi-{capdata,other}: Only allocate capdata list when necessary Rong Zhang
2026-10-09 12:53 ` [PATCH v2 07/12] platform/x86: lenovo-wmi-capdata: Adopt new WMI API Rong Zhang
2026-10-10 1:16 ` Armin Wolf
2026-10-10 1:51 ` Rong Zhang
2026-10-09 12:53 ` [PATCH v2 08/12] platform/x86: lenovo-wmi-capdata: Register component even on WMI error Rong Zhang
2026-10-09 12:53 ` [PATCH v2 09/12] platform/x86: lenovo-wmi-capdata: Detect stubbed capdata device Rong Zhang
2026-10-09 12:53 ` [PATCH v2 10/12] platform/x86: lenovo-wmi-capdata: Do not match missing components Rong Zhang
2026-10-09 12:53 ` [PATCH v2 11/12] platform/x86: lenovo-wmi-helpers: Adopt new WMI API Rong Zhang
2026-10-10 1:19 ` Armin Wolf
2026-10-09 12:53 ` [PATCH v2 12/12] MAINTAINERS: Add myself as a LENOVO drivers co-maintainer Rong Zhang
2026-10-09 20:26 ` Mark Pearson
2026-10-09 23:01 ` [PATCH v2 00/12] platform/x86: lenovo-wmi-{other,capdata,helpers}: Improve robustness on faulty firmware Derek J. Clark
2026-10-12 3:25 ` Navon John Lukose
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=faa1eb31890107b8bdd2386e9361f929d4cd881d.camel@rong.moe \
--to=i@rong.moe \
--cc=W_Armin@gmx.de \
--cc=derekjohn.clark@gmail.com \
--cc=hanker007@gmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--cc=navonjohnlukose@gmail.com \
--cc=platform-driver-x86@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
all inboxes | Powered by JetHome®