summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi-sysfs.c
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2012-03-21 19:12:02 +0000
committerShaun Ruffell <sruffell@digium.com>2012-03-21 19:12:02 +0000
commit4b40ea123289c9f785f0cd16184a34b2237dff15 (patch)
tree97027fb5b33795362b7de903f86013fe1f28cae3 /drivers/dahdi/dahdi-sysfs.c
parentbef97f2ff7f9fd7e9e2973111a0dc5b1445a72a1 (diff)
A parent-less device should not crash dahdi
* A parent-less device should not crash dahdi: - Access span->parent->dev instead of span->parent-dev.parent in soem cases. - Access span->parent->dev via new inline span_device() - Use span_device() in all dahdi_dev_{dbg,info}() * Allow low-level drivers to set their device name. - Drivers that don't use this feature get the default name based on the parent device name - Parent-less devices which don't set their name, fails to register with -EINVAL Signed-off-by: Oron Peled <oron.peled@xorcom.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10449 git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10568 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi-sysfs.c')
-rw-r--r--drivers/dahdi/dahdi-sysfs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c
index a03aba8..3e6d157 100644
--- a/drivers/dahdi/dahdi-sysfs.c
+++ b/drivers/dahdi/dahdi-sysfs.c
@@ -796,10 +796,17 @@ int dahdi_sysfs_add_device(struct dahdi_device *ddev, struct device *parent)
{
int ret;
struct device *const dev = &ddev->dev;
+ const char *dn;
dev->parent = parent;
dev->bus = &dahdi_device_bus;
- dev_set_name(dev, "%s:%s", parent->bus->name, dev_name(parent));
+ dn = dev_name(dev);
+ if (!dn || !*dn) {
+ /* Invent default name based on parent */
+ if (!parent)
+ return -EINVAL;
+ dev_set_name(dev, "%s:%s", parent->bus->name, dev_name(parent));
+ }
ret = device_add(dev);
return ret;
}