int size)
{
int len;
+ int count;
- if (!acpi_dev->flags.hardware_id)
+ if (!acpi_dev->flags.hardware_id && !acpi_dev->flags.compatible_ids)
return -ENODEV;
- len = snprintf(modalias, size, "acpi:%s:",
- acpi_dev->pnp.hardware_id);
- if (len < 0 || len >= size)
- return -EINVAL;
+ len = snprintf(modalias, size, "acpi:");
size -= len;
+ if (acpi_dev->flags.hardware_id) {
+ count = snprintf(&modalias[len], size, "%s:",
+ acpi_dev->pnp.hardware_id);
+ if (count < 0 || count >= size)
+ return -EINVAL;
+ len += count;
+ size -= count;
+ }
+
if (acpi_dev->flags.compatible_ids) {
struct acpi_compatible_id_list *cid_list;
int i;
- int count;
cid_list = acpi_dev->pnp.cid_list;
for (i = 0; i < cid_list->count; i++) {