UPSTREAM: selinux: Remove unnecessary check of array base in selinux_set_mapping()
[GitHub/LineageOS/android_kernel_samsung_universal7580.git] / block / partition-generic.c
index 789cdea05893bb8e3420ede5d1aa65e7af408e1b..93b0c80c020a0e10c3f105d47df851fbc0f24e33 100644 (file)
 #include <linux/genhd.h>
 #include <linux/blktrace_api.h>
 
+#ifdef CONFIG_BLOCK_SUPPORT_STLOG
+#include <linux/stlog.h>
+#else
+#define ST_LOG(fmt,...)
+#endif
+
 #include "partitions/check.h"
 
 #ifdef CONFIG_BLK_DEV_MD
@@ -211,15 +217,27 @@ static const struct attribute_group *part_attr_groups[] = {
 static void part_release(struct device *dev)
 {
        struct hd_struct *p = dev_to_part(dev);
+       blk_free_devt(dev->devt);
        free_part_stats(p);
        free_part_info(p);
        kfree(p);
 }
 
+static int part_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+       struct hd_struct *part = dev_to_part(dev);
+
+       add_uevent_var(env, "PARTN=%u", part->partno);
+       if (part->info && part->info->volname[0])
+               add_uevent_var(env, "PARTNAME=%s", part->info->volname);
+       return 0;
+}
+
 struct device_type part_type = {
        .name           = "partition",
        .groups         = part_attr_groups,
        .release        = part_release,
+       .uevent         = part_uevent,
 };
 
 static void delete_partition_rcu_cb(struct rcu_head *head)
@@ -242,6 +260,10 @@ void delete_partition(struct gendisk *disk, int partno)
        struct disk_part_tbl *ptbl = disk->part_tbl;
        struct hd_struct *part;
 
+#ifdef CONFIG_BLOCK_SUPPORT_STLOG
+       struct device *dev;
+#endif
+
        if (partno >= ptbl->len)
                return;
 
@@ -252,8 +274,12 @@ void delete_partition(struct gendisk *disk, int partno)
        rcu_assign_pointer(ptbl->part[partno], NULL);
        rcu_assign_pointer(ptbl->last_lookup, NULL);
        kobject_put(part->holder_dir);
+#ifdef CONFIG_BLOCK_SUPPORT_STLOG
+       dev = part_to_dev(part);
+       ST_LOG("<%s> KOBJ_REMOVE %d:%d %s",
+               __func__, MAJOR(dev->devt), MINOR(dev->devt), dev->kobj.name);
+#endif 
        device_del(part_to_dev(part));
-       blk_free_devt(part_devt(part));
 
        hd_struct_put(part);
 }