Skip to content

Commit 2460942

Browse files
jhovoldgregkh
authored andcommitted
serdev: do not generate modaliases for controllers
Serdev controllers are not bound to any drivers and it therefore makes no sense to generate modaliases for them. This has already been fixed separately for ACPI controllers for which uevent errors were also being logged during probe due to the missing ACPI companions (from which ACPI modaliases are generated). This patch moves the modalias handling from the bus type to the client device type. Specifically, this means that only serdev devices (a.k.a. clients or slaves) will have have MODALIAS fields in their uevent environments and corresponding modalias sysfs attributes. Also add the missing static keyword for the modalias device attribute when moving the definition. Reported-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f8bdfe9 commit 2460942

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

drivers/tty/serdev/core.c

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,47 @@
1919
static bool is_registered;
2020
static DEFINE_IDA(ctrl_ida);
2121

22+
static ssize_t modalias_show(struct device *dev,
23+
struct device_attribute *attr, char *buf)
24+
{
25+
int len;
26+
27+
len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
28+
if (len != -ENODEV)
29+
return len;
30+
31+
return of_device_modalias(dev, buf, PAGE_SIZE);
32+
}
33+
static DEVICE_ATTR_RO(modalias);
34+
35+
static struct attribute *serdev_device_attrs[] = {
36+
&dev_attr_modalias.attr,
37+
NULL,
38+
};
39+
ATTRIBUTE_GROUPS(serdev_device);
40+
41+
static int serdev_device_uevent(struct device *dev, struct kobj_uevent_env *env)
42+
{
43+
int rc;
44+
45+
/* TODO: platform modalias */
46+
47+
rc = acpi_device_uevent_modalias(dev, env);
48+
if (rc != -ENODEV)
49+
return rc;
50+
51+
return of_device_uevent_modalias(dev, env);
52+
}
53+
2254
static void serdev_device_release(struct device *dev)
2355
{
2456
struct serdev_device *serdev = to_serdev_device(dev);
2557
kfree(serdev);
2658
}
2759

2860
static const struct device_type serdev_device_type = {
61+
.groups = serdev_device_groups,
62+
.uevent = serdev_device_uevent,
2963
.release = serdev_device_release,
3064
};
3165

@@ -49,23 +83,6 @@ static int serdev_device_match(struct device *dev, struct device_driver *drv)
4983
return of_driver_match_device(dev, drv);
5084
}
5185

52-
static int serdev_uevent(struct device *dev, struct kobj_uevent_env *env)
53-
{
54-
int rc;
55-
56-
/* TODO: platform modalias */
57-
58-
/* ACPI enumerated controllers do not have a modalias */
59-
if (!dev->of_node && dev->type == &serdev_ctrl_type)
60-
return 0;
61-
62-
rc = acpi_device_uevent_modalias(dev, env);
63-
if (rc != -ENODEV)
64-
return rc;
65-
66-
return of_device_uevent_modalias(dev, env);
67-
}
68-
6986
/**
7087
* serdev_device_add() - add a device previously constructed via serdev_device_alloc()
7188
* @serdev: serdev_device to be added
@@ -305,32 +322,11 @@ static int serdev_drv_remove(struct device *dev)
305322
return 0;
306323
}
307324

308-
static ssize_t modalias_show(struct device *dev,
309-
struct device_attribute *attr, char *buf)
310-
{
311-
int len;
312-
313-
len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
314-
if (len != -ENODEV)
315-
return len;
316-
317-
return of_device_modalias(dev, buf, PAGE_SIZE);
318-
}
319-
DEVICE_ATTR_RO(modalias);
320-
321-
static struct attribute *serdev_device_attrs[] = {
322-
&dev_attr_modalias.attr,
323-
NULL,
324-
};
325-
ATTRIBUTE_GROUPS(serdev_device);
326-
327325
static struct bus_type serdev_bus_type = {
328326
.name = "serial",
329327
.match = serdev_device_match,
330328
.probe = serdev_drv_probe,
331329
.remove = serdev_drv_remove,
332-
.uevent = serdev_uevent,
333-
.dev_groups = serdev_device_groups,
334330
};
335331

336332
/**

0 commit comments

Comments
 (0)