[PATCH v1 2/4] spi: Support suppress_override_attrs flag
From: Andy Shevchenko
Date: Fri May 08 2026 - 05:57:37 EST
Some device driver may want to suppress the driver_override sysfs attribute
by specifying a certain flag in their struct device_driver. Since SPI uses
explicit attribute instantiation, add that support here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/spi/spi.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5f57de24b9f7..40e738f8cbb7 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -214,8 +214,19 @@ static struct attribute *spi_dev_attrs[] = {
NULL,
};
+static umode_t spi_dev_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
+{
+ struct device *dev = kobj_to_dev(kobj);
+
+ if (attr == &dev_attr_driver_override.attr)
+ return dev->driver->suppress_override_attrs ? 0 : attr->mode;
+
+ return attr->mode;
+}
+
static const struct attribute_group spi_dev_group = {
.attrs = spi_dev_attrs,
+ .is_visible = spi_dev_attr_is_visible,
};
static struct attribute *spi_device_statistics_attrs[] = {
--
2.50.1