diff options
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index c92532158195..680bb5647701 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -116,6 +116,63 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias, | |||
116 | return len; | 116 | return len; |
117 | } | 117 | } |
118 | 118 | ||
119 | /* | ||
120 | * Creates uevent modalias field for ACPI enumerated devices. | ||
121 | * Because the other buses does not support ACPI HIDs & CIDs. | ||
122 | * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get: | ||
123 | * "acpi:IBM0001:ACPI0001" | ||
124 | */ | ||
125 | int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) | ||
126 | { | ||
127 | struct acpi_device *acpi_dev; | ||
128 | int len; | ||
129 | |||
130 | acpi_dev = ACPI_COMPANION(dev); | ||
131 | if (!acpi_dev) | ||
132 | return -ENODEV; | ||
133 | |||
134 | /* Fall back to bus specific way of modalias exporting */ | ||
135 | if (list_empty(&acpi_dev->pnp.ids)) | ||
136 | return -ENODEV; | ||
137 | |||
138 | if (add_uevent_var(env, "MODALIAS=")) | ||
139 | return -ENOMEM; | ||
140 | len = create_modalias(acpi_dev, &env->buf[env->buflen - 1], | ||
141 | sizeof(env->buf) - env->buflen); | ||
142 | if (len <= 0) | ||
143 | return len; | ||
144 | env->buflen += len; | ||
145 | return 0; | ||
146 | } | ||
147 | EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias); | ||
148 | |||
149 | /* | ||
150 | * Creates modalias sysfs attribute for ACPI enumerated devices. | ||
151 | * Because the other buses does not support ACPI HIDs & CIDs. | ||
152 | * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get: | ||
153 | * "acpi:IBM0001:ACPI0001" | ||
154 | */ | ||
155 | int acpi_device_modalias(struct device *dev, char *buf, int size) | ||
156 | { | ||
157 | struct acpi_device *acpi_dev; | ||
158 | int len; | ||
159 | |||
160 | acpi_dev = ACPI_COMPANION(dev); | ||
161 | if (!acpi_dev) | ||
162 | return -ENODEV; | ||
163 | |||
164 | /* Fall back to bus specific way of modalias exporting */ | ||
165 | if (list_empty(&acpi_dev->pnp.ids)) | ||
166 | return -ENODEV; | ||
167 | |||
168 | len = create_modalias(acpi_dev, buf, size -1); | ||
169 | if (len <= 0) | ||
170 | return len; | ||
171 | buf[len++] = '\n'; | ||
172 | return len; | ||
173 | } | ||
174 | EXPORT_SYMBOL_GPL(acpi_device_modalias); | ||
175 | |||
119 | static ssize_t | 176 | static ssize_t |
120 | acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { | 177 | acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { |
121 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 178 | struct acpi_device *acpi_dev = to_acpi_device(dev); |