提交 7246c31e 编写于 作者: H Helge Deller 提交者: Kyle McMartin

parisc: add uevent helper for parisc bus

parisc: add uevent helper for parisc bus

udev device-driver auto detection was failing to work on the GSC bus, since
udev didn't knew wich driver to load due to a missing MODALIAS environment
variable from kernel.

This patch fixes this by adding the MODALIAS environment variable to the
uevent kernel notifications.
Since modalias_show() generated the modalias string already, I splitted this
out and created a new static function make_modalias() which is now used by
modalias_show() and the new parisc_uevent() function.

Tested on 715/64 and c3000.
Signed-off-by: NHelge Deller <deller@gmx.de>
Signed-off-by: NKyle McMartin <kyle@mcmartin.ca>
上级 5fbf6635
...@@ -549,6 +549,38 @@ static int parisc_generic_match(struct device *dev, struct device_driver *drv) ...@@ -549,6 +549,38 @@ static int parisc_generic_match(struct device *dev, struct device_driver *drv)
return match_device(to_parisc_driver(drv), to_parisc_device(dev)); return match_device(to_parisc_driver(drv), to_parisc_device(dev));
} }
static ssize_t make_modalias(struct device *dev, char *buf)
{
const struct parisc_device *padev = to_parisc_device(dev);
const struct parisc_device_id *id = &padev->id;
return sprintf(buf, "parisc:t%02Xhv%04Xrev%02Xsv%08X\n",
(u8)id->hw_type, (u16)id->hversion, (u8)id->hversion_rev,
(u32)id->sversion);
}
static int parisc_uevent(struct device *dev, struct kobj_uevent_env *env)
{
const struct parisc_device *padev;
char modalias[40];
if (!dev)
return -ENODEV;
padev = to_parisc_device(dev);
if (!padev)
return -ENODEV;
if (add_uevent_var(env, "PARISC_NAME=%s", padev->name))
return -ENOMEM;
make_modalias(dev, modalias);
if (add_uevent_var(env, "MODALIAS=%s", modalias))
return -ENOMEM;
return 0;
}
#define pa_dev_attr(name, field, format_string) \ #define pa_dev_attr(name, field, format_string) \
static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf) \ static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf) \
{ \ { \
...@@ -566,12 +598,7 @@ pa_dev_attr_id(sversion, "0x%05x\n"); ...@@ -566,12 +598,7 @@ pa_dev_attr_id(sversion, "0x%05x\n");
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct parisc_device *padev = to_parisc_device(dev); return make_modalias(dev, buf);
struct parisc_device_id *id = &padev->id;
return sprintf(buf, "parisc:t%02Xhv%04Xrev%02Xsv%08X\n",
(u8)id->hw_type, (u16)id->hversion, (u8)id->hversion_rev,
(u32)id->sversion);
} }
static struct device_attribute parisc_device_attrs[] = { static struct device_attribute parisc_device_attrs[] = {
...@@ -587,6 +614,7 @@ static struct device_attribute parisc_device_attrs[] = { ...@@ -587,6 +614,7 @@ static struct device_attribute parisc_device_attrs[] = {
struct bus_type parisc_bus_type = { struct bus_type parisc_bus_type = {
.name = "parisc", .name = "parisc",
.match = parisc_generic_match, .match = parisc_generic_match,
.uevent = parisc_uevent,
.dev_attrs = parisc_device_attrs, .dev_attrs = parisc_device_attrs,
.probe = parisc_driver_probe, .probe = parisc_driver_probe,
.remove = parisc_driver_remove, .remove = parisc_driver_remove,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册