From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Cc: "Daniel Scally" <djrscally@gmail.com>,
"Heikki Krogerus" <heikki.krogerus@linux.intel.com>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Mika Westerberg" <mika.westerberg@linux.intel.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Len Brown" <lenb@kernel.org>,
linux-acpi@vger.kernel.org, driver-core@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
platform-driver-x86@vger.kernel.org, brgl@kernel.org
Subject: Re: [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips
Date: Thu, 30 Apr 2026 15:51:58 +0300 [thread overview]
Message-ID: <afNQbtmd3j6wG0iI@ashevche-desk.local> (raw)
In-Reply-To: <20260430-baytrail-real-swnode-v4-2-767bcda6667f@oss.qualcomm.com>
On Thu, Apr 30, 2026 at 09:34:06AM +0200, Bartosz Golaszewski wrote:
> In order to allow GPIOLIB to match cherryview and baytrail GPIO
> controllers by their firmware nodes instead of their names, we need to
> attach the - currently "dangling" - existing software nodes to their
> target devices dynamically.
>
> The driver uses platform_create_bundle() and expects all required
> providers to be present before it itself is probed. We know the name of
> the device we're waiting for so look them up and assign the appropriate
> software node as the secondary firmware node of the underlying ACPI node.
>
> Scheduling fine-grained devres actions allows for proper teardown and
> unsetting of the secondary firmware nodes.
...
> +static void auto_secondary_unset(void *data)
> +{
> + struct fwnode_handle *fwnode = data;
> +
> + fwnode->secondary = NULL;
> +}
> +
> +static int acpi_set_secondary_fwnode(struct device *parent, struct device *dev,
> + const struct software_node *const swnode)
> +{
> + struct acpi_device *device = to_acpi_device(dev);
> + struct fwnode_handle *fwnode;
> + int ret;
> +
> + fwnode = software_node_fwnode(swnode);
> + if (WARN_ON(!fwnode))
> + return -ENOENT;
> +
> + fwnode->secondary = ERR_PTR(-ENODEV);
> + device->fwnode.secondary = fwnode;
> +
> + ret = devm_add_action_or_reset(parent, auto_secondary_unset, &device->fwnode);
> + if (ret)
> + dev_err(parent, "Failed to schedule the unset action for secondary fwnode\n");
> +
> + return ret;
> +}
Why don't we use set_secondary_fwnode() in the above functions?
Drivers are not supposed to know the guts of the fwnode implementation.
...
> +static int auto_secondary_fwnode_init(struct device *parent)
> +{
> + const struct software_node *const *swnode;
> + int ret;
> +
> + if (!gpiochip_node_group)
> + return 0;
> +
> + ret = software_node_register_node_group(gpiochip_node_group);
> + if (ret)
> + return ret;
> +
> + ret = devm_add_action_or_reset(parent,
> + auto_secondary_unregister_node_group,
> + gpiochip_node_group);
> + if (ret)
> + return ret;
> +
> + for (swnode = gpiochip_node_group; *swnode; swnode++) {
> + struct device *dev __free(put_device) =
> + acpi_bus_find_device_by_name((*swnode)->name);
> + if (!dev) {
> + dev_err(parent, "Failed to find the required GPIO controller: %s\n",
> + (*swnode)->name);
swnode at this point is registered, meaning we have an associated fwnode
handle, hence why not use %pfwP here?
> + return -ENODEV;
> + }
> +
> + ret = acpi_set_secondary_fwnode(parent, dev, *swnode);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-04-30 12:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 7:34 [PATCH v4 0/2] platform/x86: x86-android-tablets: use real firmware node references with intel drivers Bartosz Golaszewski
2026-04-30 7:34 ` [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() Bartosz Golaszewski
2026-04-30 9:57 ` Rafael J. Wysocki
2026-04-30 12:45 ` Andy Shevchenko
2026-04-30 7:34 ` [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips Bartosz Golaszewski
2026-04-30 10:03 ` Rafael J. Wysocki
2026-04-30 12:51 ` Andy Shevchenko [this message]
2026-04-30 13:01 ` Andy Shevchenko
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=afNQbtmd3j6wG0iI@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=dakr@kernel.org \
--cc=djrscally@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/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