return ns;
 }
 
+static void device_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
+{
+       struct device *dev = kobj_to_dev(kobj);
+
+       if (dev->class && dev->class->get_ownership)
+               dev->class->get_ownership(dev, uid, gid);
+}
+
 static struct kobj_type device_ktype = {
        .release        = device_release,
        .sysfs_ops      = &dev_sysfs_ops,
        .namespace      = device_namespace,
+       .get_ownership  = device_get_ownership,
 };
 
 
 
  * @shutdown_pre: Called at shut-down time before driver shutdown.
  * @ns_type:   Callbacks so sysfs can detemine namespaces.
  * @namespace: Namespace of the device belongs to this class.
+ * @get_ownership: Allows class to specify uid/gid of the sysfs directories
+ *             for the devices belonging to the class. Usually tied to
+ *             device's namespace.
  * @pm:                The default device power management operations of this class.
  * @p:         The private data of the driver core, no one other than the
  *             driver core can touch this.
        const struct kobj_ns_type_operations *ns_type;
        const void *(*namespace)(struct device *dev);
 
+       void (*get_ownership)(struct device *dev, kuid_t *uid, kgid_t *gid);
+
        const struct dev_pm_ops *pm;
 
        struct subsys_private *p;