Skip to content
Snippets Groups Projects
Unverified Commit 12046f8c authored by Armin Wolf's avatar Armin Wolf Committed by Ilpo Järvinen
Browse files

platform/x86: wmi: Add driver_override support


Add support for forcing the WMI driver core to bind
a certain WMI driver to a WMI device. This will be
necessary to support generic WMI drivers without an
ID table

Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240624173116.31314-2-W_Armin@gmx.de


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 42610314
No related branches found
No related tags found
No related merge requests found
...@@ -772,11 +772,39 @@ static ssize_t expensive_show(struct device *dev, ...@@ -772,11 +772,39 @@ static ssize_t expensive_show(struct device *dev,
} }
static DEVICE_ATTR_RO(expensive); static DEVICE_ATTR_RO(expensive);
static ssize_t driver_override_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct wmi_device *wdev = to_wmi_device(dev);
ssize_t ret;
device_lock(dev);
ret = sysfs_emit(buf, "%s\n", wdev->driver_override);
device_unlock(dev);
return ret;
}
static ssize_t driver_override_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct wmi_device *wdev = to_wmi_device(dev);
int ret;
ret = driver_set_override(dev, &wdev->driver_override, buf, count);
if (ret < 0)
return ret;
return count;
}
static DEVICE_ATTR_RW(driver_override);
static struct attribute *wmi_attrs[] = { static struct attribute *wmi_attrs[] = {
&dev_attr_modalias.attr, &dev_attr_modalias.attr,
&dev_attr_guid.attr, &dev_attr_guid.attr,
&dev_attr_instance_count.attr, &dev_attr_instance_count.attr,
&dev_attr_expensive.attr, &dev_attr_expensive.attr,
&dev_attr_driver_override.attr,
NULL NULL
}; };
ATTRIBUTE_GROUPS(wmi); ATTRIBUTE_GROUPS(wmi);
...@@ -845,6 +873,7 @@ static void wmi_dev_release(struct device *dev) ...@@ -845,6 +873,7 @@ static void wmi_dev_release(struct device *dev)
{ {
struct wmi_block *wblock = dev_to_wblock(dev); struct wmi_block *wblock = dev_to_wblock(dev);
kfree(wblock->dev.driver_override);
kfree(wblock); kfree(wblock);
} }
...@@ -854,6 +883,10 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver) ...@@ -854,6 +883,10 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver)
struct wmi_block *wblock = dev_to_wblock(dev); struct wmi_block *wblock = dev_to_wblock(dev);
const struct wmi_device_id *id = wmi_driver->id_table; const struct wmi_device_id *id = wmi_driver->id_table;
/* When driver_override is set, only bind to the matching driver */
if (wblock->dev.driver_override)
return !strcmp(wblock->dev.driver_override, driver->name);
if (id == NULL) if (id == NULL)
return 0; return 0;
......
...@@ -16,12 +16,16 @@ ...@@ -16,12 +16,16 @@
* struct wmi_device - WMI device structure * struct wmi_device - WMI device structure
* @dev: Device associated with this WMI device * @dev: Device associated with this WMI device
* @setable: True for devices implementing the Set Control Method * @setable: True for devices implementing the Set Control Method
* @driver_override: Driver name to force a match; do not set directly,
* because core frees it; use driver_set_override() to
* set or clear it.
* *
* This represents WMI devices discovered by the WMI driver core. * This represents WMI devices discovered by the WMI driver core.
*/ */
struct wmi_device { struct wmi_device {
struct device dev; struct device dev;
bool setable; bool setable;
const char *driver_override;
}; };
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment