diff options
-rw-r--r-- | drivers/base/platform.c | 19 | ||||
-rw-r--r-- | include/linux/device.h | 4 |
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1ba9d617d24..d2d4926c5c4 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -1239,6 +1239,25 @@ static int __init early_platform_driver_probe_id(char *class_str, | |||
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | if (match) { | 1241 | if (match) { |
1242 | /* | ||
1243 | * Set up a sensible init_name to enable | ||
1244 | * dev_name() and others to be used before the | ||
1245 | * rest of the driver core is initialized. | ||
1246 | */ | ||
1247 | if (!match->dev.init_name) { | ||
1248 | char buf[32]; | ||
1249 | |||
1250 | if (match->id != -1) | ||
1251 | snprintf(buf, sizeof(buf), "%s.%d", | ||
1252 | match->name, match->id); | ||
1253 | else | ||
1254 | snprintf(buf, sizeof(buf), "%s", | ||
1255 | match->name); | ||
1256 | |||
1257 | match->dev.init_name = kstrdup(buf, GFP_KERNEL); | ||
1258 | if (!match->dev.init_name) | ||
1259 | return -ENOMEM; | ||
1260 | } | ||
1242 | if (epdrv->pdrv->probe(match)) | 1261 | if (epdrv->pdrv->probe(match)) |
1243 | pr_warning("%s: unable to probe %s early.\n", | 1262 | pr_warning("%s: unable to probe %s early.\n", |
1244 | class_str, match->name); | 1263 | class_str, match->name); |
diff --git a/include/linux/device.h b/include/linux/device.h index 182192892d4..241b96bcd7a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -451,6 +451,10 @@ struct device { | |||
451 | 451 | ||
452 | static inline const char *dev_name(const struct device *dev) | 452 | static inline const char *dev_name(const struct device *dev) |
453 | { | 453 | { |
454 | /* Use the init name until the kobject becomes available */ | ||
455 | if (dev->init_name) | ||
456 | return dev->init_name; | ||
457 | |||
454 | return kobject_name(&dev->kobj); | 458 | return kobject_name(&dev->kobj); |
455 | } | 459 | } |
456 | 460 | ||