From: "Danilo Krummrich" <dakr@kernel.org>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Cc: "Mark Brown" <broonie@kernel.org>,
driver-core@lists.linux.dev, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
linux-spi@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Jean-Baptiste Maneyrol" <jean-baptiste.maneyrol@tdk.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Subject: Re: [PATCH v1 1/4] driver core: allow certain drivers prohibit override via sysfs
Date: Fri, 08 May 2026 17:18:12 +0200 [thread overview]
Message-ID: <DIDE94YBOOP3.KM9I6J4JIJIY@kernel.org> (raw)
In-Reply-To: <20260508095224.1275645-2-andriy.shevchenko@linux.intel.com>
On Fri May 8, 2026 at 11:42 AM CEST, Andy Shevchenko wrote:
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index d17bd91490ee..16a530b91a00 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -594,7 +594,7 @@ int bus_add_device(struct device *dev)
> out_subsys:
> sysfs_remove_link(&sp->devices_kset->kobj, dev_name(dev));
> out_override:
> - if (dev->bus->driver_override)
> + if (dev->bus->driver_override && !dev->driver->suppress_override_attrs)
I think that doesn't work, when bus_add_device() is called no driver is bound to
the device yet, so dev->driver should be NULL.
But more in general, I think this isn't an implementation issue, but a
conceptual issue.
The driver_override attribute is on the device, and indicates whether this
device should be forcefully matched against some specific driver.
Now, if we want to suppress this attribute, we can't really let some driver
define whether is should be suppressed for this device.
Which driver would that be? The one that's already bound?
That said, I think the problem you actually want to resolve is not "suppress the
driver_override attribute", but rather "don't bind this driver through
driver_override".
IOW, this is a match() problem not a sysfs attribute problem.
So, I think the change that we actually want, is this one:
diff --git a/include/linux/device.h b/include/linux/device.h
index d54c86d77764..64bcb46edb97 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -839,9 +839,11 @@ static inline int device_match_driver_override(struct device *dev,
const struct device_driver *drv)
{
guard(spinlock)(&dev->driver_override.lock);
- if (dev->driver_override.name)
- return !strcmp(dev->driver_override.name, drv->name);
- return -1;
+ if (!dev->driver_override.name)
+ return -1;
+ if (drv->no_driver_override)
+ return 0;
+ return !strcmp(dev->driver_override.name, drv->name);
}
/**
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index bbc67ec513ed..d48cd9822634 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -55,6 +55,7 @@ enum probe_type {
* @owner: The module owner.
* @mod_name: Used for built-in modules.
* @suppress_bind_attrs: Disables bind/unbind via sysfs.
+ * @no_driver_override: The driver will not be matched via driver_override.
* @probe_type: Type of the probe (synchronous or asynchronous) to use.
* @of_match_table: The open firmware table.
* @acpi_match_table: The ACPI match table.
@@ -103,6 +104,7 @@ struct device_driver {
const char *mod_name; /* used for built-in modules */
bool suppress_bind_attrs; /* disables bind/unbind via sysfs */
+ bool no_driver_override; /* not matchable via driver_override */
enum probe_type probe_type;
const struct of_device_id *of_match_table;
This should also get us rid of the SPI patch, since SPI already uses
device_match_driver_override() in spi_match_device().
next prev parent reply other threads:[~2026-05-08 15:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 9:42 [PATCH v1 0/4] driver core, iio: suppress driver_override Andy Shevchenko
2026-05-08 9:42 ` [PATCH v1 1/4] driver core: allow certain drivers prohibit override via sysfs Andy Shevchenko
2026-05-08 15:18 ` Danilo Krummrich [this message]
2026-05-08 9:42 ` [PATCH v1 2/4] spi: Support suppress_override_attrs flag Andy Shevchenko
2026-05-08 13:53 ` Mark Brown
2026-05-08 15:28 ` Danilo Krummrich
2026-05-08 9:42 ` [PATCH v1 3/4] iio: imu: inv_mpu6050: Suppress driver_override sysfs attribute Andy Shevchenko
2026-05-08 9:42 ` [PATCH v1 4/4] iio: imu: inv_icm42600: " Andy Shevchenko
2026-05-08 12:22 ` [PATCH v1 0/4] driver core, iio: suppress driver_override Jonathan Cameron
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=DIDE94YBOOP3.KM9I6J4JIJIY@kernel.org \
--to=dakr@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=corbet@lwn.net \
--cc=dlechner@baylibre.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=jean-baptiste.maneyrol@tdk.com \
--cc=jic23@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=rafael@kernel.org \
--cc=skhan@linuxfoundation.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