sysfs: do not create empty directories if no attributes are present

When creating an attribute group, if it is named a subdirectory is
created and the sysfs files are placed into that subdirectory.  If no
files are created, normally the directory would still be present, but it
would be empty.  Clean this up by removing the directory if no files
were successfully created in the group at all.

Co-developed-by: Greg Kroah-Hartman <>
Signed-off-by: Greg Kroah-Hartman <>
Co-developed-by: Alistair Francis <>
Signed-off-by: Alistair Francis <>
2 files changed