Cleanup implementation for __pwm_create_sysfs. Signed-off-by: Marc Pignat <marc.pignat@xxxxxxx> --- Hi all! Here is a missing piece in the generic pwm implementation. Bill, the code is simpler that you was thinking ;) In facts, attributes are deleted by device_unregister -> there is nothing to worry about attributes (un-)successful creation. Finding which device was created is also trivial (thanks to class_find_device). Best regards Marc diff --git a/drivers/pwm/pwm.c b/drivers/pwm/pwm.c index 2f28c20..391f820 100644 --- a/drivers/pwm/pwm.c +++ b/drivers/pwm/pwm.c @@ -626,15 +626,23 @@ static int __pwm_create_sysfs(struct pwm_device *pwm) goto err_dev_create; ret = sysfs_create_group(&dev->kobj, &pwm_device_attr_group); if (ret) - goto err_dev_group_create; + goto err_dev_create; } return ret; -err_dev_group_create: err_dev_create: - /* TODO: undo all the successful device_create calls */ - return -ENODEV; + for (wchan = 0; wchan < pwm->nchan; wchan++) { + dev = class_find_device(&pwm_class, NULL, + &pwm->channels[wchan], + __match_device); + if (dev) { + put_device(dev); + device_unregister(dev); + } + } + + return ret; } -- To unsubscribe from this list: send the line "unsubscribe linux-embedded" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html