Merge tag 'libnvdimm-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm...
[platform/kernel/linux-rpi.git] / drivers / nvdimm / namespace_devs.c
index bbe5099..c60ec0b 100644 (file)
@@ -170,15 +170,12 @@ EXPORT_SYMBOL(nvdimm_namespace_disk_name);
 
 const uuid_t *nd_dev_to_uuid(struct device *dev)
 {
-       if (!dev)
-               return &uuid_null;
-
-       if (is_namespace_pmem(dev)) {
+       if (dev && is_namespace_pmem(dev)) {
                struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
 
                return nspm->uuid;
-       } else
-               return &uuid_null;
+       }
+       return &uuid_null;
 }
 EXPORT_SYMBOL(nd_dev_to_uuid);
 
@@ -388,7 +385,7 @@ static resource_size_t init_dpa_allocation(struct nd_label_id *label_id,
  *
  * BLK-space is valid as long as it does not precede a PMEM
  * allocation in a given region. PMEM-space must be contiguous
- * and adjacent to an existing existing allocation (if one
+ * and adjacent to an existing allocation (if one
  * exists).  If reserving PMEM any space is valid.
  */
 static void space_valid(struct nd_region *nd_region, struct nvdimm_drvdata *ndd,
@@ -839,7 +836,6 @@ static ssize_t size_store(struct device *dev,
 {
        struct nd_region *nd_region = to_nd_region(dev->parent);
        unsigned long long val;
-       uuid_t **uuid = NULL;
        int rc;
 
        rc = kstrtoull(buf, 0, &val);
@@ -853,16 +849,12 @@ static ssize_t size_store(struct device *dev,
        if (rc >= 0)
                rc = nd_namespace_label_update(nd_region, dev);
 
-       if (is_namespace_pmem(dev)) {
+       /* setting size zero == 'delete namespace' */
+       if (rc == 0 && val == 0 && is_namespace_pmem(dev)) {
                struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
 
-               uuid = &nspm->uuid;
-       }
-
-       if (rc == 0 && val == 0 && uuid) {
-               /* setting size zero == 'delete namespace' */
-               kfree(*uuid);
-               *uuid = NULL;
+               kfree(nspm->uuid);
+               nspm->uuid = NULL;
        }
 
        dev_dbg(dev, "%llx %s (%d)\n", val, rc < 0 ? "fail" : "success", rc);