Skip to contentSkip to conversation

nvdimm: Use more common kernel coding style

PATCH In review Joe Perches 8 participants 34 messages Sep 12, 2019 – Sep 16, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover nvdimm: Use more common kernel coding style

Rather than have a local coding style, use the typical kernel style.

Joe Perches (13):
nvdimm: Use more typical whitespace
nvdimm: Move logical continuations to previous line
nvdimm: Use octal permissions
nvdimm: Use a more common kernel spacing style
nvdimm: Use "unsigned int" in preference to "unsigned"
nvdimm: Add and remove blank lines
nvdimm: Use typical kernel brace styles
nvdimm: Use typical kernel style indentation
nvdimm: btt.h: Neaten #defines to improve readability
nvdimm: namespace_devs: Move assignment operators
nvdimm: Use more common logic testing styles and bare ; positions
nvdimm: namespace_devs: Change progess typo to progress
nvdimm: Miscellaneous neatening

 drivers/nvdimm/badrange.c       |  22 +-
 drivers/nvdimm/blk.c            |  39 ++--
 drivers/nvdimm/btt.c            | 249 +++++++++++----------
 drivers/nvdimm/btt.h            |  56 ++---
 drivers/nvdimm/btt_devs.c       |  68 +++---
 drivers/nvdimm/bus.c            | 138 ++++++------
 drivers/nvdimm/claim.c          |  50 ++---
 drivers/nvdimm/core.c           |  42 ++--
 drivers/nvdimm/dax_devs.c       |   3 +-
 drivers/nvdimm/dimm.c           |   3 +-
 drivers/nvdimm/dimm_devs.c      | 107 ++++-----
 drivers/nvdimm/e820.c           |   2 +-
 drivers/nvdimm/label.c          | 213 +++++++++---------
 drivers/nvdimm/label.h          |   6 +-
 drivers/nvdimm/namespace_devs.c | 472 +++++++++++++++++++++-------------------
 drivers/nvdimm/nd-core.h        |  31 +--
 drivers/nvdimm/nd.h             |  94 ++++----
 drivers/nvdimm/nd_virtio.c      |  20 +-
 drivers/nvdimm/of_pmem.c        |   6 +-
 drivers/nvdimm/pfn_devs.c       | 136 ++++++------
 drivers/nvdimm/pmem.c           |  57 ++---
 drivers/nvdimm/pmem.h           |   2 +-
 drivers/nvdimm/region.c         |  20 +-
 drivers/nvdimm/region_devs.c    | 160 +++++++-------
 drivers/nvdimm/security.c       | 138 ++++++------
 drivers/nvdimm/virtio_pmem.c    |  10 +-
 26 files changed, 1115 insertions(+), 1029 deletions(-)
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw

PATCH 1/13 nvdimm: Use more typical whitespace

Convert the file to a more common kernel whitespace style to make this more like other kernel files

git diff -w shows no difference.

---
 drivers/nvdimm/badrange.c       |  18 +--
 drivers/nvdimm/blk.c            |  26 ++--
 drivers/nvdimm/btt.c            | 192 +++++++++++++--------------
 drivers/nvdimm/btt.h            |   2 +-
 drivers/nvdimm/btt_devs.c       |  42 +++---
 drivers/nvdimm/bus.c            | 100 +++++++-------
 drivers/nvdimm/claim.c          |  36 +++---
 drivers/nvdimm/core.c           |  36 +++---
 drivers/nvdimm/dimm.c           |   2 +-
 drivers/nvdimm/dimm_devs.c      |  68 +++++-----
 drivers/nvdimm/e820.c           |   2 +-
 drivers/nvdimm/label.c          | 146 ++++++++++-----------
 drivers/nvdimm/label.h          |   4 +-
 drivers/nvdimm/namespace_devs.c | 280 ++++++++++++++++++++--------------------
 drivers/nvdimm/nd-core.h        |  26 ++--
 drivers/nvdimm/nd.h             |  66 +++++-----
 drivers/nvdimm/nd_virtio.c      |  18 +--
 drivers/nvdimm/of_pmem.c        |   6 +-
 drivers/nvdimm/pfn_devs.c       |  86 ++++++------
 drivers/nvdimm/pmem.c           |  44 +++----
 drivers/nvdimm/pmem.h           |   2 +-
 drivers/nvdimm/region.c         |  16 +--
 drivers/nvdimm/region_devs.c    | 122 ++++++++---------
 drivers/nvdimm/security.c       |  84 ++++++------
 drivers/nvdimm/virtio_pmem.c    |   8 +-
 25 files changed, 716 insertions(+), 716 deletions(-)
drivers/nvdimm/badrange.c +9 -9
index b9eeefa27e3a..b997c2007b83 100644
@@ -24,7 +24,7 @@ void badrange_init(struct badrange *badrange)
 EXPORT_SYMBOL_GPL(badrange_init);
 
 static void append_badrange_entry(struct badrange *badrange,
-		struct badrange_entry *bre, u64 addr, u64 length)
+				  struct badrange_entry *bre, u64 addr, u64 length)
 {
 	lockdep_assert_held(&badrange->lock);
 	bre->start = addr;
@@ -33,7 +33,7 @@ static void append_badrange_entry(struct badrange *badrange,
 }
 
 static int alloc_and_append_badrange_entry(struct badrange *badrange,
-		u64 addr, u64 length, gfp_t flags)
+					   u64 addr, u64 length, gfp_t flags)
 {
 	struct badrange_entry *bre;
 
@@ -99,7 +99,7 @@ int badrange_add(struct badrange *badrange, u64 addr, u64 length)
 EXPORT_SYMBOL_GPL(badrange_add);
 
 void badrange_forget(struct badrange *badrange, phys_addr_t start,
-		unsigned int len)
+		     unsigned int len)
 {
 	struct list_head *badrange_list = &badrange->list;
 	u64 clr_end = start + len - 1;
@@ -152,7 +152,7 @@ void badrange_forget(struct badrange *badrange, phys_addr_t start,
 
 			/* Add new entry covering the right half */
 			alloc_and_append_badrange_entry(badrange, new_start,
-					new_len, GFP_NOWAIT);
+							new_len, GFP_NOWAIT);
 			/* Adjust this entry to cover the left half */
 			bre->length = start - bre->start;
 			continue;
@@ -165,11 +165,11 @@ EXPORT_SYMBOL_GPL(badrange_forget);
 static void set_badblock(struct badblocks *bb, sector_t s, int num)
 {
 	dev_dbg(bb->dev, "Found a bad range (0x%llx, 0x%llx)\n",
-			(u64) s * 512, (u64) num * 512);
+		(u64) s * 512, (u64) num * 512);
 	/* this isn't an error as the hardware will still throw an exception */
 	if (badblocks_set(bb, s, num, 1))
 		dev_info_once(bb->dev, "%s: failed for sector %llx\n",
-				__func__, (u64) s);
+			      __func__, (u64) s);
 }
 
 /**
@@ -211,7 +211,7 @@ static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len)
 }
 
 static void badblocks_populate(struct badrange *badrange,
-		struct badblocks *bb, const struct resource *res)
+			       struct badblocks *bb, const struct resource *res)
 {
 	struct badrange_entry *bre;
 
@@ -267,13 +267,13 @@ static void badblocks_populate(struct badrange *badrange,
  * and add badblocks entries for all matching sub-ranges
  */
 void nvdimm_badblocks_populate(struct nd_region *nd_region,
-		struct badblocks *bb, const struct resource *res)
+			       struct badblocks *bb, const struct resource *res)
 {
 	struct nvdimm_bus *nvdimm_bus;
 
 	if (!is_memory(&nd_region->dev)) {
 		dev_WARN_ONCE(&nd_region->dev, 1,
-				"%s only valid for pmem regions\n", __func__);
+			      "%s only valid for pmem regions\n", __func__);
 		return;
 	}
 	nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev);
drivers/nvdimm/blk.c +13 -13
index 677d6f45b5c4..edd3e1664edc 100644
@@ -29,7 +29,7 @@ static u32 nsblk_sector_size(struct nd_namespace_blk *nsblk)
 }
 
 static resource_size_t to_dev_offset(struct nd_namespace_blk *nsblk,
-				resource_size_t ns_offset, unsigned int len)
+				     resource_size_t ns_offset, unsigned int len)
 {
 	int i;
 
@@ -37,7 +37,7 @@ static resource_size_t to_dev_offset(struct nd_namespace_blk *nsblk,
 		if (ns_offset < resource_size(nsblk->res[i])) {
 			if (ns_offset + len > resource_size(nsblk->res[i])) {
 				dev_WARN_ONCE(&nsblk->common.dev, 1,
-					"illegal request\n");
+					      "illegal request\n");
 				return SIZE_MAX;
 			}
 			return nsblk->res[i]->start + ns_offset;
@@ -61,7 +61,7 @@ static struct nd_blk_region *to_ndbr(struct nd_namespace_blk *nsblk)
 
 #ifdef CONFIG_BLK_DEV_INTEGRITY
 static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
-		struct bio_integrity_payload *bip, u64 lba, int rw)
+			       struct bio_integrity_payload *bip, u64 lba, int rw)
 {
 	struct nd_blk_region *ndbr = to_ndbr(nsblk);
 	unsigned int len = nsblk_meta_size(nsblk);
@@ -91,7 +91,7 @@ static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
 		cur_len = min(len, bv.bv_len);
 		iobuf = kmap_atomic(bv.bv_page);
 		err = ndbr->do_io(ndbr, dev_offset, iobuf + bv.bv_offset,
-				cur_len, rw);
+				  cur_len, rw);
 		kunmap_atomic(iobuf);
 		if (err)
 			return err;
@@ -107,15 +107,15 @@ static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
 
 #else /* CONFIG_BLK_DEV_INTEGRITY */
 static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
-		struct bio_integrity_payload *bip, u64 lba, int rw)
+			       struct bio_integrity_payload *bip, u64 lba, int rw)
 {
 	return 0;
 }
 #endif
 
 static int nsblk_do_bvec(struct nd_namespace_blk *nsblk,
-		struct bio_integrity_payload *bip, struct page *page,
-		unsigned int len, unsigned int off, int rw, sector_t sector)
+			 struct bio_integrity_payload *bip, struct page *page,
+			 unsigned int len, unsigned int off, int rw, sector_t sector)
 {
 	struct nd_blk_region *ndbr = to_ndbr(nsblk);
 	resource_size_t	dev_offset, ns_offset;
@@ -184,12 +184,12 @@ static blk_qc_t nd_blk_make_request(struct request_queue *q, struct bio *bio)
 
 		BUG_ON(len > PAGE_SIZE);
 		err = nsblk_do_bvec(nsblk, bip, bvec.bv_page, len,
-				bvec.bv_offset, rw, iter.bi_sector);
+				    bvec.bv_offset, rw, iter.bi_sector);
 		if (err) {
 			dev_dbg(&nsblk->common.dev,
-					"io error in %s sector %lld, len %d,\n",
-					(rw == READ) ? "READ" : "WRITE",
-					(unsigned long long) iter.bi_sector, len);
+				"io error in %s sector %lld, len %d,\n",
+				(rw == READ) ? "READ" : "WRITE",
+				(unsigned long long) iter.bi_sector, len);
 			bio->bi_status = errno_to_blk_status(err);
 			break;
 		}
@@ -202,8 +202,8 @@ static blk_qc_t nd_blk_make_request(struct request_queue *q, struct bio *bio)
 }
 
 static int nsblk_rw_bytes(struct nd_namespace_common *ndns,
-		resource_size_t offset, void *iobuf, size_t n, int rw,
-		unsigned long flags)
+			  resource_size_t offset, void *iobuf, size_t n, int rw,
+			  unsigned long flags)
 {
 	struct nd_namespace_blk *nsblk = to_nd_namespace_blk(&ndns->dev);
 	struct nd_blk_region *ndbr = to_ndbr(nsblk);
drivers/nvdimm/btt.c +96 -96

615 lines not on this page · raw message

drivers/nvdimm/btt.h +1 -1
index 2e258bee7db2..1da76da3e159 100644
@@ -235,6 +235,6 @@ struct btt {
 
 bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super);
 int nd_btt_version(struct nd_btt *nd_btt, struct nd_namespace_common *ndns,
-		struct btt_sb *btt_sb);
+		   struct btt_sb *btt_sb);
 
 #endif
drivers/nvdimm/btt_devs.c +21 -21

152 lines not on this page · raw message

drivers/nvdimm/bus.c +50 -50

352 lines not on this page · raw message

drivers/nvdimm/claim.c +18 -18
index 2985ca949912..62f3afaa7d27 100644
@@ -27,7 +27,7 @@ void __nd_detach_ndns(struct device *dev, struct nd_namespace_common **_ndns)
 }
 
 void nd_detach_ndns(struct device *dev,
-		struct nd_namespace_common **_ndns)
+		    struct nd_namespace_common **_ndns)
 {
 	struct nd_namespace_common *ndns = *_ndns;
 
@@ -41,7 +41,7 @@ void nd_detach_ndns(struct device *dev,
 }
 
 bool __nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach,
-		struct nd_namespace_common **_ndns)
+		      struct nd_namespace_common **_ndns)
 {
 	struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&attach->dev);
 
@@ -56,7 +56,7 @@ bool __nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach,
 }
 
 bool nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach,
-		struct nd_namespace_common **_ndns)
+		    struct nd_namespace_common **_ndns)
 {
 	bool claimed;
 
@@ -110,7 +110,7 @@ struct nd_pfn *to_nd_pfn_safe(struct device *dev)
 }
 
 static void nd_detach_and_reset(struct device *dev,
-		struct nd_namespace_common **_ndns)
+				struct nd_namespace_common **_ndns)
 {
 	/* detach the namespace and destroy / reset the device */
 	__nd_detach_ndns(dev, _ndns);
@@ -132,8 +132,8 @@ static void nd_detach_and_reset(struct device *dev,
 }
 
 ssize_t nd_namespace_store(struct device *dev,
-		struct nd_namespace_common **_ndns, const char *buf,
-		size_t len)
+			   struct nd_namespace_common **_ndns, const char *buf,
+			   size_t len)
 {
 	struct nd_namespace_common *ndns;
 	struct device *found;
@@ -162,7 +162,7 @@ ssize_t nd_namespace_store(struct device *dev,
 		goto out;
 	} else if (ndns) {
 		dev_dbg(dev, "namespace already set to: %s\n",
-				dev_name(&ndns->dev));
+			dev_name(&ndns->dev));
 		len = -EBUSY;
 		goto out;
 	}
@@ -170,7 +170,7 @@ ssize_t nd_namespace_store(struct device *dev,
 	found = device_find_child(dev->parent, name, namespace_match);
 	if (!found) {
 		dev_dbg(dev, "'%s' not found under %s\n", name,
-				dev_name(dev->parent));
+			dev_name(dev->parent));
 		len = -ENODEV;
 		goto out;
 	}
@@ -214,13 +214,13 @@ ssize_t nd_namespace_store(struct device *dev,
 	WARN_ON_ONCE(!is_nvdimm_bus_locked(dev));
 	if (!__nd_attach_ndns(dev, ndns, _ndns)) {
 		dev_dbg(dev, "%s already claimed\n",
-				dev_name(&ndns->dev));
+			dev_name(&ndns->dev));
 		len = -EBUSY;
 	}
 
- out_attach:
+out_attach:
 	put_device(&ndns->dev); /* from device_find_child */
- out:
+out:
 	kfree(name);
 	return len;
 }
@@ -249,8 +249,8 @@ u64 nd_sb_checksum(struct nd_gen_sb *nd_gen_sb)
 EXPORT_SYMBOL(nd_sb_checksum);
 
 static int nsio_rw_bytes(struct nd_namespace_common *ndns,
-		resource_size_t offset, void *buf, size_t size, int rw,
-		unsigned long flags)
+			 resource_size_t offset, void *buf, size_t size, int rw,
+			 unsigned long flags)
 {
 	struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
 	unsigned int sz_align = ALIGN(size + (offset & (512 - 1)), 512);
@@ -275,12 +275,12 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
 
 	if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) {
 		if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512)
-				&& !(flags & NVDIMM_IO_ATOMIC)) {
+		    && !(flags & NVDIMM_IO_ATOMIC)) {
 			long cleared;
 
 			might_sleep();
 			cleared = nvdimm_clear_poison(&ndns->dev,
-					nsio->res.start + offset, size);
+						      nsio->res.start + offset, size);
 			if (cleared < size)
 				rc = -EIO;
 			if (cleared > 0 && cleared / 512) {
@@ -307,7 +307,7 @@ int devm_nsio_enable(struct device *dev, struct nd_namespace_io *nsio)
 
 	nsio->size = resource_size(res);
 	if (!devm_request_mem_region(dev, res->start, resource_size(res),
-				dev_name(&ndns->dev))) {
+				     dev_name(&ndns->dev))) {
 		dev_warn(dev, "could not reserve region %pR\n", res);
 		return -EBUSY;
 	}
@@ -316,10 +316,10 @@ int devm_nsio_enable(struct device *dev, struct nd_namespace_io *nsio)
 	if (devm_init_badblocks(dev, &nsio->bb))
 		return -ENOMEM;
 	nvdimm_badblocks_populate(to_nd_region(ndns->dev.parent), &nsio->bb,
-			&nsio->res);
+				  &nsio->res);
 
 	nsio->addr = devm_memremap(dev, res->start, resource_size(res),
-			ARCH_MEMREMAP_PMEM);
+				   ARCH_MEMREMAP_PMEM);
 
 	return PTR_ERR_OR_ZERO(nsio->addr);
 }
drivers/nvdimm/core.c +18 -18
index 9204f1e9fd14..b3ff3e62d847 100644
@@ -63,7 +63,7 @@ struct nvdimm_map {
 };
 
 static struct nvdimm_map *find_nvdimm_map(struct device *dev,
-		resource_size_t offset)
+					  resource_size_t offset)
 {
 	struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
 	struct nvdimm_map *nvdimm_map;
@@ -75,7 +75,7 @@ static struct nvdimm_map *find_nvdimm_map(struct device *dev,
 }
 
 static struct nvdimm_map *alloc_nvdimm_map(struct device *dev,
-		resource_size_t offset, size_t size, unsigned long flags)
+					   resource_size_t offset, size_t size, unsigned long flags)
 {
 	struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
 	struct nvdimm_map *nvdimm_map;
@@ -93,7 +93,7 @@ static struct nvdimm_map *alloc_nvdimm_map(struct device *dev,
 
 	if (!request_mem_region(offset, size, dev_name(&nvdimm_bus->dev))) {
 		dev_err(&nvdimm_bus->dev, "failed to request %pa + %zd for %s\n",
-				&offset, size, dev_name(dev));
+			&offset, size, dev_name(dev));
 		goto err_request_region;
 	}
 
@@ -106,14 +106,14 @@ static struct nvdimm_map *alloc_nvdimm_map(struct device *dev,
 		goto err_map;
 
 	dev_WARN_ONCE(dev, !is_nvdimm_bus_locked(dev), "%s: bus unlocked!",
-			__func__);
+		      __func__);
 	list_add(&nvdimm_map->list, &nvdimm_bus->mapping_list);
 
 	return nvdimm_map;
 
- err_map:
+err_map:
 	release_mem_region(offset, size);
- err_request_region:
+err_request_region:
 	kfree(nvdimm_map);
 	return NULL;
 }
@@ -154,7 +154,7 @@ static void nvdimm_map_put(void *data)
  * @flags: memremap flags, or, if zero, perform an ioremap instead
  */
 void *devm_nvdimm_memremap(struct device *dev, resource_size_t offset,
-		size_t size, unsigned long flags)
+			   size_t size, unsigned long flags)
 {
 	struct nvdimm_map *nvdimm_map;
 
@@ -214,7 +214,7 @@ static bool is_uuid_sep(char sep)
 }
 
 static int nd_uuid_parse(struct device *dev, u8 *uuid_out, const char *buf,
-		size_t len)
+			 size_t len)
 {
 	const char *str = buf;
 	u8 uuid[16];
@@ -223,8 +223,8 @@ static int nd_uuid_parse(struct device *dev, u8 *uuid_out, const char *buf,
 	for (i = 0; i < 16; i++) {
 		if (!isxdigit(str[0]) || !isxdigit(str[1])) {
 			dev_dbg(dev, "pos: %d buf[%zd]: %c buf[%zd]: %c\n",
-					i, str - buf, str[0],
-					str + 1 - buf, str[1]);
+				i, str - buf, str[0],
+				str + 1 - buf, str[1]);
 			return -EINVAL;
 		}
 
@@ -249,7 +249,7 @@ static int nd_uuid_parse(struct device *dev, u8 *uuid_out, const char *buf,
  * LOCKING: expects nd_device_lock() is held on entry
  */
 int nd_uuid_store(struct device *dev, u8 **uuid_out, const char *buf,
-		size_t len)
+		  size_t len)
 {
 	u8 uuid[16];
 	int rc;
@@ -270,7 +270,7 @@ int nd_uuid_store(struct device *dev, u8 **uuid_out, const char *buf,
 }
 
 ssize_t nd_size_select_show(unsigned long current_size,
-		const unsigned long *supported, char *buf)
+			    const unsigned long *supported, char *buf)
 {
 	ssize_t len = 0;
 	int i;
@@ -285,7 +285,7 @@ ssize_t nd_size_select_show(unsigned long current_size,
 }
 
 ssize_t nd_size_select_store(struct device *dev, const char *buf,
-		unsigned long *current_size, const unsigned long *supported)
+			     unsigned long *current_size, const unsigned long *supported)
 {
 	unsigned long lbasize;
 	int rc, i;
@@ -310,7 +310,7 @@ ssize_t nd_size_select_store(struct device *dev, const char *buf,
 }
 
 static ssize_t commands_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
+			     struct device_attribute *attr, char *buf)
 {
 	int cmd, len = 0;
 	struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
@@ -337,7 +337,7 @@ static const char *nvdimm_bus_provider(struct nvdimm_bus *nvdimm_bus)
 }
 
 static ssize_t provider_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
+			     struct device_attribute *attr, char *buf)
 {
 	struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
 
@@ -361,7 +361,7 @@ static int flush_regions_dimms(struct device *dev, void *data)
 }
 
 static ssize_t wait_probe_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
+			       struct device_attribute *attr, char *buf)
 {
 	struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
 	struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
@@ -442,9 +442,9 @@ static __init int libnvdimm_init(void)
 	nd_label_init();
 
 	return 0;
- err_region:
+err_region:
 	nvdimm_exit();
- err_dimm:
+err_dimm:
 	nvdimm_bus_exit();
 	return rc;
 }
drivers/nvdimm/dimm.c +1 -1
index 64776ed15bb3..916710ae647f 100644
@@ -108,7 +108,7 @@ static int nvdimm_probe(struct device *dev)
 
 	return 0;
 
- err:
+err:
 	put_ndd(ndd);
 	return rc;
 }
drivers/nvdimm/dimm_devs.c +34 -34

213 lines not on this page · raw message

drivers/nvdimm/e820.c +1 -1
index 87f72f725e4f..adfeaf5c3c23 100644
@@ -71,7 +71,7 @@ static int e820_pmem_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, nvdimm_bus);
 
 	rc = walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY_LEGACY,
-			IORESOURCE_MEM, 0, -1, nvdimm_bus, e820_register_one);
+				 IORESOURCE_MEM, 0, -1, nvdimm_bus, e820_register_one);
 	if (rc)
 		goto err;
 	return 0;
drivers/nvdimm/label.c +73 -73

429 lines not on this page · raw message

drivers/nvdimm/label.h +2 -2
index 4c7b775c2811..aff33d09fec3 100644
@@ -140,7 +140,7 @@ struct nd_region;
 struct nd_namespace_pmem;
 struct nd_namespace_blk;
 int nd_pmem_namespace_label_update(struct nd_region *nd_region,
-		struct nd_namespace_pmem *nspm, resource_size_t size);
+				   struct nd_namespace_pmem *nspm, resource_size_t size);
 int nd_blk_namespace_label_update(struct nd_region *nd_region,
-		struct nd_namespace_blk *nsblk, resource_size_t size);
+				  struct nd_namespace_blk *nsblk, resource_size_t size);
 #endif /* __LABEL_H__ */
drivers/nvdimm/namespace_devs.c +140 -140

819 lines not on this page · raw message

drivers/nvdimm/nd-core.h +13 -13
index 454454ba1738..60525ff1f19f 100644

Lines of this file are not shown. View the raw message.

drivers/nvdimm/nd.h +33 -33

66 lines not on this page · raw message

drivers/nvdimm/nd_virtio.c +9 -9
index 10351d5b49fa..e4f553633759 100644

Lines of this file are not shown. View the raw message.

drivers/nvdimm/of_pmem.c +3 -3
index 97187d6c0bdb..03ffcbf601d4 100644

Lines of this file are not shown. View the raw message.

drivers/nvdimm/pfn_devs.c +43 -43

86 lines not on this page · raw message

drivers/nvdimm/pmem.c +22 -22

44 lines not on this page · raw message

drivers/nvdimm/pmem.h +1 -1
index 59cfe13ea8a8..f5ba2a9a68ed 100644

Lines of this file are not shown. View the raw message.

drivers/nvdimm/region.c +8 -8
index 37bf8719a2a4..8b7dbac27aea 100644

Lines of this file are not shown. View the raw message.

drivers/nvdimm/region_devs.c +61 -61

122 lines not on this page · raw message

drivers/nvdimm/security.c +42 -42

84 lines not on this page · raw message

drivers/nvdimm/virtio_pmem.c +4 -4
index 5e3d07b47e0c..ce2181e06756 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH 01/13] nvdimm: Use more typical whitespace

drivers/nvdimm/badrange.c void badrange_init(struct badrange *badrange) · line 27

Quoted 3 lines

static void append_badrange_entry(struct badrange *badrange,

drivers/nvdimm/badrange.c +1 -1
-		struct badrange_entry *bre, u64 addr, u64 length)
+				  struct badrange_entry *bre, u64 addr, u64 length)

Please stop sending this kind of crap. Two tabs are a very common style used in a lot of the kernel, and some people actually prefer it.

Instead of arguing what is better just stick to what the surrounding code does.

Or in other words: Feel free to be a codingstyle nazi for your code (I am for some of mine), but leave others peoples code alone with "cleanup" patches.

#3 lore raw

Re: [PATCH 01/13] nvdimm: Use more typical whitespace

Quoted 2 lines · Christoph Hellwig

Instead of arguing what is better just stick to what the surrounding code does.

That's not always feasible nor readable.

Especially for the logic inversion blocks where
the existing code does unreadable and error prone
things like hiding semicolons immediately after
comments.

	if (foo)
		/* longish comment */;
	else {
		<code>;
	}
Quoted 3 lines

Or in other words: Feel free to be a codingstyle nazi for your code (I am for some of mine), but leave others peoples code alone with "cleanup" patches.

My point was to avoid documenting per-subsystem
coding style rules.

#4 lore raw

Re: [PATCH 01/13] nvdimm: Use more typical whitespace

Quoted 11 lines · Joe Perches
Quoted 2 lines · Christoph Hellwig

Instead of arguing what is better just stick to what the surrounding code does.

That's not always feasible nor readable.

Especially for the logic inversion blocks where
the existing code does unreadable and error prone
things like hiding semicolons immediately after
comments.

Quoted 5 lines
	if (foo)
		/* longish comment */;
	else {
		<code>;
	}

Which has nothing to do with your patch.

Quoted 6 lines
Quoted 3 lines

Or in other words: Feel free to be a codingstyle nazi for your code (I am for some of mine), but leave others peoples code alone with "cleanup" patches.

My point was to avoid documenting per-subsystem
coding style rules.

It is called common sense. In many cases different parts of the subsystem might have slight variations. Just stick to your preferred style in the bounds of coding style. Maintainers will either remind you if they feel strongly that they have a slightly different preference or just fix it up. What we really don't need need it whitespace cleanup patches in the micro variation area.

#5 lore raw

PATCH 2/13 nvdimm: Move logical continuations to previous line

In reply to Joe Perches

Make the logical continuation style more like the rest of the kernel.

No change in object files.

---
 drivers/nvdimm/btt.c            |  9 +++++----
 drivers/nvdimm/bus.c            |  4 ++--
 drivers/nvdimm/claim.c          |  4 ++--
 drivers/nvdimm/dimm_devs.c      | 23 ++++++++++++-----------
 drivers/nvdimm/label.c          |  8 ++++----
 drivers/nvdimm/namespace_devs.c | 40 +++++++++++++++++++++-------------------
 drivers/nvdimm/pfn_devs.c       | 17 +++++++++--------
 drivers/nvdimm/pmem.c           |  5 +++--
 drivers/nvdimm/region.c         |  6 +++---
 drivers/nvdimm/region_devs.c    | 23 ++++++++++++-----------
 drivers/nvdimm/security.c       | 34 ++++++++++++++++++++--------------
 11 files changed, 93 insertions(+), 80 deletions(-)
drivers/nvdimm/btt.c +5 -4
index d3e187ac43eb..6362d96dfc16 100644
@@ -603,8 +603,9 @@ static int btt_freelist_init(struct arena_info *arena)
 
 static bool ent_is_padding(struct log_entry *ent)
 {
-	return (ent->lba == 0) && (ent->old_map == 0) && (ent->new_map == 0)
-		&& (ent->seq == 0);
+	return (ent->lba == 0) &&
+		(ent->old_map == 0) && (ent->new_map == 0) &&
+		(ent->seq == 0);
 }
 
 /*
@@ -1337,8 +1338,8 @@ static int btt_write_pg(struct btt *btt, struct bio_integrity_payload *bip,
 		if (btt_is_badblock(btt, arena, arena->freelist[lane].block))
 			arena->freelist[lane].has_err = 1;
 
-		if (mutex_is_locked(&arena->err_lock)
-		    || arena->freelist[lane].has_err) {
+		if (mutex_is_locked(&arena->err_lock) ||
+		    arena->freelist[lane].has_err) {
 			nd_region_release_lane(btt->nd_region, lane);
 
 			ret = arena_clear_freelist_error(arena, lane);
drivers/nvdimm/bus.c +2 -2
index 83b6fcbb252d..6d4d4c72ac92 100644
@@ -189,8 +189,8 @@ static int nvdimm_clear_badblocks_region(struct device *dev, void *data)
 	ndr_end = nd_region->ndr_start + nd_region->ndr_size - 1;
 
 	/* make sure we are in the region */
-	if (ctx->phys < nd_region->ndr_start
-	    || (ctx->phys + ctx->cleared) > ndr_end)
+	if (ctx->phys < nd_region->ndr_start ||
+	    (ctx->phys + ctx->cleared) > ndr_end)
 		return 0;
 
 	sector = (ctx->phys - nd_region->ndr_start) / 512;
drivers/nvdimm/claim.c +2 -2
index 62f3afaa7d27..ff66a3cc349c 100644
@@ -274,8 +274,8 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
 	}
 
 	if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) {
-		if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512)
-		    && !(flags & NVDIMM_IO_ATOMIC)) {
+		if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512) &&
+		    !(flags & NVDIMM_IO_ATOMIC)) {
 			long cleared;
 
 			might_sleep();
drivers/nvdimm/dimm_devs.c +12 -11
index 52b00078939b..cb5598b3c389 100644
@@ -437,10 +437,11 @@ static umode_t nvdimm_visible(struct kobject *kobj, struct attribute *a, int n)
 
 	if (a == &dev_attr_security.attr) {
 		/* Are there any state mutation ops (make writable)? */
-		if (nvdimm->sec.ops->freeze || nvdimm->sec.ops->disable
-		    || nvdimm->sec.ops->change_key
-		    || nvdimm->sec.ops->erase
-		    || nvdimm->sec.ops->overwrite)
+		if (nvdimm->sec.ops->freeze ||
+		    nvdimm->sec.ops->disable ||
+		    nvdimm->sec.ops->change_key ||
+		    nvdimm->sec.ops->erase ||
+		    nvdimm->sec.ops->overwrite)
 			return a->mode;
 		return 0444;
 	}
@@ -516,8 +517,9 @@ int nvdimm_security_setup_events(struct device *dev)
 {
 	struct nvdimm *nvdimm = to_nvdimm(dev);
 
-	if (!nvdimm->sec.flags || !nvdimm->sec.ops
-	    || !nvdimm->sec.ops->overwrite)
+	if (!nvdimm->sec.flags ||
+	    !nvdimm->sec.ops ||
+	    !nvdimm->sec.ops->overwrite)
 		return 0;
 	nvdimm->sec.overwrite_state = sysfs_get_dirent(dev->kobj.sd, "security");
 	if (!nvdimm->sec.overwrite_state)
@@ -589,8 +591,8 @@ int alias_dpa_busy(struct device *dev, void *data)
 	 * (i.e. BLK is allocated after all aliased PMEM).
 	 */
 	if (info->res) {
-		if (info->res->start >= nd_mapping->start
-		    && info->res->start < map_end)
+		if (info->res->start >= nd_mapping->start &&
+		    info->res->start < map_end)
 			/* pass */;
 		else
 			return 0;
@@ -604,9 +606,8 @@ int alias_dpa_busy(struct device *dev, void *data)
 	for_each_dpa_resource(ndd, res) {
 		if (strncmp(res->name, "pmem", 4) != 0)
 			continue;
-		if ((res->start >= blk_start && res->start < map_end)
-		    || (res->end >= blk_start
-			&& res->end <= map_end)) {
+		if ((res->start >= blk_start && res->start < map_end) ||
+		    (res->end >= blk_start && res->end <= map_end)) {
 			new = max(blk_start, min(map_end + 1, res->end + 1));
 			if (new != blk_start) {
 				blk_start = new;
drivers/nvdimm/label.c +4 -4
index ebfad5183b23..37ea4fd89d3f 100644
@@ -187,8 +187,8 @@ static int __nd_label_validate(struct nvdimm_drvdata *ndd)
 		}
 
 		size = __le64_to_cpu(nsindex[i]->mysize);
-		if (size > sizeof_namespace_index(ndd)
-		    || size < sizeof(struct nd_namespace_index)) {
+		if (size > sizeof_namespace_index(ndd) ||
+		    size < sizeof(struct nd_namespace_index)) {
 			dev_dbg(dev, "nsindex%d mysize: %#llx invalid\n", i, size);
 			continue;
 		}
@@ -839,8 +839,8 @@ static int __pmem_label_update(struct nd_region *nd_region,
 	list_for_each_entry(label_ent, &nd_mapping->labels, list) {
 		if (!label_ent->label)
 			continue;
-		if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags)
-		    || memcmp(nspm->uuid, label_ent->label->uuid,
+		if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags) ||
+		    memcmp(nspm->uuid, label_ent->label->uuid,
 			      NSLABEL_UUID_LEN) == 0)
 			reap_victim(nd_mapping, label_ent);
 	}
drivers/nvdimm/namespace_devs.c +21 -19
index 5ffa137dc963..df2a82179622 100644
@@ -598,8 +598,8 @@ static void space_valid(struct nd_region *nd_region, struct nvdimm_drvdata *ndd,
 		return;
 
 	/* allocation needs to be contiguous with the existing namespace */
-	if (valid->start == exist->end + 1
-	    || valid->end == exist->start - 1)
+	if (valid->start == exist->end + 1 ||
+	    valid->end == exist->start - 1)
 		return;
 
 invalid:
@@ -777,9 +777,10 @@ static int merge_dpa(struct nd_region *nd_region,
 		struct resource *next = res->sibling;
 		resource_size_t end = res->start + resource_size(res);
 
-		if (!next || strcmp(res->name, label_id->id) != 0
-		    || strcmp(next->name, label_id->id) != 0
-		    || end != next->start)
+		if (!next ||
+		    strcmp(res->name, label_id->id) != 0 ||
+		    strcmp(next->name, label_id->id) != 0 ||
+		    end != next->start)
 			continue;
 		end += resource_size(next);
 		nvdimm_free_dpa(ndd, next);
@@ -1459,8 +1460,8 @@ static int btt_claim_class(struct device *dev)
 			loop_bitmask |= 1;
 		else {
 			/* check whether existing labels are v1.1 or v1.2 */
-			if (__le16_to_cpu(nsindex->major) == 1
-			    && __le16_to_cpu(nsindex->minor) == 1)
+			if (__le16_to_cpu(nsindex->major) == 1 &&
+			    __le16_to_cpu(nsindex->minor) == 1)
 				loop_bitmask |= 2;
 			else
 				loop_bitmask |= 4;
@@ -1658,11 +1659,12 @@ static umode_t namespace_visible(struct kobject *kobj,
 		return a->mode;
 	}
 
-	if (a == &dev_attr_nstype.attr || a == &dev_attr_size.attr
-	    || a == &dev_attr_holder.attr
-	    || a == &dev_attr_holder_class.attr
-	    || a == &dev_attr_force_raw.attr
-	    || a == &dev_attr_mode.attr)
+	if (a == &dev_attr_nstype.attr ||
+	    a == &dev_attr_size.attr ||
+	    a == &dev_attr_holder.attr ||
+	    a == &dev_attr_holder_class.attr ||
+	    a == &dev_attr_force_raw.attr ||
+	    a == &dev_attr_mode.attr)
 		return a->mode;
 
 	return 0;
@@ -1818,9 +1820,9 @@ static bool has_uuid_at_pos(struct nd_region *nd_region, u8 *uuid,
 			if (memcmp(nd_label->uuid, uuid, NSLABEL_UUID_LEN) != 0)
 				continue;
 
-			if (namespace_label_has(ndd, type_guid)
-			    && !guid_equal(&nd_set->type_guid,
-					   &nd_label->type_guid)) {
+			if (namespace_label_has(ndd, type_guid) &&
+			    !guid_equal(&nd_set->type_guid,
+					&nd_label->type_guid)) {
 				dev_dbg(ndd->dev, "expect type_guid %pUb got %pUb\n",
 					&nd_set->type_guid,
 					&nd_label->type_guid);
@@ -1882,8 +1884,8 @@ static int select_pmem_id(struct nd_region *nd_region, u8 *pmem_id)
 		hw_end = hw_start + nd_mapping->size;
 		pmem_start = __le64_to_cpu(nd_label->dpa);
 		pmem_end = pmem_start + __le64_to_cpu(nd_label->rawsize);
-		if (pmem_start >= hw_start && pmem_start < hw_end
-		    && pmem_end <= hw_end && pmem_end > hw_start)
+		if (pmem_start >= hw_start && pmem_start < hw_end &&
+		    pmem_end <= hw_end && pmem_end > hw_start)
 			/* pass */;
 		else {
 			dev_dbg(&nd_region->dev, "%s invalid label for %pUb\n",
@@ -2049,8 +2051,8 @@ struct resource *nsblk_add_resource(struct nd_region *nd_region,
 		return NULL;
 	nsblk->res = (struct resource **) res;
 	for_each_dpa_resource(ndd, res)
-		if (strcmp(res->name, label_id.id) == 0
-		    && res->start == start) {
+		if (strcmp(res->name, label_id.id) == 0 &&
+		    res->start == start) {
 			nsblk->res[nsblk->num_resources++] = res;
 			return res;
 		}
drivers/nvdimm/pfn_devs.c +9 -8
index 354ec83f0081..5382b4f2f5ef 100644
@@ -74,14 +74,14 @@ static ssize_t mode_store(struct device *dev,
 	else {
 		size_t n = len - 1;
 
-		if (strncmp(buf, "pmem\n", n) == 0
-		    || strncmp(buf, "pmem", n) == 0) {
+		if (strncmp(buf, "pmem\n", n) == 0 ||
+		    strncmp(buf, "pmem", n) == 0) {
 			nd_pfn->mode = PFN_MODE_PMEM;
-		} else if (strncmp(buf, "ram\n", n) == 0
-			   || strncmp(buf, "ram", n) == 0)
+		} else if (strncmp(buf, "ram\n", n) == 0 ||
+			   strncmp(buf, "ram", n) == 0)
 			nd_pfn->mode = PFN_MODE_RAM;
-		else if (strncmp(buf, "none\n", n) == 0
-			 || strncmp(buf, "none", n) == 0)
+		else if (strncmp(buf, "none\n", n) == 0 ||
+			 strncmp(buf, "none", n) == 0)
 			nd_pfn->mode = PFN_MODE_NONE;
 		else
 			rc = -EINVAL;
@@ -529,8 +529,9 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
 		return -EBUSY;
 	}
 
-	if ((align && !IS_ALIGNED(nsio->res.start + offset + start_pad, align))
-	    || !IS_ALIGNED(offset, PAGE_SIZE)) {
+	if ((align &&
+	     !IS_ALIGNED(nsio->res.start + offset + start_pad, align)) ||
+	    !IS_ALIGNED(offset, PAGE_SIZE)) {
 		dev_err(&nd_pfn->dev,
 			"bad offset: %#llx dax disabled align: %#lx\n",
 			offset, align);
drivers/nvdimm/pmem.c +3 -2
index 29f19db46845..fa4500b4f2eb 100644
@@ -506,8 +506,9 @@ static int nd_pmem_probe(struct device *dev)
 		return pmem_attach_disk(dev, ndns);
 
 	/* if we find a valid info-block we'll come back as that personality */
-	if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0
-	    || nd_dax_probe(dev, ndns) == 0)
+	if (nd_btt_probe(dev, ndns) == 0 ||
+	    nd_pfn_probe(dev, ndns) == 0 ||
+	    nd_dax_probe(dev, ndns) == 0)
 		return -ENXIO;
 
 	/* ...otherwise we're just a raw pmem device */
drivers/nvdimm/region.c +3 -3
index 8b7dbac27aea..8486b6c26367 100644
@@ -16,9 +16,9 @@ static int nd_region_probe(struct device *dev)
 	struct nd_region_data *ndrd;
 	struct nd_region *nd_region = to_nd_region(dev);
 
-	if (nd_region->num_lanes > num_online_cpus()
-	    && nd_region->num_lanes < num_possible_cpus()
-	    && !test_and_set_bit(0, &once)) {
+	if (nd_region->num_lanes > num_online_cpus() &&
+	    nd_region->num_lanes < num_possible_cpus() &&
+	    !test_and_set_bit(0, &once)) {
 		dev_dbg(dev, "online cpus (%d) < concurrent i/o lanes (%d) < possible cpus (%d)\n",
 			num_online_cpus(), nd_region->num_lanes,
 			num_possible_cpus());
drivers/nvdimm/region_devs.c +12 -11
index 025cd996ea58..0cff51370d3c 100644
@@ -660,13 +660,13 @@ static umode_t region_visible(struct kobject *kobj, struct attribute *a, int n)
 		return a->mode;
 	}
 
-	if (a != &dev_attr_set_cookie.attr
-	    && a != &dev_attr_available_size.attr)
+	if (a != &dev_attr_set_cookie.attr &&
+	    a != &dev_attr_available_size.attr)
 		return a->mode;
 
-	if ((type == ND_DEVICE_NAMESPACE_PMEM
-	     || type == ND_DEVICE_NAMESPACE_BLK)
-	    && a == &dev_attr_available_size.attr)
+	if ((type == ND_DEVICE_NAMESPACE_PMEM ||
+	     type == ND_DEVICE_NAMESPACE_BLK) &&
+	    a == &dev_attr_available_size.attr)
 		return a->mode;
 	else if (is_memory(dev) && nd_set)
 		return a->mode;
@@ -688,8 +688,9 @@ u64 nd_region_interleave_set_cookie(struct nd_region *nd_region,
 	if (!nd_set)
 		return 0;
 
-	if (nsindex && __le16_to_cpu(nsindex->major) == 1
-	    && __le16_to_cpu(nsindex->minor) == 1)
+	if (nsindex &&
+	    __le16_to_cpu(nsindex->major) == 1 &&
+	    __le16_to_cpu(nsindex->minor) == 1)
 		return nd_set->cookie1;
 	return nd_set->cookie2;
 }
@@ -1002,8 +1003,8 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
 		if (test_bit(NDD_UNARMED, &nvdimm->flags))
 			ro = 1;
 
-		if (test_bit(NDD_NOBLK, &nvdimm->flags)
-		    && dev_type == &nd_blk_device_type) {
+		if (test_bit(NDD_NOBLK, &nvdimm->flags) &&
+		    dev_type == &nd_blk_device_type) {
 			dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not BLK capable\n",
 				caller, dev_name(&nvdimm->dev), i);
 			return NULL;
@@ -1186,8 +1187,8 @@ int nvdimm_has_flush(struct nd_region *nd_region)
 	int i;
 
 	/* no nvdimm or pmem api == flushing capability unknown */
-	if (nd_region->ndr_mappings == 0
-	    || !IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API))
+	if (nd_region->ndr_mappings == 0 ||
+	    !IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API))
 		return -ENXIO;
 
 	for (i = 0; i < nd_region->ndr_mappings; i++) {
drivers/nvdimm/security.c +20 -14
index be89ad78a368..8f1766c00c5f 100644
@@ -173,8 +173,9 @@ static int __nvdimm_security_unlock(struct nvdimm *nvdimm)
 	/* The bus lock should be held at the top level of the call stack */
 	lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
 
-	if (!nvdimm->sec.ops || !nvdimm->sec.ops->unlock
-	    || !nvdimm->sec.flags)
+	if (!nvdimm->sec.ops ||
+	    !nvdimm->sec.ops->unlock ||
+	    !nvdimm->sec.flags)
 		return -EIO;
 
 	if (test_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags)) {
@@ -246,8 +247,9 @@ static int security_disable(struct nvdimm *nvdimm, unsigned int keyid)
 	/* The bus lock should be held at the top level of the call stack */
 	lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
 
-	if (!nvdimm->sec.ops || !nvdimm->sec.ops->disable
-	    || !nvdimm->sec.flags)
+	if (!nvdimm->sec.ops ||
+	    !nvdimm->sec.ops->disable ||
+	    !nvdimm->sec.flags)
 		return -EOPNOTSUPP;
 
 	rc = check_security_state(nvdimm);
@@ -281,8 +283,9 @@ static int security_update(struct nvdimm *nvdimm, unsigned int keyid,
 	/* The bus lock should be held at the top level of the call stack */
 	lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
 
-	if (!nvdimm->sec.ops || !nvdimm->sec.ops->change_key
-	    || !nvdimm->sec.flags)
+	if (!nvdimm->sec.ops ||
+	    !nvdimm->sec.ops->change_key ||
+	    !nvdimm->sec.flags)
 		return -EOPNOTSUPP;
 
 	rc = check_security_state(nvdimm);
@@ -330,16 +333,17 @@ static int security_erase(struct nvdimm *nvdimm, unsigned int keyid,
 	/* The bus lock should be held at the top level of the call stack */
 	lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
 
-	if (!nvdimm->sec.ops || !nvdimm->sec.ops->erase
-	    || !nvdimm->sec.flags)
+	if (!nvdimm->sec.ops ||
+	    !nvdimm->sec.ops->erase ||
+	    !nvdimm->sec.flags)
 		return -EOPNOTSUPP;
 
 	rc = check_security_state(nvdimm);
 	if (rc)
 		return rc;
 
-	if (!test_bit(NVDIMM_SECURITY_UNLOCKED, &nvdimm->sec.ext_flags)
-	    && pass_type == NVDIMM_MASTER) {
+	if (!test_bit(NVDIMM_SECURITY_UNLOCKED, &nvdimm->sec.ext_flags) &&
+	    pass_type == NVDIMM_MASTER) {
 		dev_dbg(dev,
 			"Attempt to secure erase in wrong master state.\n");
 		return -EOPNOTSUPP;
@@ -371,8 +375,9 @@ static int security_overwrite(struct nvdimm *nvdimm, unsigned int keyid)
 	/* The bus lock should be held at the top level of the call stack */
 	lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
 
-	if (!nvdimm->sec.ops || !nvdimm->sec.ops->overwrite
-	    || !nvdimm->sec.flags)
+	if (!nvdimm->sec.ops ||
+	    !nvdimm->sec.ops->overwrite ||
+	    !nvdimm->sec.flags)
 		return -EOPNOTSUPP;
 
 	if (dev->driver == NULL) {
@@ -427,8 +432,9 @@ void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
 
 	tmo = nvdimm->sec.overwrite_tmo;
 
-	if (!nvdimm->sec.ops || !nvdimm->sec.ops->query_overwrite
-	    || !nvdimm->sec.flags)
+	if (!nvdimm->sec.ops ||
+	    !nvdimm->sec.ops->query_overwrite ||
+	    !nvdimm->sec.flags)
 		return;
 
 	rc = nvdimm->sec.ops->query_overwrite(nvdimm);
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#6 lore raw

PATCH 3/13 nvdimm: Use octal permissions

In reply to Joe Perches

Avoid the use of the S_IRUGO define and use 0444 to improve readability and use a more common kernel style.

---
 drivers/nvdimm/btt.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/nvdimm/btt.c +18 -21
index 6362d96dfc16..9cad4dca6eac 100644
@@ -229,27 +229,24 @@ static void arena_debugfs_init(struct arena_info *a, struct dentry *parent,
 		return;
 	a->debugfs_dir = d;
 
-	debugfs_create_x64("size", S_IRUGO, d, &a->size);
-	debugfs_create_x64("external_lba_start", S_IRUGO, d,
-			   &a->external_lba_start);
-	debugfs_create_x32("internal_nlba", S_IRUGO, d, &a->internal_nlba);
-	debugfs_create_u32("internal_lbasize", S_IRUGO, d,
-			   &a->internal_lbasize);
-	debugfs_create_x32("external_nlba", S_IRUGO, d, &a->external_nlba);
-	debugfs_create_u32("external_lbasize", S_IRUGO, d,
-			   &a->external_lbasize);
-	debugfs_create_u32("nfree", S_IRUGO, d, &a->nfree);
-	debugfs_create_u16("version_major", S_IRUGO, d, &a->version_major);
-	debugfs_create_u16("version_minor", S_IRUGO, d, &a->version_minor);
-	debugfs_create_x64("nextoff", S_IRUGO, d, &a->nextoff);
-	debugfs_create_x64("infooff", S_IRUGO, d, &a->infooff);
-	debugfs_create_x64("dataoff", S_IRUGO, d, &a->dataoff);
-	debugfs_create_x64("mapoff", S_IRUGO, d, &a->mapoff);
-	debugfs_create_x64("logoff", S_IRUGO, d, &a->logoff);
-	debugfs_create_x64("info2off", S_IRUGO, d, &a->info2off);
-	debugfs_create_x32("flags", S_IRUGO, d, &a->flags);
-	debugfs_create_u32("log_index_0", S_IRUGO, d, &a->log_index[0]);
-	debugfs_create_u32("log_index_1", S_IRUGO, d, &a->log_index[1]);
+	debugfs_create_x64("size", 0444, d, &a->size);
+	debugfs_create_x64("external_lba_start", 0444, d, &a->external_lba_start);
+	debugfs_create_x32("internal_nlba", 0444, d, &a->internal_nlba);
+	debugfs_create_u32("internal_lbasize", 0444, d, &a->internal_lbasize);
+	debugfs_create_x32("external_nlba", 0444, d, &a->external_nlba);
+	debugfs_create_u32("external_lbasize", 0444, d, &a->external_lbasize);
+	debugfs_create_u32("nfree", 0444, d, &a->nfree);
+	debugfs_create_u16("version_major", 0444, d, &a->version_major);
+	debugfs_create_u16("version_minor", 0444, d, &a->version_minor);
+	debugfs_create_x64("nextoff", 0444, d, &a->nextoff);
+	debugfs_create_x64("infooff", 0444, d, &a->infooff);
+	debugfs_create_x64("dataoff", 0444, d, &a->dataoff);
+	debugfs_create_x64("mapoff", 0444, d, &a->mapoff);
+	debugfs_create_x64("logoff", 0444, d, &a->logoff);
+	debugfs_create_x64("info2off", 0444, d, &a->info2off);
+	debugfs_create_x32("flags", 0444, d, &a->flags);
+	debugfs_create_u32("log_index_0", 0444, d, &a->log_index[0]);
+	debugfs_create_u32("log_index_1", 0444, d, &a->log_index[1]);
 }
 
 static void btt_debugfs_init(struct btt *btt)
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#7 lore raw

PATCH 4/13 nvdimm: Use a more common kernel spacing style

In reply to Joe Perches

Use the more common kernel spacing styles per line.

git diff -w shows no difference.

---
 drivers/nvdimm/badrange.c       |  4 ++--
 drivers/nvdimm/blk.c            |  2 +-
 drivers/nvdimm/btt.c            |  4 ++--
 drivers/nvdimm/btt_devs.c       |  2 +-
 drivers/nvdimm/bus.c            | 14 +++++++-------
 drivers/nvdimm/core.c           |  2 +-
 drivers/nvdimm/label.c          | 28 ++++++++++++++--------------
 drivers/nvdimm/namespace_devs.c | 22 +++++++++++-----------
 drivers/nvdimm/nd-core.h        |  2 +-
 drivers/nvdimm/nd.h             |  4 ++--
 drivers/nvdimm/pfn_devs.c       |  6 +++---
 drivers/nvdimm/pmem.c           |  2 +-
 drivers/nvdimm/region.c         |  2 +-
 drivers/nvdimm/region_devs.c    |  2 +-
 drivers/nvdimm/security.c       | 18 +++++++++---------
 15 files changed, 57 insertions(+), 57 deletions(-)
drivers/nvdimm/badrange.c +2 -2
index b997c2007b83..f2a742c6258a 100644
@@ -165,11 +165,11 @@ EXPORT_SYMBOL_GPL(badrange_forget);
 static void set_badblock(struct badblocks *bb, sector_t s, int num)
 {
 	dev_dbg(bb->dev, "Found a bad range (0x%llx, 0x%llx)\n",
-		(u64) s * 512, (u64) num * 512);
+		(u64)s * 512, (u64)num * 512);
 	/* this isn't an error as the hardware will still throw an exception */
 	if (badblocks_set(bb, s, num, 1))
 		dev_info_once(bb->dev, "%s: failed for sector %llx\n",
-			      __func__, (u64) s);
+			      __func__, (u64)s);
 }
 
 /**
drivers/nvdimm/blk.c +1 -1
index edd3e1664edc..95acb48bfaed 100644
@@ -189,7 +189,7 @@ static blk_qc_t nd_blk_make_request(struct request_queue *q, struct bio *bio)
 			dev_dbg(&nsblk->common.dev,
 				"io error in %s sector %lld, len %d,\n",
 				(rw == READ) ? "READ" : "WRITE",
-				(unsigned long long) iter.bi_sector, len);
+				(unsigned long long)iter.bi_sector, len);
 			bio->bi_status = errno_to_blk_status(err);
 			break;
 		}
drivers/nvdimm/btt.c +2 -2
index 9cad4dca6eac..28b65413abd8 100644
@@ -1007,7 +1007,7 @@ static int btt_arena_write_layout(struct arena_info *arena)
 	super->info2off = cpu_to_le64(arena->info2off - arena->infooff);
 
 	super->flags = 0;
-	sum = nd_sb_checksum((struct nd_gen_sb *) super);
+	sum = nd_sb_checksum((struct nd_gen_sb *)super);
 	super->checksum = cpu_to_le64(sum);
 
 	ret = btt_info_write(arena, super);
@@ -1469,7 +1469,7 @@ static blk_qc_t btt_make_request(struct request_queue *q, struct bio *bio)
 				"io error in %s sector %lld, len %d,\n",
 				(op_is_write(bio_op(bio))) ? "WRITE" :
 				"READ",
-				(unsigned long long) iter.bi_sector, len);
+				(unsigned long long)iter.bi_sector, len);
 			bio->bi_status = errno_to_blk_status(err);
 			break;
 		}
drivers/nvdimm/btt_devs.c +1 -1
index 9c4cbda834be..f6429842f1b6 100644
@@ -256,7 +256,7 @@ bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super)
 
 	checksum = le64_to_cpu(super->checksum);
 	super->checksum = 0;
-	if (checksum != nd_sb_checksum((struct nd_gen_sb *) super))
+	if (checksum != nd_sb_checksum((struct nd_gen_sb *)super))
 		return false;
 	super->checksum = cpu_to_le64(checksum);
 
drivers/nvdimm/bus.c +7 -7
index 6d4d4c72ac92..35591f492d27 100644
@@ -876,7 +876,7 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
 			return remainder;
 		return out_field[1] - 8;
 	} else if (cmd == ND_CMD_CALL) {
-		struct nd_cmd_pkg *pkg = (struct nd_cmd_pkg *) in_field;
+		struct nd_cmd_pkg *pkg = (struct nd_cmd_pkg *)in_field;
 
 		return pkg->nd_size_out;
 	}
@@ -984,7 +984,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 	const struct nd_cmd_desc *desc = NULL;
 	unsigned int cmd = _IOC_NR(ioctl_cmd);
 	struct device *dev = &nvdimm_bus->dev;
-	void __user *p = (void __user *) arg;
+	void __user *p = (void __user *)arg;
 	char *out_env = NULL, *in_env = NULL;
 	const char *cmd_name, *dimm_name;
 	u32 in_len = 0, out_len = 0;
@@ -1073,7 +1073,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 
 	for (i = 0; i < desc->out_num; i++) {
 		u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i,
-					       (u32 *) in_env, (u32 *) out_env, 0);
+					       (u32 *)in_env, (u32 *)out_env, 0);
 		u32 copy;
 
 		if (out_size == UINT_MAX) {
@@ -1094,7 +1094,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 		out_len += out_size;
 	}
 
-	buf_len = (u64) out_len + (u64) in_len;
+	buf_len = (u64)out_len + (u64)in_len;
 	if (buf_len > ND_IOCTL_MAX_BUFLEN) {
 		dev_dbg(dev, "%s cmd: %s buf_len: %llu > %d\n", dimm_name,
 			cmd_name, buf_len, ND_IOCTL_MAX_BUFLEN);
@@ -1150,7 +1150,7 @@ enum nd_ioctl_mode {
 
 static int match_dimm(struct device *dev, void *data)
 {
-	long id = (long) data;
+	long id = (long)data;
 
 	if (is_nvdimm(dev)) {
 		struct nvdimm *nvdimm = to_nvdimm(dev);
@@ -1166,7 +1166,7 @@ static long nd_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
 
 {
 	struct nvdimm_bus *nvdimm_bus, *found = NULL;
-	long id = (long) file->private_data;
+	long id = (long)file->private_data;
 	struct nvdimm *nvdimm = NULL;
 	int rc, ro;
 
@@ -1221,7 +1221,7 @@ static int nd_open(struct inode *inode, struct file *file)
 {
 	long minor = iminor(inode);
 
-	file->private_data = (void *) minor;
+	file->private_data = (void *)minor;
 	return 0;
 }
 
drivers/nvdimm/core.c +1 -1
index b3ff3e62d847..e30b39f49c46 100644
@@ -184,7 +184,7 @@ u64 nd_fletcher64(void *addr, size_t len, bool le)
 	int i;
 
 	for (i = 0; i < len / sizeof(u32); i++) {
-		lo32 += le ? le32_to_cpu((__le32) buf[i]) : buf[i];
+		lo32 += le ? le32_to_cpu((__le32)buf[i]) : buf[i];
 		hi32 += lo32;
 	}
 
drivers/nvdimm/label.c +14 -14
index 37ea4fd89d3f..2c780c5352dc 100644
@@ -275,8 +275,8 @@ static int to_slot(struct nvdimm_drvdata *ndd,
 {
 	unsigned long label, base;
 
-	label = (unsigned long) nd_label;
-	base = (unsigned long) nd_label_base(ndd);
+	label = (unsigned long)nd_label;
+	base = (unsigned long)nd_label_base(ndd);
 
 	return (label - base) / sizeof_namespace_label(ndd);
 }
@@ -285,10 +285,10 @@ static struct nd_namespace_label *to_label(struct nvdimm_drvdata *ndd, int slot)
 {
 	unsigned long label, base;
 
-	base = (unsigned long) nd_label_base(ndd);
+	base = (unsigned long)nd_label_base(ndd);
 	label = base + sizeof_namespace_label(ndd) * slot;
 
-	return (struct nd_namespace_label *) label;
+	return (struct nd_namespace_label *)label;
 }
 
 #define for_each_clear_bit_le(bit, addr, size)				\
@@ -314,7 +314,7 @@ static bool preamble_index(struct nvdimm_drvdata *ndd, int idx,
 	if (nsindex == NULL)
 		return false;
 
-	*free = (unsigned long *) nsindex->free;
+	*free = (unsigned long *)nsindex->free;
 	*nslot = __le32_to_cpu(nsindex->nslot);
 	*nsindex_out = nsindex;
 
@@ -659,16 +659,16 @@ static int nd_label_write_index(struct nvdimm_drvdata *ndd, int index, u32 seq,
 	memset(&nsindex->flags, 0, 3);
 	nsindex->labelsize = sizeof_namespace_label(ndd) >> 8;
 	nsindex->seq = __cpu_to_le32(seq);
-	offset = (unsigned long) nsindex
-		- (unsigned long) to_namespace_index(ndd, 0);
+	offset = (unsigned long)nsindex
+		- (unsigned long)to_namespace_index(ndd, 0);
 	nsindex->myoff = __cpu_to_le64(offset);
 	nsindex->mysize = __cpu_to_le64(sizeof_namespace_index(ndd));
-	offset = (unsigned long) to_namespace_index(ndd,
+	offset = (unsigned long)to_namespace_index(ndd,
 						    nd_label_next_nsindex(index))
-		- (unsigned long) to_namespace_index(ndd, 0);
+		- (unsigned long)to_namespace_index(ndd, 0);
 	nsindex->otheroff = __cpu_to_le64(offset);
-	offset = (unsigned long) nd_label_base(ndd)
-		- (unsigned long) to_namespace_index(ndd, 0);
+	offset = (unsigned long)nd_label_base(ndd)
+		- (unsigned long)to_namespace_index(ndd, 0);
 	nsindex->labeloff = __cpu_to_le64(offset);
 	nsindex->nslot = __cpu_to_le32(nslot);
 	nsindex->major = __cpu_to_le16(1);
@@ -678,7 +678,7 @@ static int nd_label_write_index(struct nvdimm_drvdata *ndd, int index, u32 seq,
 		nsindex->minor = __cpu_to_le16(2);
 	nsindex->checksum = __cpu_to_le64(0);
 	if (flags & ND_NSINDEX_INIT) {
-		unsigned long *free = (unsigned long *) nsindex->free;
+		unsigned long *free = (unsigned long *)nsindex->free;
 		u32 nfree = ALIGN(nslot, BITS_PER_LONG);
 		int last_bits, i;
 
@@ -709,8 +709,8 @@ static int nd_label_write_index(struct nvdimm_drvdata *ndd, int index, u32 seq,
 static unsigned long nd_label_offset(struct nvdimm_drvdata *ndd,
 				     struct nd_namespace_label *nd_label)
 {
-	return (unsigned long) nd_label
-		- (unsigned long) to_namespace_index(ndd, 0);
+	return (unsigned long)nd_label
+		- (unsigned long)to_namespace_index(ndd, 0);
 }
 
 enum nvdimm_claim_class to_nvdimm_cclass(guid_t *guid)
drivers/nvdimm/namespace_devs.c +11 -11
index df2a82179622..2bf4b6344926 100644
@@ -824,8 +824,8 @@ int __reserve_free_pmem(struct device *dev, void *data)
 		rem = scan_allocate(nd_region, nd_mapping, &label_id, n);
 		dev_WARN_ONCE(&nd_region->dev, rem,
 			      "pmem reserve underrun: %#llx of %#llx bytes\n",
-			      (unsigned long long) n - rem,
-			      (unsigned long long) n);
+			      (unsigned long long)n - rem,
+			      (unsigned long long)n);
 		return rem ? -ENXIO : 0;
 	}
 
@@ -905,8 +905,8 @@ static int grow_dpa_allocation(struct nd_region *nd_region,
 
 		dev_WARN_ONCE(&nd_region->dev, rem,
 			      "allocation underrun: %#llx of %#llx bytes\n",
-			      (unsigned long long) n - rem,
-			      (unsigned long long) n);
+			      (unsigned long long)n - rem,
+			      (unsigned long long)n);
 		if (rem)
 			return -ENXIO;
 
@@ -1245,7 +1245,7 @@ static int namespace_update_uuid(struct nd_region *nd_region,
 
 		for_each_dpa_resource(ndd, res)
 			if (strcmp(res->name, old_label_id.id) == 0)
-				sprintf((void *) res->name, "%s",
+				sprintf((void *)res->name, "%s",
 					new_label_id.id);
 
 		mutex_lock(&nd_mapping->lock);
@@ -1328,7 +1328,7 @@ static ssize_t resource_show(struct device *dev,
 	/* no address to convey if the namespace has no allocation */
 	if (resource_size(res) == 0)
 		return -ENXIO;
-	return sprintf(buf, "%#llx\n", (unsigned long long) res->start);
+	return sprintf(buf, "%#llx\n", (unsigned long long)res->start);
 }
 static DEVICE_ATTR_RO(resource);
 
@@ -2000,9 +2000,9 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
 		if (__le16_to_cpu(label0->position) != 0)
 			continue;
 		WARN_ON(nspm->alt_name || nspm->uuid);
-		nspm->alt_name = kmemdup((void __force *) label0->name,
+		nspm->alt_name = kmemdup((void __force *)label0->name,
 					 NSLABEL_NAME_LEN, GFP_KERNEL);
-		nspm->uuid = kmemdup((void __force *) label0->uuid,
+		nspm->uuid = kmemdup((void __force *)label0->uuid,
 				     NSLABEL_UUID_LEN, GFP_KERNEL);
 		nspm->lbasize = __le64_to_cpu(label0->lbasize);
 		ndd = to_ndd(nd_mapping);
@@ -2049,7 +2049,7 @@ struct resource *nsblk_add_resource(struct nd_region *nd_region,
 		       GFP_KERNEL);
 	if (!res)
 		return NULL;
-	nsblk->res = (struct resource **) res;
+	nsblk->res = (struct resource **)res;
 	for_each_dpa_resource(ndd, res)
 		if (strcmp(res->name, label_id.id) == 0 &&
 		    res->start == start) {
@@ -2277,8 +2277,8 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
 
 static int cmp_dpa(const void *a, const void *b)
 {
-	const struct device *dev_a = *(const struct device **) a;
-	const struct device *dev_b = *(const struct device **) b;
+	const struct device *dev_a = *(const struct device **)a;
+	const struct device *dev_b = *(const struct device **)b;
 	struct nd_namespace_blk *nsblk_a, *nsblk_b;
 	struct nd_namespace_pmem *nspm_a, *nspm_b;
 
drivers/nvdimm/nd-core.h +1 -1
index 60525ff1f19f..b9163fff27b0 100644
@@ -63,7 +63,7 @@ static inline unsigned long nvdimm_security_flags(
 	/* disabled, locked, unlocked, and overwrite are mutually exclusive */
 	dev_WARN_ONCE(&nvdimm->dev, hweight64(flags & state_flags) > 1,
 		      "reported invalid security state: %#llx\n",
-		      (unsigned long long) flags);
+		      (unsigned long long)flags);
 	return flags;
 }
 int nvdimm_security_freeze(struct nvdimm *nvdimm);
drivers/nvdimm/nd.h +2 -2
index 56ffd998d642..c10a4b94d44a 100644
@@ -90,8 +90,8 @@ unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd);
 #define nd_dbg_dpa(r, d, res, fmt, arg...)				\
 	dev_dbg((r) ? &(r)->dev : (d)->dev, "%s: %.13s: %#llx @ %#llx " fmt, \
 		(r) ? dev_name((d)->dev) : "", res ? res->name : "null", \
-		(unsigned long long) (res ? resource_size(res) : 0),	\
-		(unsigned long long) (res ? res->start : 0), ##arg)
+		(unsigned long long)(res ? resource_size(res) : 0),	\
+		(unsigned long long)(res ? res->start : 0), ##arg)
 
 #define for_each_dpa_resource(ndd, res)				\
 	for (res = (ndd)->dpa.child; res; res = res->sibling)
drivers/nvdimm/pfn_devs.c +3 -3
index 5382b4f2f5ef..20a0cce9ee93 100644
@@ -216,7 +216,7 @@ static ssize_t resource_show(struct device *dev,
 		u32 start_pad = __le32_to_cpu(pfn_sb->start_pad);
 		struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
 
-		rc = sprintf(buf, "%#llx\n", (unsigned long long) nsio->res.start
+		rc = sprintf(buf, "%#llx\n", (unsigned long long)nsio->res.start
 			     + start_pad + offset);
 	} else {
 		/* no address to convey if the pfn instance is disabled */
@@ -445,7 +445,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
 
 	checksum = le64_to_cpu(pfn_sb->checksum);
 	pfn_sb->checksum = 0;
-	if (checksum != nd_sb_checksum((struct nd_gen_sb *) pfn_sb))
+	if (checksum != nd_sb_checksum((struct nd_gen_sb *)pfn_sb))
 		return -ENODEV;
 	pfn_sb->checksum = cpu_to_le64(checksum);
 
@@ -728,7 +728,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
 	pfn_sb->version_minor = cpu_to_le16(3);
 	pfn_sb->end_trunc = cpu_to_le32(end_trunc);
 	pfn_sb->align = cpu_to_le32(nd_pfn->align);
-	checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb);
+	checksum = nd_sb_checksum((struct nd_gen_sb *)pfn_sb);
 	pfn_sb->checksum = cpu_to_le64(checksum);
 
 	return nvdimm_write_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb), 0);
drivers/nvdimm/pmem.c +1 -1
index fa4500b4f2eb..dfe38d6b6607 100644
@@ -85,7 +85,7 @@ static blk_status_t pmem_clear_poison(struct pmem_device *pmem,
 		hwpoison_clear(pmem, pmem->phys_addr + offset, cleared);
 		cleared /= 512;
 		dev_dbg(dev, "%#llx clear %ld sector%s\n",
-			(unsigned long long) sector, cleared,
+			(unsigned long long)sector, cleared,
 			cleared > 1 ? "s" : "");
 		badblocks_clear(&pmem->bb, sector, cleared);
 		if (pmem->bb_state)
drivers/nvdimm/region.c +1 -1
index 8486b6c26367..fdd67ff499c9 100644
@@ -113,7 +113,7 @@ static int nd_region_remove(struct device *dev)
 
 static int child_notify(struct device *dev, void *data)
 {
-	nd_device_notify(dev, *(enum nvdimm_event *) data);
+	nd_device_notify(dev, *(enum nvdimm_event *)data);
 	return 0;
 }
 
drivers/nvdimm/region_devs.c +1 -1
index 0cff51370d3c..9265a2b0018c 100644
@@ -44,7 +44,7 @@ static int nvdimm_map_flush(struct device *dev, struct nvdimm *nvdimm, int dimm,
 		}
 
 		if (j < i)
-			flush_page = (void __iomem *) ((unsigned long)
+			flush_page = (void __iomem *)((unsigned long)
 						       ndrd_get_flush_wpq(ndrd, dimm, j)
 						       & PAGE_MASK);
 		else
drivers/nvdimm/security.c +9 -9
index 8f1766c00c5f..ac23cd4480bd 100644
@@ -473,13 +473,13 @@ void nvdimm_security_overwrite_query(struct work_struct *work)
 }
 
 #define OPS								\
-	C( OP_FREEZE,		"freeze",		1),		\
-		C( OP_DISABLE,		"disable",		2),	\
-		C( OP_UPDATE,		"update",		3),	\
-		C( OP_ERASE,		"erase",		2),	\
-		C( OP_OVERWRITE,	"overwrite",		2),	\
-		C( OP_MASTER_UPDATE,	"master_update",	3),	\
-		C( OP_MASTER_ERASE,	"master_erase",		2)
+	C(OP_FREEZE,		"freeze",		1),		\
+	C(OP_DISABLE,		"disable",		2),		\
+	C(OP_UPDATE,		"update",		3),		\
+	C(OP_ERASE,		"erase",		2),		\
+	C(OP_OVERWRITE,		"overwrite",		2),		\
+	C(OP_MASTER_UPDATE,	"master_update",	3),		\
+	C(OP_MASTER_ERASE,	"master_erase",		2)
 #undef C
 #define C(a, b, c) a
 enum nvdimmsec_op_ids { OPS };
@@ -498,8 +498,8 @@ ssize_t nvdimm_security_store(struct device *dev, const char *buf, size_t len)
 {
 	struct nvdimm *nvdimm = to_nvdimm(dev);
 	ssize_t rc;
-	char cmd[SEC_CMD_SIZE+1], keystr[KEY_ID_SIZE+1],
-		nkeystr[KEY_ID_SIZE+1];
+	char cmd[SEC_CMD_SIZE + 1], keystr[KEY_ID_SIZE + 1],
+		nkeystr[KEY_ID_SIZE + 1];
 	unsigned int key, newkey;
 	int i;
 
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#8 lore raw

PATCH 5/13 nvdimm: Use "unsigned int" in preference to "unsigned"

In reply to Joe Perches

Use the more common kernel type.

---
 drivers/nvdimm/label.c | 2 +-
 drivers/nvdimm/nd.h    | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/nvdimm/label.c +1 -1
index 2c780c5352dc..5700d9b35b8f 100644
@@ -34,7 +34,7 @@ static u32 best_seq(u32 a, u32 b)
 		return a;
 }
 
-unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd)
+unsigned int sizeof_namespace_label(struct nvdimm_drvdata *ndd)
 {
 	return ndd->nslabel_size;
 }
drivers/nvdimm/nd.h +3 -3
index c10a4b94d44a..1636061b1f93 100644
@@ -81,7 +81,7 @@ static inline struct nd_namespace_index *to_next_namespace_index(
 	return to_namespace_index(ndd, ndd->ns_next);
 }
 
-unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd);
+unsigned int sizeof_namespace_label(struct nvdimm_drvdata *ndd);
 
 #define namespace_label_has(ndd, field)			\
 	(offsetof(struct nd_namespace_label, field)	\
@@ -170,9 +170,9 @@ struct nd_blk_region {
 /*
  * Lookup next in the repeating sequence of 01, 10, and 11.
  */
-static inline unsigned nd_inc_seq(unsigned seq)
+static inline unsigned int nd_inc_seq(unsigned int seq)
 {
-	static const unsigned next[] = { 0, 2, 3, 1 };
+	static const unsigned int next[] = { 0, 2, 3, 1 };
 
 	return next[seq & 3];
 }
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#9 lore raw

PATCH 6/13 nvdimm: Add and remove blank lines

In reply to Joe Perches

Use a more common kernel style.

Remove unnecessary multiple blank lines. Remove blank lines before and after braces. Add blank lines after functions definitions and enums. Add blank lines around #define pr_fmt.

---
 drivers/nvdimm/btt.c            | 2 --
 drivers/nvdimm/bus.c            | 5 ++---
 drivers/nvdimm/dimm.c           | 1 -
 drivers/nvdimm/dimm_devs.c      | 2 ++
 drivers/nvdimm/label.c          | 1 -
 drivers/nvdimm/namespace_devs.c | 5 -----
 drivers/nvdimm/nd-core.h        | 4 ++++
 drivers/nvdimm/nd.h             | 6 ++++++
 drivers/nvdimm/nd_virtio.c      | 1 -
 drivers/nvdimm/region_devs.c    | 1 +
 drivers/nvdimm/security.c       | 2 --
 11 files changed, 15 insertions(+), 15 deletions(-)
drivers/nvdimm/btt.c +0 -2
index 28b65413abd8..0927cbdc5cc6 100644
@@ -1354,7 +1354,6 @@ static int btt_write_pg(struct btt *btt, struct bio_integrity_payload *bip,
 			while (arena->rtt[i] == (RTT_VALID | new_postmap))
 				cpu_relax();
 
-
 		if (new_postmap >= arena->internal_nlba) {
 			ret = -EIO;
 			goto out_lane;
@@ -1496,7 +1495,6 @@ static int btt_rw_page(struct block_device *bdev, sector_t sector,
 	return rc;
 }
 
-
 static int btt_getgeo(struct block_device *bd, struct hd_geometry *geo)
 {
 	/* some standard values */
drivers/nvdimm/bus.c +2 -3
index 35591f492d27..5ffd61c9c4b7 100644
@@ -2,7 +2,9 @@
 /*
  * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
  */
+
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/libnvdimm.h>
 #include <linux/sched/mm.h>
 #include <linux/vmalloc.h>
@@ -643,7 +645,6 @@ int nvdimm_revalidate_disk(struct gendisk *disk)
 	set_disk_ro(disk, 1);
 
 	return 0;
-
 }
 EXPORT_SYMBOL(nvdimm_revalidate_disk);
 
@@ -881,7 +882,6 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
 		return pkg->nd_size_out;
 	}
 
-
 	return UINT_MAX;
 }
 EXPORT_SYMBOL_GPL(nd_cmd_out_size);
@@ -940,7 +940,6 @@ static int nd_pmem_forget_poison_check(struct device *dev, void *data)
 		return -EBUSY;
 
 	return 0;
-
 }
 
 static int nd_ns_forget_poison_check(struct device *dev, void *data)
drivers/nvdimm/dimm.c +0 -1
index 916710ae647f..5783c6d6dbdc 100644
@@ -62,7 +62,6 @@ static int nvdimm_probe(struct device *dev)
 	if (rc < 0)
 		dev_dbg(dev, "failed to unlock dimm: %d\n", rc);
 
-
 	/*
 	 * EACCES failures reading the namespace label-area-properties
 	 * are interpreted as the DIMM capacity being locked but the
drivers/nvdimm/dimm_devs.c +2 -0
index cb5598b3c389..873df96795b0 100644
@@ -2,7 +2,9 @@
 /*
  * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
  */
+
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/moduleparam.h>
 #include <linux/vmalloc.h>
 #include <linux/device.h>
drivers/nvdimm/label.c +0 -1
index 5700d9b35b8f..bf58357927c4 100644
@@ -972,7 +972,6 @@ static int __blk_label_update(struct nd_region *nd_region,
 	}
 	/* from here on we need to abort on error */
 
-
 	/* assign all resources to the namespace before writing the labels */
 	nsblk->res = NULL;
 	nsblk->num_resources = 0;
drivers/nvdimm/namespace_devs.c +0 -5
index 2bf4b6344926..600df84b4d2d 100644
@@ -367,7 +367,6 @@ resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk)
 }
 EXPORT_SYMBOL(nd_namespace_blk_validate);
 
-
 static int nd_namespace_label_update(struct nd_region *nd_region,
 				     struct device *dev)
 {
@@ -543,7 +542,6 @@ static resource_size_t init_dpa_allocation(struct nd_label_id *label_id,
 	return rc ? n : 0;
 }
 
-
 /**
  * space_valid() - validate free dpa space against constraints
  * @nd_region: hosting region of the free space
@@ -2009,7 +2007,6 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
 		if (namespace_label_has(ndd, abstraction_guid))
 			nspm->nsio.common.claim_class
 				= to_nvdimm_cclass(&label0->abstraction_guid);
-
 	}
 
 	if (!nspm->alt_name || !nspm->uuid) {
@@ -2217,7 +2214,6 @@ static int add_namespace_resource(struct nd_region *nd_region,
 static struct device *create_namespace_blk(struct nd_region *nd_region,
 					   struct nd_namespace_label *nd_label, int count)
 {
-
 	struct nd_mapping *nd_mapping = &nd_region->mapping[0];
 	struct nd_interleave_set *nd_set = nd_region->nd_set;
 	struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
@@ -2362,7 +2358,6 @@ static struct device **scan_labels(struct nd_region *nd_region)
 			}
 		} else
 			devs[count++] = dev;
-
 	}
 
 	dev_dbg(&nd_region->dev, "discovered %d %s namespace%s\n",
drivers/nvdimm/nd-core.h +4 -0
index b9163fff27b0..3b48fba4629b 100644
@@ -66,6 +66,7 @@ static inline unsigned long nvdimm_security_flags(
 		      (unsigned long long)flags);
 	return flags;
 }
+
 int nvdimm_security_freeze(struct nvdimm *nvdimm);
 #if IS_ENABLED(CONFIG_NVDIMM_KEYS)
 ssize_t nvdimm_security_store(struct device *dev, const char *buf, size_t len);
@@ -76,6 +77,7 @@ static inline ssize_t nvdimm_security_store(struct device *dev,
 {
 	return -EOPNOTSUPP;
 }
+
 static inline void nvdimm_security_overwrite_query(struct work_struct *work)
 {
 }
@@ -106,10 +108,12 @@ static inline bool is_nd_region(struct device *dev)
 {
 	return is_nd_pmem(dev) || is_nd_blk(dev) || is_nd_volatile(dev);
 }
+
 static inline bool is_memory(struct device *dev)
 {
 	return is_nd_pmem(dev) || is_nd_volatile(dev);
 }
+
 struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev);
 int __init nvdimm_bus_init(void);
 void nvdimm_bus_exit(void);
drivers/nvdimm/nd.h +6 -0
index 1636061b1f93..d434041ca2e5 100644
@@ -108,6 +108,7 @@ struct nd_percpu_lane {
 enum nd_label_flags {
 	ND_LABEL_REAP,
 };
+
 struct nd_label_ent {
 	struct list_head list;
 	unsigned long flags;
@@ -384,11 +385,13 @@ static inline int nvdimm_setup_pfn(struct nd_pfn *nd_pfn,
 {
 	return -ENXIO;
 }
+
 static inline int devm_nsio_enable(struct device *dev,
 				   struct nd_namespace_io *nsio)
 {
 	return -ENXIO;
 }
+
 static inline void devm_nsio_disable(struct device *dev,
 				     struct nd_namespace_io *nsio)
 {
@@ -409,12 +412,14 @@ static inline bool nd_iostat_start(struct bio *bio, unsigned long *start)
 			      &disk->part0);
 	return true;
 }
+
 static inline void nd_iostat_end(struct bio *bio, unsigned long start)
 {
 	struct gendisk *disk = bio->bi_disk;
 
 	generic_end_io_acct(disk->queue, bio_op(bio), &disk->part0, start);
 }
+
 static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector,
 			       unsigned int len)
 {
@@ -428,6 +433,7 @@ static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector,
 
 	return false;
 }
+
 resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk);
 const u8 *nd_dev_to_uuid(struct device *dev);
 bool pmem_should_map_pages(struct device *dev);
drivers/nvdimm/nd_virtio.c +0 -1
index e4f553633759..f09541bf3d5d 100644
@@ -68,7 +68,6 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
 	 */
 	while ((err = virtqueue_add_sgs(vpmem->req_vq, sgs, 1, 1, req_data,
 					GFP_ATOMIC)) == -ENOSPC) {
-
 		dev_info(&vdev->dev, "failed to send command to virtio pmem device, no free slots in the virtqueue\n");
 		req_data->wq_buf_avail = false;
 		list_add_tail(&req_data->list, &vpmem->req_list);
drivers/nvdimm/region_devs.c +1 -0
index 9265a2b0018c..76b08b64b0b1 100644
@@ -1141,6 +1141,7 @@ int nvdimm_flush(struct nd_region *nd_region, struct bio *bio)
 
 	return rc;
 }
+
 /**
  * nvdimm_flush - flush any posted write queues between the cpu and pmem media
  * @nd_region: blk or interleaved pmem region
drivers/nvdimm/security.c +0 -2
index ac23cd4480bd..13bc5d54f0b6 100644
@@ -135,7 +135,6 @@ static const void *nvdimm_get_user_key_payload(struct nvdimm *nvdimm,
 	return key_data(*key);
 }
 
-
 static int nvdimm_key_revalidate(struct nvdimm *nvdimm)
 {
 	struct key *key;
@@ -439,7 +438,6 @@ void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
 
 	rc = nvdimm->sec.ops->query_overwrite(nvdimm);
 	if (rc == -EBUSY) {
-
 		/* setup delayed work again */
 		tmo += 10;
 		queue_delayed_work(system_wq, &nvdimm->dwork, tmo * HZ);
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#10 lore raw

PATCH 7/13 nvdimm: Use typical kernel brace styles

In reply to Joe Perches

Make the nvdimm code more like the rest of the kernel code to improve readability.

Add balanced braces to multiple test blocks.
Remove else statements from blocks where the block above uses return.

e.g.:

	if (foo) {
		[code...];
		return FOO;
	} else if (bar) {
		[code...];
		return BAR;
	} else
		return BAZ;

becomes

	if (foo) {
		[code...];
		return FOO;
	}
	if (bar) {
		[code...];
		return BAR;
	}
	return BAZ;
---
 drivers/nvdimm/badrange.c       |  3 +-
 drivers/nvdimm/blk.c            |  9 +++--
 drivers/nvdimm/btt.c            |  5 +--
 drivers/nvdimm/btt_devs.c       |  4 +--
 drivers/nvdimm/bus.c            | 10 +++---
 drivers/nvdimm/claim.c          |  7 ++--
 drivers/nvdimm/dax_devs.c       |  3 +-
 drivers/nvdimm/dimm_devs.c      | 13 ++++---
 drivers/nvdimm/label.c          | 13 +++----
 drivers/nvdimm/namespace_devs.c | 78 ++++++++++++++++++++++++++---------------
 drivers/nvdimm/pfn_devs.c       | 24 +++++++------
 drivers/nvdimm/pmem.c           |  8 ++---
 drivers/nvdimm/region_devs.c    | 10 +++---
 drivers/nvdimm/security.c       |  8 +++--
 14 files changed, 118 insertions(+), 77 deletions(-)
drivers/nvdimm/badrange.c +2 -1
index f2a742c6258a..681d99c59f52 100644
@@ -206,8 +206,9 @@ static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len)
 			remaining -= done;
 			s += done;
 		}
-	} else
+	} else {
 		set_badblock(bb, start_sector, num_sectors);
+	}
 }
 
 static void badblocks_populate(struct badrange *badrange,
drivers/nvdimm/blk.c +6 -3
index 95acb48bfaed..db3973c7f506 100644
@@ -301,13 +301,16 @@ static int nd_blk_probe(struct device *dev)
 	dev_set_drvdata(dev, nsblk);
 
 	ndns->rw_bytes = nsblk_rw_bytes;
+
 	if (is_nd_btt(dev))
 		return nvdimm_namespace_attach_btt(ndns);
-	else if (nd_btt_probe(dev, ndns) == 0) {
+
+	if (nd_btt_probe(dev, ndns) == 0) {
 		/* we'll come back as btt-blk */
 		return -ENXIO;
-	} else
-		return nsblk_attach_disk(nsblk);
+	}
+
+	return nsblk_attach_disk(nsblk);
 }
 
 static int nd_blk_remove(struct device *dev)
drivers/nvdimm/btt.c +3 -2
index 0927cbdc5cc6..39851edc2cc5 100644
@@ -702,9 +702,10 @@ static int log_set_indices(struct arena_info *arena)
 	 * Only allow the known permutations of log/padding indices,
 	 * i.e. (0, 1), and (0, 2)
 	 */
-	if ((log_index[0] == 0) && ((log_index[1] == 1) || (log_index[1] == 2)))
+	if ((log_index[0] == 0) &&
+	    ((log_index[1] == 1) || (log_index[1] == 2))) {
 		; /* known index possibilities */
-	else {
+	} else {
 		dev_err(to_dev(arena), "Found an unknown padding scheme\n");
 		return -ENXIO;
 	}
drivers/nvdimm/btt_devs.c +2 -2
index f6429842f1b6..9e0f17045e69 100644
@@ -139,9 +139,9 @@ static ssize_t size_show(struct device *dev,
 	ssize_t rc;
 
 	nd_device_lock(dev);
-	if (dev->driver)
+	if (dev->driver) {
 		rc = sprintf(buf, "%llu\n", nd_btt->size);
-	else {
+	} else {
 		/* no size to convey if the btt instance is disabled */
 		rc = -ENXIO;
 	}
drivers/nvdimm/bus.c +6 -4
index 5ffd61c9c4b7..620f07ac306c 100644
@@ -857,9 +857,9 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
 
 	if (nvdimm && cmd == ND_CMD_GET_CONFIG_DATA && idx == 1)
 		return in_field[1];
-	else if (nvdimm && cmd == ND_CMD_VENDOR && idx == 2)
+	if (nvdimm && cmd == ND_CMD_VENDOR && idx == 2)
 		return out_field[1];
-	else if (!nvdimm && cmd == ND_CMD_ARS_STATUS && idx == 2) {
+	if (!nvdimm && cmd == ND_CMD_ARS_STATUS && idx == 2) {
 		/*
 		 * Per table 9-276 ARS Data in ACPI 6.1, out_field[1] is
 		 * "Size of Output Buffer in bytes, including this
@@ -876,7 +876,8 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
 		if (out_field[1] - 4 == remainder)
 			return remainder;
 		return out_field[1] - 8;
-	} else if (cmd == ND_CMD_CALL) {
+	}
+	if (cmd == ND_CMD_CALL) {
 		struct nd_cmd_pkg *pkg = (struct nd_cmd_pkg *)in_field;
 
 		return pkg->nd_size_out;
@@ -929,8 +930,9 @@ static int nd_pmem_forget_poison_check(struct device *dev, void *data)
 
 		if (!ndns)
 			return 0;
-	} else
+	} else {
 		ndns = to_ndns(dev);
+	}
 
 	nsio = to_nd_namespace_io(&ndns->dev);
 	pstart = nsio->res.start + offset;
drivers/nvdimm/claim.c +4 -3
index ff66a3cc349c..3732925aadb8 100644
@@ -149,9 +149,9 @@ ssize_t nd_namespace_store(struct device *dev,
 		return -ENOMEM;
 	strim(name);
 
-	if (strncmp(name, "namespace", 9) == 0 || strcmp(name, "") == 0)
+	if (strncmp(name, "namespace", 9) == 0 || strcmp(name, "") == 0) {
 		/* pass */;
-	else {
+	} else {
 		len = -EINVAL;
 		goto out;
 	}
@@ -288,8 +288,9 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
 				badblocks_clear(&nsio->bb, sector, cleared);
 			}
 			arch_invalidate_pmem(nsio->addr + offset, size);
-		} else
+		} else {
 			rc = -EIO;
+		}
 	}
 
 	memcpy_flushcache(nsio->addr + offset, buf, size);
drivers/nvdimm/dax_devs.c +2 -1
index 6d22b0f83b3b..46230eb35b90 100644
@@ -125,8 +125,9 @@ int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)
 	if (rc < 0) {
 		nd_detach_ndns(dax_dev, &nd_pfn->ndns);
 		put_device(dax_dev);
-	} else
+	} else {
 		__nd_device_register(dax_dev);
+	}
 
 	return rc;
 }
drivers/nvdimm/dimm_devs.c +8 -5
index 873df96795b0..4df85dd72682 100644
@@ -361,8 +361,9 @@ static ssize_t available_slots_show(struct device *dev,
 	if (nfree - 1 > nfree) {
 		dev_WARN_ONCE(dev, 1, "we ate our last label?\n");
 		nfree = 0;
-	} else
+	} else {
 		nfree--;
+	}
 	rc = sprintf(buf, "%d\n", nfree);
 	nvdimm_bus_unlock(dev);
 	return rc;
@@ -728,14 +729,15 @@ resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
 	blk_start = max(map_start, map_end + 1 - *overlap);
 	for_each_dpa_resource(ndd, res) {
 		if (res->start >= map_start && res->start < map_end) {
-			if (strncmp(res->name, "blk", 3) == 0)
+			if (strncmp(res->name, "blk", 3) == 0) {
 				blk_start = min(blk_start,
 						max(map_start, res->start));
-			else if (res->end > map_end) {
+			} else if (res->end > map_end) {
 				reason = "misaligned to iset";
 				goto err;
-			} else
+			} else {
 				busy += resource_size(res);
+			}
 		} else if (res->end >= map_start && res->end <= map_end) {
 			if (strncmp(res->name, "blk", 3) == 0) {
 				/*
@@ -744,8 +746,9 @@ resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
 				 * be used for BLK.
 				 */
 				blk_start = map_start;
-			} else
+			} else {
 				busy += resource_size(res);
+			}
 		} else if (map_start > res->start && map_start < res->end) {
 			/* total eclipse of the mapping */
 			busy += nd_mapping->size;
drivers/nvdimm/label.c +7 -6
index bf58357927c4..e4632dbebead 100644
@@ -734,20 +734,21 @@ static const guid_t *to_abstraction_guid(enum nvdimm_claim_class claim_class,
 {
 	if (claim_class == NVDIMM_CCLASS_BTT)
 		return &nvdimm_btt_guid;
-	else if (claim_class == NVDIMM_CCLASS_BTT2)
+	if (claim_class == NVDIMM_CCLASS_BTT2)
 		return &nvdimm_btt2_guid;
-	else if (claim_class == NVDIMM_CCLASS_PFN)
+	if (claim_class == NVDIMM_CCLASS_PFN)
 		return &nvdimm_pfn_guid;
-	else if (claim_class == NVDIMM_CCLASS_DAX)
+	if (claim_class == NVDIMM_CCLASS_DAX)
 		return &nvdimm_dax_guid;
-	else if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
+	if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
 		/*
 		 * If we're modifying a namespace for which we don't
 		 * know the claim_class, don't touch the existing guid.
 		 */
 		return target;
-	} else
-		return &guid_null;
+	}
+
+	return &guid_null;
 }
 
 static void reap_victim(struct nd_mapping *nd_mapping,
drivers/nvdimm/namespace_devs.c +49 -29

209 lines not on this page · raw message

drivers/nvdimm/pfn_devs.c +14 -10
index 20a0cce9ee93..7226d6d95899 100644
@@ -69,22 +69,23 @@ static ssize_t mode_store(struct device *dev,
 
 	nd_device_lock(dev);
 	nvdimm_bus_lock(dev);
-	if (dev->driver)
+	if (dev->driver) {
 		rc = -EBUSY;
-	else {
+	} else {
 		size_t n = len - 1;
 
 		if (strncmp(buf, "pmem\n", n) == 0 ||
 		    strncmp(buf, "pmem", n) == 0) {
 			nd_pfn->mode = PFN_MODE_PMEM;
 		} else if (strncmp(buf, "ram\n", n) == 0 ||
-			   strncmp(buf, "ram", n) == 0)
+			   strncmp(buf, "ram", n) == 0) {
 			nd_pfn->mode = PFN_MODE_RAM;
-		else if (strncmp(buf, "none\n", n) == 0 ||
-			 strncmp(buf, "none", n) == 0)
+		} else if (strncmp(buf, "none\n", n) == 0 ||
+			   strncmp(buf, "none", n) == 0) {
 			nd_pfn->mode = PFN_MODE_NONE;
-		else
+		} else {
 			rc = -EINVAL;
+		}
 	}
 	dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
 		buf[len - 1] == '\n' ? "" : "\n");
@@ -575,8 +576,9 @@ int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns)
 	if (rc < 0) {
 		nd_detach_ndns(pfn_dev, &nd_pfn->ndns);
 		put_device(pfn_dev);
-	} else
+	} else {
 		__nd_device_register(pfn_dev);
+	}
 
 	return rc;
 }
@@ -643,8 +645,9 @@ static int __nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap)
 		altmap->free = PHYS_PFN(offset - reserve);
 		altmap->alloc = 0;
 		pgmap->flags |= PGMAP_ALTMAP_VALID;
-	} else
+	} else {
 		return -ENXIO;
+	}
 
 	return 0;
 }
@@ -706,10 +709,11 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
 		 * PMD_SIZE for most architectures.
 		 */
 		offset = ALIGN(start + SZ_8K + 64 * npfns, align) - start;
-	} else if (nd_pfn->mode == PFN_MODE_RAM)
+	} else if (nd_pfn->mode == PFN_MODE_RAM) {
 		offset = ALIGN(start + SZ_8K, align) - start;
-	else
+	} else {
 		return -ENXIO;
+	}
 
 	if (offset >= size) {
 		dev_err(&nd_pfn->dev, "%s unable to satisfy requested alignment\n",
drivers/nvdimm/pmem.c +4 -4
index dfe38d6b6607..64e7429edcc2 100644
@@ -150,9 +150,9 @@ static blk_status_t pmem_do_bvec(struct pmem_device *pmem, struct page *page,
 		bad_pmem = true;
 
 	if (!op_is_write(op)) {
-		if (unlikely(bad_pmem))
+		if (unlikely(bad_pmem)) {
 			rc = BLK_STS_IOERR;
-		else {
+		} else {
 			rc = read_pmem(page, off, pmem_addr, len);
 			flush_dcache_page(page);
 		}
@@ -519,9 +519,9 @@ static int nd_pmem_remove(struct device *dev)
 {
 	struct pmem_device *pmem = dev_get_drvdata(dev);
 
-	if (is_nd_btt(dev))
+	if (is_nd_btt(dev)) {
 		nvdimm_namespace_detach_btt(to_nd_btt(dev));
-	else {
+	} else {
 		/*
 		 * Note, this assumes nd_device_lock() context to not
 		 * race nd_pmem_notify()
drivers/nvdimm/region_devs.c +6 -4
index 76b08b64b0b1..16dfdbdbf1c8 100644
@@ -381,8 +381,9 @@ resource_size_t nd_region_available_dpa(struct nd_region *nd_region)
 				blk_max_overlap = overlap;
 				goto retry;
 			}
-		} else if (is_nd_blk(&nd_region->dev))
+		} else if (is_nd_blk(&nd_region->dev)) {
 			available += nd_blk_available_dpa(nd_region);
+		}
 	}
 
 	return available;
@@ -956,8 +957,9 @@ unsigned int nd_region_acquire_lane(struct nd_region *nd_region)
 		ndl_lock = per_cpu_ptr(nd_region->lane, lane);
 		if (ndl_count->count++ == 0)
 			spin_lock(&ndl_lock->lock);
-	} else
+	} else {
 		lane = cpu;
+	}
 
 	return lane;
 }
@@ -1132,9 +1134,9 @@ int nvdimm_flush(struct nd_region *nd_region, struct bio *bio)
 {
 	int rc = 0;
 
-	if (!nd_region->flush)
+	if (!nd_region->flush) {
 		rc = generic_nvdimm_flush(nd_region);
-	else {
+	} else {
 		if (nd_region->flush(nd_region, bio))
 			rc = -EIO;
 	}
drivers/nvdimm/security.c +5 -3
index 13bc5d54f0b6..693416001d17 100644
@@ -194,8 +194,9 @@ static int __nvdimm_security_unlock(struct nvdimm *nvdimm)
 			return 0;
 
 		return nvdimm_key_revalidate(nvdimm);
-	} else
-		data = nvdimm_get_key_payload(nvdimm, &key);
+	}
+
+	data = nvdimm_get_key_payload(nvdimm, &key);
 
 	rc = nvdimm->sec.ops->unlock(nvdimm, data);
 	dev_dbg(dev, "key: %d unlock: %s\n", key_serial(key),
@@ -544,8 +545,9 @@ ssize_t nvdimm_security_store(struct device *dev, const char *buf, size_t len)
 			return -EBUSY;
 		}
 		rc = security_overwrite(nvdimm, key);
-	} else
+	} else {
 		return -EINVAL;
+	}
 
 	if (rc == 0)
 		rc = len;
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#11 lore raw

PATCH 8/13 nvdimm: Use typical kernel style indentation

In reply to Joe Perches

Make the nvdimm code more like the rest of the kernel.

Avoid indentation of labels and spaces where tabs should be used.

---
 drivers/nvdimm/btt.c         | 2 +-
 drivers/nvdimm/region_devs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/nvdimm/btt.c +1 -1
index 39851edc2cc5..0df4461fe607 100644
@@ -1320,7 +1320,7 @@ static int btt_write_pg(struct btt *btt, struct bio_integrity_payload *bip,
 		u32 cur_len;
 		int e_flag;
 
-	retry:
+retry:
 		lane = nd_region_acquire_lane(btt->nd_region);
 
 		ret = lba_to_arena(btt, sector, &premap, &arena);
drivers/nvdimm/region_devs.c +1 -1
index 16dfdbdbf1c8..65df07481909 100644
@@ -1044,7 +1044,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
 	if (!nd_region->lane)
 		goto err_percpu;
 
-        for (i = 0; i < nr_cpu_ids; i++) {
+	for (i = 0; i < nr_cpu_ids; i++) {
 		struct nd_percpu_lane *ndl;
 
 		ndl = per_cpu_ptr(nd_region->lane, i);
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#12 lore raw

PATCH 9/13 nvdimm: btt.h: Neaten #defines to improve readability

In reply to Joe Perches

Use tab alignment to make the content and macro a bit more intelligible.

Use the BIT and BIT_ULL macros.
Convert MAP_LBA_MASK to use the already defined shift masks.

---
 drivers/nvdimm/btt.h | 54 ++++++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/nvdimm/btt.h +27 -27
index 1da76da3e159..fb0f4546153f 100644
@@ -10,34 +10,34 @@
 #include <linux/badblocks.h>
 #include <linux/types.h>
 
-#define BTT_SIG_LEN 16
-#define BTT_SIG "BTT_ARENA_INFO\0"
-#define MAP_ENT_SIZE 4
-#define MAP_TRIM_SHIFT 31
-#define MAP_TRIM_MASK (1 << MAP_TRIM_SHIFT)
-#define MAP_ERR_SHIFT 30
-#define MAP_ERR_MASK (1 << MAP_ERR_SHIFT)
-#define MAP_LBA_MASK (~((1 << MAP_TRIM_SHIFT) | (1 << MAP_ERR_SHIFT)))
-#define MAP_ENT_NORMAL 0xC0000000
-#define LOG_GRP_SIZE sizeof(struct log_group)
-#define LOG_ENT_SIZE sizeof(struct log_entry)
-#define ARENA_MIN_SIZE (1UL << 24)	/* 16 MB */
-#define ARENA_MAX_SIZE (1ULL << 39)	/* 512 GB */
-#define RTT_VALID (1UL << 31)
-#define RTT_INVALID 0
-#define BTT_PG_SIZE 4096
-#define BTT_DEFAULT_NFREE ND_MAX_LANES
-#define LOG_SEQ_INIT 1
-
-#define IB_FLAG_ERROR 0x00000001
-#define IB_FLAG_ERROR_MASK 0x00000001
-
-#define ent_lba(ent) (ent & MAP_LBA_MASK)
-#define ent_e_flag(ent) (!!(ent & MAP_ERR_MASK))
-#define ent_z_flag(ent) (!!(ent & MAP_TRIM_MASK))
-#define set_e_flag(ent) (ent |= MAP_ERR_MASK)
+#define BTT_SIG_LEN		16
+#define BTT_SIG			"BTT_ARENA_INFO\0"
+#define MAP_ENT_SIZE		4
+#define MAP_TRIM_SHIFT		31
+#define MAP_TRIM_MASK		BIT(MAP_TRIM_SHIFT)
+#define MAP_ERR_SHIFT		30
+#define MAP_ERR_MASK		BIT(MAP_ERR_SHIFT)
+#define MAP_LBA_MASK		(~(MAP_TRIM_MASK | MAP_ERR_MASK))
+#define MAP_ENT_NORMAL		0xC0000000
+#define LOG_GRP_SIZE		sizeof(struct log_group)
+#define LOG_ENT_SIZE		sizeof(struct log_entry)
+#define ARENA_MIN_SIZE		BIT(24)		/* 16 MB */
+#define ARENA_MAX_SIZE		BIT_ULL(39)	/* 512 GB */
+#define RTT_VALID		BIT(31)
+#define RTT_INVALID		0
+#define BTT_PG_SIZE		4096
+#define BTT_DEFAULT_NFREE	ND_MAX_LANES
+#define LOG_SEQ_INIT		1
+
+#define IB_FLAG_ERROR		0x00000001
+#define IB_FLAG_ERROR_MASK	0x00000001
+
+#define ent_lba(ent)		((ent) & MAP_LBA_MASK)
+#define ent_e_flag(ent)		(!!((ent) & MAP_ERR_MASK))
+#define ent_z_flag(ent)		(!!((ent) & MAP_TRIM_MASK))
+#define set_e_flag(ent)		((ent) |= MAP_ERR_MASK)
 /* 'normal' is both e and z flags set */
-#define ent_normal(ent) (ent_e_flag(ent) && ent_z_flag(ent))
+#define ent_normal(ent)		(ent_e_flag(ent) && ent_z_flag(ent))
 
 enum btt_init_state {
 	INIT_UNCHECKED = 0,
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#13 lore raw

PATCH 10/13 nvdimm: namespace_devs: Move assignment operators

In reply to Joe Perches

Kernel code uses assignment operators where the statement is split on multiple lines on the first line.

Move 2 unusual uses.

---
 drivers/nvdimm/namespace_devs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/nvdimm/namespace_devs.c +4 -4
index 70e1d752c12c..8c75ef84bad7 100644
@@ -2023,8 +2023,8 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
 		nspm->lbasize = __le64_to_cpu(label0->lbasize);
 		ndd = to_ndd(nd_mapping);
 		if (namespace_label_has(ndd, abstraction_guid))
-			nspm->nsio.common.claim_class
-				= to_nvdimm_cclass(&label0->abstraction_guid);
+			nspm->nsio.common.claim_class =
+				to_nvdimm_cclass(&label0->abstraction_guid);
 	}
 
 	if (!nspm->alt_name || !nspm->uuid) {
@@ -2267,8 +2267,8 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
 	nsblk->uuid = kmemdup(nd_label->uuid, NSLABEL_UUID_LEN,
 			      GFP_KERNEL);
 	if (namespace_label_has(ndd, abstraction_guid))
-		nsblk->common.claim_class
-			= to_nvdimm_cclass(&nd_label->abstraction_guid);
+		nsblk->common.claim_class =
+			to_nvdimm_cclass(&nd_label->abstraction_guid);
 	if (!nsblk->uuid)
 		goto blk_err;
 	memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#14 lore raw

PATCH 11/13 nvdimm: Use more common logic testing styles and bare ; positions

In reply to Joe Perches

Avoid using uncommon logic testing styles to make the code a bit more like other kernel code.

e.g.:

	if (foo) {
		;
	} else {
		<code>
	}

is typically written

	if (!foo) {
		<code>
	}

Also put bare semicolons before the comment not after the comment

e.g.:

	if (foo) {
		/* comment */;
	} else if (bar) {
		<code>
	} else {
		baz;
	}

is typically written

	if (foo) {
		;	/* comment */
	} else if (bar) {
		<code>
	} else {
		baz;
	}
---
 drivers/nvdimm/claim.c          |  4 +---
 drivers/nvdimm/dimm_devs.c      | 11 ++++------
 drivers/nvdimm/label.c          |  4 +---
 drivers/nvdimm/namespace_devs.c | 46 +++++++++++++++++++----------------------
 drivers/nvdimm/region_devs.c    |  4 +---
 5 files changed, 28 insertions(+), 41 deletions(-)
drivers/nvdimm/claim.c +1 -3
index 3732925aadb8..244631f5308c 100644
@@ -149,9 +149,7 @@ ssize_t nd_namespace_store(struct device *dev,
 		return -ENOMEM;
 	strim(name);
 
-	if (strncmp(name, "namespace", 9) == 0 || strcmp(name, "") == 0) {
-		/* pass */;
-	} else {
+	if (!(strncmp(name, "namespace", 9) == 0 || strcmp(name, "") == 0)) {
 		len = -EINVAL;
 		goto out;
 	}
drivers/nvdimm/dimm_devs.c +4 -7
index 4df85dd72682..cac62bb726bb 100644
@@ -593,13 +593,10 @@ int alias_dpa_busy(struct device *dev, void *data)
 	 * looking to validate against PMEM aliasing collision rules
 	 * (i.e. BLK is allocated after all aliased PMEM).
 	 */
-	if (info->res) {
-		if (info->res->start >= nd_mapping->start &&
-		    info->res->start < map_end)
-			/* pass */;
-		else
-			return 0;
-	}
+	if (info->res &&
+	    (info->res->start < nd_mapping->start ||
+	     info->res->start >= map_end))
+		return 0;
 
 retry:
 	/*
drivers/nvdimm/label.c +1 -3
index e4632dbebead..ae466c6faa90 100644
@@ -1180,9 +1180,7 @@ static int init_labels(struct nd_mapping *nd_mapping, int num_labels)
 		mutex_unlock(&nd_mapping->lock);
 	}
 
-	if (ndd->ns_current == -1 || ndd->ns_next == -1)
-		/* pass */;
-	else
+	if (ndd->ns_current != -1 && ndd->ns_next != -1)
 		return max(num_labels, old_num_labels);
 
 	nsindex = to_namespace_index(ndd, 0);
drivers/nvdimm/namespace_devs.c +21 -25

86 lines not on this page · raw message

drivers/nvdimm/region_devs.c +1 -3
index 65df07481909..6861e0997d21 100644
@@ -320,9 +320,7 @@ static ssize_t set_cookie_show(struct device *dev,
 	struct nd_interleave_set *nd_set = nd_region->nd_set;
 	ssize_t rc = 0;
 
-	if (is_memory(dev) && nd_set)
-		/* pass, should be precluded by region_visible */;
-	else
+	if (!(is_memory(dev) && nd_set))
 		return -ENXIO;
 
 	/*
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
maintainer
#15 lore raw

Re: [PATCH 11/13] nvdimm: Use more common logic testing styles and bare ; positions

Quoted 10 lines · Joe Perches

Avoid using uncommon logic testing styles to make the code a bit more like other kernel code.

e.g.:

	if (foo) {
		;
	} else {
		<code>
	}
Quoted 6 lines

is typically written

	if (!foo) {
		<code>
	}

A lot of times the excessive inversions seem to result in a net loss of readability - e.g.:

<snip>

drivers/nvdimm/region_devs.c static ssize_t set_cookie_show(struct device *dev, · line 324

Quoted 11 lines
drivers/nvdimm/region_devs.c +0 -2
index 65df07481909..6861e0997d21 100644
@@ -320,9 +320,7 @@ static ssize_t set_cookie_show(struct device *dev,
 	struct nd_interleave_set *nd_set = nd_region->nd_set;
 	ssize_t rc = 0;
 
-	if (is_memory(dev) && nd_set)
-		/* pass, should be precluded by region_visible */;

For one, the comment is lost

drivers/nvdimm/region_devs.c static ssize_t set_cookie_show(struct device *dev, · line 323

Quoted 2 lines
drivers/nvdimm/region_devs.c +1 -1
-	else
+	if (!(is_memory(dev) && nd_set))

And it takes a moment to resolve between things such as:

	if (!(A && B))
	  vs.
	if (!(A) && B)

And this is especially true if 'A' and 'B' are longer function calls, split over multiple lines, or are themselves compound 'sections'.

I'm not opposed to /all/ such transformations -- for example, the ones where the logical inversion can be 'consumed' by toggling a comparision operator, as you have a few times in this patch, don't sacrifice any readibility, and perhaps even improve it.

Quoted 3 lines
drivers/nvdimm/region_devs.c +0 -0
 		return -ENXIO;
 
 	/*
#16 lore raw

PATCH 12/13 nvdimm: namespace_devs: Change progess typo to progress

In reply to Joe Perches

Typing is hard.

---
 drivers/nvdimm/namespace_devs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/namespace_devs.c +1 -1
index 7a16340f9853..253f07d97b73 100644
@@ -1718,7 +1718,7 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
 			return ERR_PTR(-ENODEV);
 
 		/*
-		 * Flush any in-progess probes / removals in the driver
+		 * Flush any in-progress probes / removals in the driver
 		 * for the raw personality of this namespace.
 		 */
 		nd_device_lock(&ndns->dev);
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#17 lore raw

PATCH 13/13 nvdimm: Miscellaneous neatening

In reply to Joe Perches

Random neatening, mostly trivially wrapping to 80 columns, to make the code a bit more kernel style compatible.

Use casts to (u64) and not (unsigned long long)

---
 drivers/nvdimm/badrange.c       |   3 +-
 drivers/nvdimm/blk.c            |  18 ++++---
 drivers/nvdimm/btt.c            |  22 ++++----
 drivers/nvdimm/btt_devs.c       |  42 +++++++++-------
 drivers/nvdimm/bus.c            |  25 ++++-----
 drivers/nvdimm/claim.c          |  11 ++--
 drivers/nvdimm/core.c           |   4 +-
 drivers/nvdimm/dimm_devs.c      |  18 ++++---
 drivers/nvdimm/label.c          |  35 +++++++------
 drivers/nvdimm/label.h          |   6 ++-
 drivers/nvdimm/namespace_devs.c | 109 +++++++++++++++++++++++-----------------
 drivers/nvdimm/nd-core.h        |  13 ++---
 drivers/nvdimm/nd.h             |  26 +++++-----
 drivers/nvdimm/nd_virtio.c      |   3 +-
 drivers/nvdimm/pfn_devs.c       |  43 ++++++++--------
 drivers/nvdimm/pmem.c           |  14 +++---
 drivers/nvdimm/region_devs.c    |  36 +++++++------
 drivers/nvdimm/security.c       |  28 +++++------
 drivers/nvdimm/virtio_pmem.c    |   4 +-
 19 files changed, 254 insertions(+), 206 deletions(-)
drivers/nvdimm/badrange.c +2 -1
index 681d99c59f52..4d231643c095 100644
@@ -24,7 +24,8 @@ void badrange_init(struct badrange *badrange)
 EXPORT_SYMBOL_GPL(badrange_init);
 
 static void append_badrange_entry(struct badrange *badrange,
-				  struct badrange_entry *bre, u64 addr, u64 length)
+				  struct badrange_entry *bre,
+				  u64 addr, u64 length)
 {
 	lockdep_assert_held(&badrange->lock);
 	bre->start = addr;
drivers/nvdimm/blk.c +11 -7
index db3973c7f506..fc15aa9220c8 100644
@@ -29,7 +29,8 @@ static u32 nsblk_sector_size(struct nd_namespace_blk *nsblk)
 }
 
 static resource_size_t to_dev_offset(struct nd_namespace_blk *nsblk,
-				     resource_size_t ns_offset, unsigned int len)
+				     resource_size_t ns_offset,
+				     unsigned int len)
 {
 	int i;
 
@@ -61,7 +62,8 @@ static struct nd_blk_region *to_ndbr(struct nd_namespace_blk *nsblk)
 
 #ifdef CONFIG_BLK_DEV_INTEGRITY
 static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
-			       struct bio_integrity_payload *bip, u64 lba, int rw)
+			       struct bio_integrity_payload *bip,
+			       u64 lba, int rw)
 {
 	struct nd_blk_region *ndbr = to_ndbr(nsblk);
 	unsigned int len = nsblk_meta_size(nsblk);
@@ -107,7 +109,8 @@ static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
 
 #else /* CONFIG_BLK_DEV_INTEGRITY */
 static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
-			       struct bio_integrity_payload *bip, u64 lba, int rw)
+			       struct bio_integrity_payload *bip,
+			       u64 lba, int rw)
 {
 	return 0;
 }
@@ -115,7 +118,8 @@ static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
 
 static int nsblk_do_bvec(struct nd_namespace_blk *nsblk,
 			 struct bio_integrity_payload *bip, struct page *page,
-			 unsigned int len, unsigned int off, int rw, sector_t sector)
+			 unsigned int len, unsigned int off, int rw,
+			 sector_t sector)
 {
 	struct nd_blk_region *ndbr = to_ndbr(nsblk);
 	resource_size_t	dev_offset, ns_offset;
@@ -187,9 +191,9 @@ static blk_qc_t nd_blk_make_request(struct request_queue *q, struct bio *bio)
 				    bvec.bv_offset, rw, iter.bi_sector);
 		if (err) {
 			dev_dbg(&nsblk->common.dev,
-				"io error in %s sector %lld, len %d,\n",
-				(rw == READ) ? "READ" : "WRITE",
-				(unsigned long long)iter.bi_sector, len);
+				"io error in %s sector %lld, len %d\n",
+				rw == READ ? "READ" : "WRITE",
+				(u64)iter.bi_sector, len);
 			bio->bi_status = errno_to_blk_status(err);
 			break;
 		}
drivers/nvdimm/btt.c +12 -10
index 0df4461fe607..6c18d7bba6af 100644
@@ -589,7 +589,8 @@ static int btt_freelist_init(struct arena_info *arena)
 			 * to complete the map write. So fix up the map.
 			 */
 			ret = btt_map_write(arena, le32_to_cpu(log_new.lba),
-					    le32_to_cpu(log_new.new_map), 0, 0, 0);
+					    le32_to_cpu(log_new.new_map),
+					    0, 0, 0);
 			if (ret)
 				return ret;
 		}
@@ -827,8 +828,9 @@ static void parse_arena_meta(struct arena_info *arena, struct btt_sb *super,
 	arena->version_major = le16_to_cpu(super->version_major);
 	arena->version_minor = le16_to_cpu(super->version_minor);
 
-	arena->nextoff = (super->nextoff == 0) ? 0 : (arena_off +
-						      le64_to_cpu(super->nextoff));
+	arena->nextoff = (super->nextoff == 0)
+		? 0
+		: arena_off + le64_to_cpu(super->nextoff);
 	arena->infooff = arena_off;
 	arena->dataoff = arena_off + le64_to_cpu(super->dataoff);
 	arena->mapoff = arena_off + le64_to_cpu(super->mapoff);
@@ -836,8 +838,8 @@ static void parse_arena_meta(struct arena_info *arena, struct btt_sb *super,
 	arena->info2off = arena_off + le64_to_cpu(super->info2off);
 
 	arena->size = (le64_to_cpu(super->nextoff) > 0)
-		? (le64_to_cpu(super->nextoff))
-		: (arena->info2off - arena->infooff + BTT_PG_SIZE);
+		? le64_to_cpu(super->nextoff)
+		: arena->info2off - arena->infooff + BTT_PG_SIZE;
 
 	arena->flags = le32_to_cpu(super->flags);
 }
@@ -1457,7 +1459,8 @@ static blk_qc_t btt_make_request(struct request_queue *q, struct bio *bio)
 		if (len > PAGE_SIZE || len < btt->sector_size ||
 		    len % btt->sector_size) {
 			dev_err_ratelimited(&btt->nd_btt->dev,
-					    "unaligned bio segment (len: %d)\n", len);
+					    "unaligned bio segment (len: %d)\n",
+					    len);
 			bio->bi_status = BLK_STS_IOERR;
 			break;
 		}
@@ -1466,10 +1469,9 @@ static blk_qc_t btt_make_request(struct request_queue *q, struct bio *bio)
 				  bio_op(bio), iter.bi_sector);
 		if (err) {
 			dev_err(&btt->nd_btt->dev,
-				"io error in %s sector %lld, len %d,\n",
-				(op_is_write(bio_op(bio))) ? "WRITE" :
-				"READ",
-				(unsigned long long)iter.bi_sector, len);
+				"io error in %s sector %lld, len %d\n",
+				op_is_write(bio_op(bio)) ? "WRITE" : "READ",
+				(u64)iter.bi_sector, len);
 			bio->bi_status = errno_to_blk_status(err);
 			break;
 		}
drivers/nvdimm/btt_devs.c +23 -19

106 lines not on this page · raw message

drivers/nvdimm/bus.c +13 -12
index 620f07ac306c..733b2a2117c0 100644
@@ -103,8 +103,8 @@ static int nvdimm_bus_probe(struct device *dev)
 		nd_region_disable(nvdimm_bus, dev);
 	nvdimm_bus_probe_end(nvdimm_bus);
 
-	dev_dbg(&nvdimm_bus->dev, "END: %s.probe(%s) = %d\n", dev->driver->name,
-		dev_name(dev), rc);
+	dev_dbg(&nvdimm_bus->dev, "END: %s.probe(%s) = %d\n",
+		dev->driver->name, dev_name(dev), rc);
 
 	if (rc != 0)
 		module_put(provider);
@@ -125,8 +125,8 @@ static int nvdimm_bus_remove(struct device *dev)
 	}
 	nd_region_disable(nvdimm_bus, dev);
 
-	dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n", dev->driver->name,
-		dev_name(dev), rc);
+	dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n",
+		dev->driver->name, dev_name(dev), rc);
 	module_put(provider);
 	return rc;
 }
@@ -846,8 +846,9 @@ u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd,
 EXPORT_SYMBOL_GPL(nd_cmd_in_size);
 
 u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
-		    const struct nd_cmd_desc *desc, int idx, const u32 *in_field,
-		    const u32 *out_field, unsigned long remainder)
+		    const struct nd_cmd_desc *desc, int idx,
+		    const u32 *in_field, const u32 *out_field,
+		    unsigned long remainder)
 {
 	if (idx >= desc->out_num)
 		return UINT_MAX;
@@ -951,7 +952,8 @@ static int nd_ns_forget_poison_check(struct device *dev, void *data)
 
 /* set_config requires an idle interleave set */
 static int nd_cmd_clear_to_send(struct nvdimm_bus *nvdimm_bus,
-				struct nvdimm *nvdimm, unsigned int cmd, void *data)
+				struct nvdimm *nvdimm,
+				unsigned int cmd, void *data)
 {
 	struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
 
@@ -1025,7 +1027,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 		case ND_CMD_ARS_START:
 		case ND_CMD_CLEAR_ERROR:
 		case ND_CMD_CALL:
-			dev_dbg(dev, "'%s' command while read-only.\n",
+			dev_dbg(dev, "'%s' command while read-only\n",
 				nvdimm ? nvdimm_cmd_name(cmd)
 				: nvdimm_bus_cmd_name(cmd));
 			return -EPERM;
@@ -1061,8 +1063,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 	if (cmd == ND_CMD_CALL) {
 		func = pkg.nd_command;
 		dev_dbg(dev, "%s, idx: %llu, in: %u, out: %u, len %llu\n",
-			dimm_name, pkg.nd_command,
-			in_len, out_len, buf_len);
+			dimm_name, pkg.nd_command, in_len, out_len, buf_len);
 	}
 
 	/* process an output envelope */
@@ -1097,8 +1098,8 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 
 	buf_len = (u64)out_len + (u64)in_len;
 	if (buf_len > ND_IOCTL_MAX_BUFLEN) {
-		dev_dbg(dev, "%s cmd: %s buf_len: %llu > %d\n", dimm_name,
-			cmd_name, buf_len, ND_IOCTL_MAX_BUFLEN);
+		dev_dbg(dev, "%s cmd: %s buf_len: %llu > %d\n",
+			dimm_name, cmd_name, buf_len, ND_IOCTL_MAX_BUFLEN);
 		rc = -EINVAL;
 		goto out;
 	}
drivers/nvdimm/claim.c +6 -5
index 244631f5308c..953029c240e5 100644
@@ -132,8 +132,8 @@ static void nd_detach_and_reset(struct device *dev,
 }
 
 ssize_t nd_namespace_store(struct device *dev,
-			   struct nd_namespace_common **_ndns, const char *buf,
-			   size_t len)
+			   struct nd_namespace_common **_ndns,
+			   const char *buf, size_t len)
 {
 	struct nd_namespace_common *ndns;
 	struct device *found;
@@ -158,7 +158,8 @@ ssize_t nd_namespace_store(struct device *dev,
 	if (strcmp(name, "") == 0) {
 		nd_detach_and_reset(dev, _ndns);
 		goto out;
-	} else if (ndns) {
+	}
+	if (ndns) {
 		dev_dbg(dev, "namespace already set to: %s\n",
 			dev_name(&ndns->dev));
 		len = -EBUSY;
@@ -200,7 +201,6 @@ ssize_t nd_namespace_store(struct device *dev,
 	default:
 		len = -EBUSY;
 		goto out_attach;
-		break;
 	}
 
 	if (__nvdimm_namespace_capacity(ndns) < SZ_16M) {
@@ -278,7 +278,8 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
 
 			might_sleep();
 			cleared = nvdimm_clear_poison(&ndns->dev,
-						      nsio->res.start + offset, size);
+						      nsio->res.start + offset,
+						      size);
 			if (cleared < size)
 				rc = -EIO;
 			if (cleared > 0 && cleared / 512) {
drivers/nvdimm/core.c +1 -3
index e30b39f49c46..deb92c806abf 100644
@@ -208,9 +208,7 @@ EXPORT_SYMBOL_GPL(to_nvdimm_bus_dev);
 
 static bool is_uuid_sep(char sep)
 {
-	if (sep == '\n' || sep == '-' || sep == ':' || sep == '\0')
-		return true;
-	return false;
+	return sep == '\n' || sep == '-' || sep == ':' || sep == '\0';
 }
 
 static int nd_uuid_parse(struct device *dev, u8 *uuid_out, const char *buf,
drivers/nvdimm/dimm_devs.c +11 -7
index cac62bb726bb..35a6c20d30fd 100644
@@ -114,7 +114,8 @@ int nvdimm_get_config_data(struct nvdimm_drvdata *ndd, void *buf,
 		cmd_size = sizeof(*cmd) + cmd->in_length;
 
 		rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev),
-				    ND_CMD_GET_CONFIG_DATA, cmd, cmd_size, &cmd_rc);
+				    ND_CMD_GET_CONFIG_DATA, cmd, cmd_size,
+				    &cmd_rc);
 		if (rc < 0)
 			break;
 		if (cmd_rc < 0) {
@@ -162,7 +163,8 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
 		cmd_size = sizeof(*cmd) + cmd->in_length + sizeof(u32);
 
 		rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev),
-				    ND_CMD_SET_CONFIG_DATA, cmd, cmd_size, &cmd_rc);
+				    ND_CMD_SET_CONFIG_DATA, cmd, cmd_size,
+				    &cmd_rc);
 		if (rc < 0)
 			break;
 		if (cmd_rc < 0) {
@@ -341,8 +343,8 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
 	 */
 	nvdimm_bus_lock(dev);
 	nvdimm_bus_unlock(dev);
-	return sprintf(buf, "%s\n", atomic_read(&nvdimm->busy)
-		       ? "active" : "idle");
+	return sprintf(buf, "%s\n",
+		       atomic_read(&nvdimm->busy) ? "active" : "idle");
 }
 static DEVICE_ATTR_RO(state);
 
@@ -397,7 +399,8 @@ static ssize_t frozen_show(struct device *dev,
 static DEVICE_ATTR_RO(frozen);
 
 static ssize_t security_store(struct device *dev,
-			      struct device_attribute *attr, const char *buf, size_t len)
+			      struct device_attribute *attr,
+			      const char *buf, size_t len)
 
 {
 	ssize_t rc;
@@ -551,7 +554,7 @@ int nvdimm_security_freeze(struct nvdimm *nvdimm)
 		return -EIO;
 
 	if (test_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags)) {
-		dev_warn(&nvdimm->dev, "Overwrite operation in progress.\n");
+		dev_warn(&nvdimm->dev, "Overwrite operation in progress\n");
 		return -EBUSY;
 	}
 
@@ -711,7 +714,8 @@ resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
  * the set can be established.
  */
 resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
-				      struct nd_mapping *nd_mapping, resource_size_t *overlap)
+				      struct nd_mapping *nd_mapping,
+				      resource_size_t *overlap)
 {
 	resource_size_t map_start, map_end, busy = 0, available, blk_start;
 	struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
drivers/nvdimm/label.c +19 -16
index ae466c6faa90..9bf75dad8e93 100644
@@ -159,7 +159,8 @@ static int __nd_label_validate(struct nvdimm_drvdata *ndd)
 
 		seq = __le32_to_cpu(nsindex[i]->seq);
 		if ((seq & NSINDEX_SEQ_MASK) == 0) {
-			dev_dbg(dev, "nsindex%d sequence: %#x invalid\n", i, seq);
+			dev_dbg(dev, "nsindex%d sequence: %#x invalid\n",
+				i, seq);
 			continue;
 		}
 
@@ -167,29 +168,27 @@ static int __nd_label_validate(struct nvdimm_drvdata *ndd)
 		if (__le64_to_cpu(nsindex[i]->myoff)
 		    != i * sizeof_namespace_index(ndd)) {
 			dev_dbg(dev, "nsindex%d myoff: %#llx invalid\n",
-				i, (unsigned long long)
-				__le64_to_cpu(nsindex[i]->myoff));
+				i, (u64)__le64_to_cpu(nsindex[i]->myoff));
 			continue;
 		}
 		if (__le64_to_cpu(nsindex[i]->otheroff)
 		    != (!i) * sizeof_namespace_index(ndd)) {
 			dev_dbg(dev, "nsindex%d otheroff: %#llx invalid\n",
-				i, (unsigned long long)
-				__le64_to_cpu(nsindex[i]->otheroff));
+				i, (u64)__le64_to_cpu(nsindex[i]->otheroff));
 			continue;
 		}
 		if (__le64_to_cpu(nsindex[i]->labeloff)
 		    != 2 * sizeof_namespace_index(ndd)) {
 			dev_dbg(dev, "nsindex%d labeloff: %#llx invalid\n",
-				i, (unsigned long long)
-				__le64_to_cpu(nsindex[i]->labeloff));
+				i, (u64)__le64_to_cpu(nsindex[i]->labeloff));
 			continue;
 		}
 
 		size = __le64_to_cpu(nsindex[i]->mysize);
 		if (size > sizeof_namespace_index(ndd) ||
 		    size < sizeof(struct nd_namespace_index)) {
-			dev_dbg(dev, "nsindex%d mysize: %#llx invalid\n", i, size);
+			dev_dbg(dev, "nsindex%d mysize: %#llx invalid\n",
+				i, size);
 			continue;
 		}
 
@@ -717,13 +716,13 @@ enum nvdimm_claim_class to_nvdimm_cclass(guid_t *guid)
 {
 	if (guid_equal(guid, &nvdimm_btt_guid))
 		return NVDIMM_CCLASS_BTT;
-	else if (guid_equal(guid, &nvdimm_btt2_guid))
+	if (guid_equal(guid, &nvdimm_btt2_guid))
 		return NVDIMM_CCLASS_BTT2;
-	else if (guid_equal(guid, &nvdimm_pfn_guid))
+	if (guid_equal(guid, &nvdimm_pfn_guid))
 		return NVDIMM_CCLASS_PFN;
-	else if (guid_equal(guid, &nvdimm_dax_guid))
+	if (guid_equal(guid, &nvdimm_dax_guid))
 		return NVDIMM_CCLASS_DAX;
-	else if (guid_equal(guid, &guid_null))
+	if (guid_equal(guid, &guid_null))
 		return NVDIMM_CCLASS_NONE;
 
 	return NVDIMM_CCLASS_UNKNOWN;
@@ -763,7 +762,8 @@ static void reap_victim(struct nd_mapping *nd_mapping,
 }
 
 static int __pmem_label_update(struct nd_region *nd_region,
-			       struct nd_mapping *nd_mapping, struct nd_namespace_pmem *nspm,
+			       struct nd_mapping *nd_mapping,
+			       struct nd_namespace_pmem *nspm,
 			       int pos, unsigned long flags)
 {
 	struct nd_namespace_common *ndns = &nspm->nsio.common;
@@ -901,7 +901,8 @@ static struct resource *to_resource(struct nvdimm_drvdata *ndd,
  * 3/ Record the resources in the namespace device
  */
 static int __blk_label_update(struct nd_region *nd_region,
-			      struct nd_mapping *nd_mapping, struct nd_namespace_blk *nsblk,
+			      struct nd_mapping *nd_mapping,
+			      struct nd_namespace_blk *nsblk,
 			      int num_labels)
 {
 	int i, alloc, victims, nfree, old_num_resources, nlabel, rc = -ENXIO;
@@ -1245,7 +1246,8 @@ static int del_labels(struct nd_mapping *nd_mapping, u8 *uuid)
 }
 
 int nd_pmem_namespace_label_update(struct nd_region *nd_region,
-				   struct nd_namespace_pmem *nspm, resource_size_t size)
+				   struct nd_namespace_pmem *nspm,
+				   resource_size_t size)
 {
 	int i, rc;
 
@@ -1293,7 +1295,8 @@ int nd_pmem_namespace_label_update(struct nd_region *nd_region,
 }
 
 int nd_blk_namespace_label_update(struct nd_region *nd_region,
-				  struct nd_namespace_blk *nsblk, resource_size_t size)
+				  struct nd_namespace_blk *nsblk,
+				  resource_size_t size)
 {
 	struct nd_mapping *nd_mapping = &nd_region->mapping[0];
 	struct resource *res;
drivers/nvdimm/label.h +4 -2
index aff33d09fec3..a008ec92f78c 100644
@@ -140,7 +140,9 @@ struct nd_region;
 struct nd_namespace_pmem;
 struct nd_namespace_blk;
 int nd_pmem_namespace_label_update(struct nd_region *nd_region,
-				   struct nd_namespace_pmem *nspm, resource_size_t size);
+				   struct nd_namespace_pmem *nspm,
+				   resource_size_t size);
 int nd_blk_namespace_label_update(struct nd_region *nd_region,
-				  struct nd_namespace_blk *nsblk, resource_size_t size);
+				  struct nd_namespace_blk *nsblk,
+				  resource_size_t size);
 #endif /* __LABEL_H__ */
drivers/nvdimm/namespace_devs.c +62 -47

282 lines not on this page · raw message

drivers/nvdimm/nd-core.h +7 -6
index 3b48fba4629b..15bbdf6bea24 100644
@@ -62,8 +62,7 @@ static inline unsigned long nvdimm_security_flags(
 	flags = nvdimm->sec.ops->get_flags(nvdimm, ptype);
 	/* disabled, locked, unlocked, and overwrite are mutually exclusive */
 	dev_WARN_ONCE(&nvdimm->dev, hweight64(flags & state_flags) > 1,
-		      "reported invalid security state: %#llx\n",
-		      (unsigned long long)flags);
+		      "reported invalid security state: %#llx\n", (u64)flags);
 	return flags;
 }
 
@@ -150,7 +149,8 @@ resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
 					   struct nd_mapping *nd_mapping);
 resource_size_t nd_region_allocatable_dpa(struct nd_region *nd_region);
 resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
-				      struct nd_mapping *nd_mapping, resource_size_t *overlap);
+				      struct nd_mapping *nd_mapping,
+				      resource_size_t *overlap);
 resource_size_t nd_blk_available_dpa(struct nd_region *nd_region);
 resource_size_t nd_region_available_dpa(struct nd_region *nd_region);
 int nd_region_conflict(struct nd_region *nd_region, resource_size_t start,
@@ -159,7 +159,8 @@ resource_size_t nvdimm_allocated_dpa(struct nvdimm_drvdata *ndd,
 				     struct nd_label_id *label_id);
 int alias_dpa_busy(struct device *dev, void *data);
 struct resource *nsblk_add_resource(struct nd_region *nd_region,
-				    struct nvdimm_drvdata *ndd, struct nd_namespace_blk *nsblk,
+				    struct nvdimm_drvdata *ndd,
+				    struct nd_namespace_blk *nsblk,
 				    resource_size_t start);
 int nvdimm_num_label_slots(struct nvdimm_drvdata *ndd);
 void get_ndd(struct nvdimm_drvdata *ndd);
@@ -171,8 +172,8 @@ bool nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach,
 bool __nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach,
 		      struct nd_namespace_common **_ndns);
 ssize_t nd_namespace_store(struct device *dev,
-			   struct nd_namespace_common **_ndns, const char *buf,
-			   size_t len);
+			   struct nd_namespace_common **_ndns,
+			   const char *buf, size_t len);
 struct nd_pfn *to_nd_pfn_safe(struct device *dev);
 bool is_nvdimm_bus(struct device *dev);
 
drivers/nvdimm/nd.h +14 -12
index d434041ca2e5..852ce9591109 100644
@@ -90,8 +90,8 @@ unsigned int sizeof_namespace_label(struct nvdimm_drvdata *ndd);
 #define nd_dbg_dpa(r, d, res, fmt, arg...)				\
 	dev_dbg((r) ? &(r)->dev : (d)->dev, "%s: %.13s: %#llx @ %#llx " fmt, \
 		(r) ? dev_name((d)->dev) : "", res ? res->name : "null", \
-		(unsigned long long)(res ? resource_size(res) : 0),	\
-		(unsigned long long)(res ? res->start : 0), ##arg)
+		(u64)(res ? resource_size(res) : 0),	\
+		(u64)(res ? res->start : 0), ##arg)
 
 #define for_each_dpa_resource(ndd, res)				\
 	for (res = (ndd)->dpa.child; res; res = res->sibling)
@@ -228,7 +228,8 @@ int nd_uuid_store(struct device *dev, u8 **uuid_out, const char *buf,
 ssize_t nd_size_select_show(unsigned long current_size,
 			    const unsigned long *supported, char *buf);
 ssize_t nd_size_select_store(struct device *dev, const char *buf,
-			     unsigned long *current_size, const unsigned long *supported);
+			     unsigned long *current_size,
+			     const unsigned long *supported);
 int __init nvdimm_init(void);
 int __init nd_region_init(void);
 int __init nd_label_init(void);
@@ -363,7 +364,8 @@ void put_ndd(struct nvdimm_drvdata *ndd);
 int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd);
 void nvdimm_free_dpa(struct nvdimm_drvdata *ndd, struct resource *res);
 struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd,
-				     struct nd_label_id *label_id, resource_size_t start,
+				     struct nd_label_id *label_id,
+				     resource_size_t start,
 				     resource_size_t n);
 resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns);
 bool nvdimm_namespace_locked(struct nd_namespace_common *ndns);
@@ -374,7 +376,8 @@ const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
 				       char *name);
 unsigned int pmem_sector_size(struct nd_namespace_common *ndns);
 void nvdimm_badblocks_populate(struct nd_region *nd_region,
-			       struct badblocks *bb, const struct resource *res);
+			       struct badblocks *bb,
+			       const struct resource *res);
 #if IS_ENABLED(CONFIG_ND_CLAIM)
 int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap);
 int devm_nsio_enable(struct device *dev, struct nd_namespace_io *nsio);
@@ -423,15 +426,14 @@ static inline void nd_iostat_end(struct bio *bio, unsigned long start)
 static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector,
 			       unsigned int len)
 {
-	if (bb->count) {
-		sector_t first_bad;
-		int num_bad;
+	sector_t first_bad;
+	int num_bad;
 
-		return !!badblocks_check(bb, sector, len / 512, &first_bad,
-					 &num_bad);
-	}
+	if (!bb->count)
+		return false;
 
-	return false;
+
+	return badblocks_check(bb, sector, len / 512, &first_bad, &num_bad);
 }
 
 resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk);
drivers/nvdimm/nd_virtio.c +2 -1
index f09541bf3d5d..1a792fee8cfd 100644
@@ -24,7 +24,8 @@ void virtio_pmem_host_ack(struct virtqueue *vq)
 
 		if (!list_empty(&vpmem->req_list)) {
 			req_buf = list_first_entry(&vpmem->req_list,
-						   struct virtio_pmem_request, list);
+						   struct virtio_pmem_request,
+						   list);
 			req_buf->wq_buf_avail = true;
 			wake_up(&req_buf->wq_buf);
 			list_del(&req_buf->list);
drivers/nvdimm/pfn_devs.c +23 -20

108 lines not on this page · raw message

drivers/nvdimm/pmem.c +7 -7
index 64e7429edcc2..3f1add94144a 100644
@@ -85,8 +85,7 @@ static blk_status_t pmem_clear_poison(struct pmem_device *pmem,
 		hwpoison_clear(pmem, pmem->phys_addr + offset, cleared);
 		cleared /= 512;
 		dev_dbg(dev, "%#llx clear %ld sector%s\n",
-			(unsigned long long)sector, cleared,
-			cleared > 1 ? "s" : "");
+			(u64)sector, cleared, cleared > 1 ? "s" : "");
 		badblocks_clear(&pmem->bb, sector, cleared);
 		if (pmem->bb_state)
 			sysfs_notify_dirent(pmem->bb_state);
@@ -138,8 +137,8 @@ static blk_status_t read_pmem(struct page *page, unsigned int off,
 }
 
 static blk_status_t pmem_do_bvec(struct pmem_device *pmem, struct page *page,
-				 unsigned int len, unsigned int off, unsigned int op,
-				 sector_t sector)
+				 unsigned int len, unsigned int off,
+				 unsigned int op, sector_t sector)
 {
 	blk_status_t rc = BLK_STS_OK;
 	bool bad_pmem = false;
@@ -270,7 +269,8 @@ static const struct block_device_operations pmem_fops = {
 };
 
 static long pmem_dax_direct_access(struct dax_device *dax_dev,
-				   pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn)
+				   pgoff_t pgoff, long nr_pages,
+				   void **kaddr, pfn_t *pfn)
 {
 	struct pmem_device *pmem = dax_get_private(dax_dev);
 
@@ -455,8 +455,8 @@ static int pmem_attach_disk(struct device *dev,
 	disk->flags		= GENHD_FL_EXT_DEVT;
 	disk->queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO;
 	nvdimm_namespace_disk_name(ndns, disk->disk_name);
-	set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
-		     / 512);
+	set_capacity(disk,
+		     (pmem->size - pmem->pfn_pad - pmem->data_offset) / 512);
 	if (devm_init_badblocks(dev, &pmem->bb))
 		return -ENOMEM;
 	nvdimm_badblocks_populate(nd_region, &pmem->bb, &bb_res);
drivers/nvdimm/region_devs.c +20 -16
index 6861e0997d21..6ed918e30cf9 100644
@@ -2,6 +2,7 @@
 /*
  * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
  */
+
 #include <linux/scatterlist.h>
 #include <linux/highmem.h>
 #include <linux/sched.h>
@@ -44,16 +45,15 @@ static int nvdimm_map_flush(struct device *dev, struct nvdimm *nvdimm, int dimm,
 		}
 
 		if (j < i)
-			flush_page = (void __iomem *)((unsigned long)
-						       ndrd_get_flush_wpq(ndrd, dimm, j)
-						       & PAGE_MASK);
+			flush_page = (void __iomem *)
+				((unsigned long)ndrd_get_flush_wpq(ndrd, dimm, j) & PAGE_MASK);
 		else
-			flush_page = devm_nvdimm_ioremap(dev,
-							 PFN_PHYS(pfn), PAGE_SIZE);
+			flush_page = devm_nvdimm_ioremap(dev, PFN_PHYS(pfn),
+							 PAGE_SIZE);
 		if (!flush_page)
 			return -ENXIO;
-		ndrd_set_flush_wpq(ndrd, dimm, i, flush_page
-				   + (res->start & ~PAGE_MASK));
+		ndrd_set_flush_wpq(ndrd, dimm, i,
+				   flush_page + (res->start & ~PAGE_MASK));
 	}
 
 	return 0;
@@ -276,7 +276,8 @@ static ssize_t deep_flush_show(struct device *dev,
 	return sprintf(buf, "%d\n", nvdimm_has_flush(nd_region));
 }
 
-static ssize_t deep_flush_store(struct device *dev, struct device_attribute *attr,
+static ssize_t deep_flush_store(struct device *dev,
+				struct device_attribute *attr,
 				const char *buf, size_t len)
 {
 	bool flush;
@@ -435,7 +436,8 @@ static ssize_t available_size_show(struct device *dev,
 static DEVICE_ATTR_RO(available_size);
 
 static ssize_t max_available_extent_show(struct device *dev,
-					 struct device_attribute *attr, char *buf)
+					 struct device_attribute *attr,
+					 char *buf)
 {
 	struct nd_region *nd_region = to_nd_region(dev);
 	unsigned long long available = 0;
@@ -544,7 +546,8 @@ static ssize_t read_only_show(struct device *dev,
 }
 
 static ssize_t read_only_store(struct device *dev,
-			       struct device_attribute *attr, const char *buf, size_t len)
+			       struct device_attribute *attr,
+			       const char *buf, size_t len)
 {
 	bool ro;
 	int rc = strtobool(buf, &ro);
@@ -813,12 +816,13 @@ static ssize_t mappingN(struct device *dev, char *buf, int n)
 }
 
 #define REGION_MAPPING(idx)						\
-	static ssize_t mapping##idx##_show(struct device *dev,		\
-					   struct device_attribute *attr, char *buf) \
-	{								\
-		return mappingN(dev, buf, idx);				\
-	}								\
-	static DEVICE_ATTR_RO(mapping##idx)
+static ssize_t mapping##idx##_show(struct device *dev,			\
+				   struct device_attribute *attr,	\
+				   char *buf)				\
+{									\
+	return mappingN(dev, buf, idx);					\
+}									\
+static DEVICE_ATTR_RO(mapping##idx)
 
 /*
  * 32 should be enough for a while, even in the presence of socket
drivers/nvdimm/security.c +14 -14
index 693416001d17..cb14c05f127e 100644
@@ -118,7 +118,8 @@ static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm,
 }
 
 static const void *nvdimm_get_user_key_payload(struct nvdimm *nvdimm,
-					       key_serial_t id, int subclass, struct key **key)
+					       key_serial_t id, int subclass,
+					       struct key **key)
 {
 	*key = NULL;
 	if (id == 0) {
@@ -229,7 +230,7 @@ static int check_security_state(struct nvdimm *nvdimm)
 	}
 
 	if (test_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags)) {
-		dev_dbg(dev, "Security operation in progress.\n");
+		dev_dbg(dev, "Security operation in progress\n");
 		return -EBUSY;
 	}
 
@@ -262,8 +263,8 @@ static int security_disable(struct nvdimm *nvdimm, unsigned int keyid)
 		return -ENOKEY;
 
 	rc = nvdimm->sec.ops->disable(nvdimm, data);
-	dev_dbg(dev, "key: %d disable: %s\n", key_serial(key),
-		rc == 0 ? "success" : "fail");
+	dev_dbg(dev, "key: %d disable: %s\n",
+		key_serial(key), rc == 0 ? "success" : "fail");
 
 	nvdimm_put_key(key);
 	nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
@@ -316,8 +317,7 @@ static int security_update(struct nvdimm *nvdimm, unsigned int keyid,
 		nvdimm->sec.ext_flags = nvdimm_security_flags(nvdimm,
 							      NVDIMM_MASTER);
 	else
-		nvdimm->sec.flags = nvdimm_security_flags(nvdimm,
-							  NVDIMM_USER);
+		nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
 	return rc;
 }
 
@@ -344,8 +344,7 @@ static int security_erase(struct nvdimm *nvdimm, unsigned int keyid,
 
 	if (!test_bit(NVDIMM_SECURITY_UNLOCKED, &nvdimm->sec.ext_flags) &&
 	    pass_type == NVDIMM_MASTER) {
-		dev_dbg(dev,
-			"Attempt to secure erase in wrong master state.\n");
+		dev_dbg(dev, "Attempt to secure erase in wrong master state\n");
 		return -EOPNOTSUPP;
 	}
 
@@ -355,7 +354,8 @@ static int security_erase(struct nvdimm *nvdimm, unsigned int keyid,
 		return -ENOKEY;
 
 	rc = nvdimm->sec.ops->erase(nvdimm, data, pass_type);
-	dev_dbg(dev, "key: %d erase%s: %s\n", key_serial(key),
+	dev_dbg(dev, "key: %d erase%s: %s\n",
+		key_serial(key),
 		pass_type == NVDIMM_MASTER ? "(master)" : "(user)",
 		rc == 0 ? "success" : "fail");
 
@@ -381,7 +381,7 @@ static int security_overwrite(struct nvdimm *nvdimm, unsigned int keyid)
 		return -EOPNOTSUPP;
 
 	if (dev->driver == NULL) {
-		dev_dbg(dev, "Unable to overwrite while DIMM active.\n");
+		dev_dbg(dev, "Unable to overwrite while DIMM active\n");
 		return -EINVAL;
 	}
 
@@ -395,8 +395,8 @@ static int security_overwrite(struct nvdimm *nvdimm, unsigned int keyid)
 		return -ENOKEY;
 
 	rc = nvdimm->sec.ops->overwrite(nvdimm, data);
-	dev_dbg(dev, "key: %d overwrite submission: %s\n", key_serial(key),
-		rc == 0 ? "success" : "fail");
+	dev_dbg(dev, "key: %d overwrite submission: %s\n",
+		key_serial(key), rc == 0 ? "success" : "fail");
 
 	nvdimm_put_key(key);
 	if (rc == 0) {
@@ -533,7 +533,7 @@ ssize_t nvdimm_security_store(struct device *dev, const char *buf, size_t len)
 	} else if (i == OP_ERASE || i == OP_MASTER_ERASE) {
 		dev_dbg(dev, "%s %u\n", ops[i].name, key);
 		if (atomic_read(&nvdimm->busy)) {
-			dev_dbg(dev, "Unable to secure erase while DIMM active.\n");
+			dev_dbg(dev, "Unable to secure erase while DIMM active\n");
 			return -EBUSY;
 		}
 		rc = security_erase(nvdimm, key, i == OP_ERASE
@@ -541,7 +541,7 @@ ssize_t nvdimm_security_store(struct device *dev, const char *buf, size_t len)
 	} else if (i == OP_OVERWRITE) {
 		dev_dbg(dev, "overwrite %u\n", key);
 		if (atomic_read(&nvdimm->busy)) {
-			dev_dbg(dev, "Unable to overwrite while DIMM active.\n");
+			dev_dbg(dev, "Unable to overwrite while DIMM active\n");
 			return -EBUSY;
 		}
 		rc = security_overwrite(nvdimm, key);
drivers/nvdimm/virtio_pmem.c +3 -1
index ce2181e06756..087753ac81a0 100644
@@ -19,7 +19,8 @@ static int init_vq(struct virtio_pmem *vpmem)
 {
 	/* single vq */
 	vpmem->req_vq = virtio_find_single_vq(vpmem->vdev,
-					      virtio_pmem_host_ack, "flush_queue");
+					      virtio_pmem_host_ack,
+					      "flush_queue");
 	if (IS_ERR(vpmem->req_vq))
 		return PTR_ERR(vpmem->req_vq);
 
@@ -91,6 +92,7 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
 	}
 	nd_region->provider_data = dev_to_virtio(nd_region->dev.parent->parent);
 	return 0;
+
 out_nd:
 	nvdimm_bus_unregister(vpmem->nvdimm_bus);
 out_vq:
Signature · 6 lines
2.15.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#19 lore raw
Quoted 7 lines · Dan Williams

Hi Joe,

Quoted 1 line · Joe Perches

Rather than have a local coding style, use the typical kernel style.

I'd rather automate this. I'm going to do once-over with clang-format and see what falls out.

I am adding Miguel Ojeda to the cc's.

Of course you are welcome to try it, but I believe that clang-format doesn't work all that well yet.

It's more a work in progress rather than a "standard".

I believe you'll find that the patch series I sent ends up with a rather more typical kernel style.

I suggest you try to apply the series I sent and then run clang-format on that and see the differences.

Ideally one day, something tool like clang-format might be locally applied by every developer for their own personal style with some other neutral style the content actually distributed.

cheers, Joe

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#20 lore raw
Quoted 2 lines · Joe Perches

I am adding Miguel Ojeda to the cc's.

Thanks Joe!

Quoted 10 lines

Of course you are welcome to try it, but I believe that clang-format doesn't work all that well yet.

It's more a work in progress rather than a "standard".

I believe you'll find that the patch series I sent ends up with a rather more typical kernel style.

I suggest you try to apply the series I sent and then run clang-format on that and see the differences.

Indeed, it is not there just yet. There are a few differences w.r.t. the kernel style that aren't supported yet. However, for block/batch conversions, it is very useful.

Luckily, one of the biggest ones (the consecutive macros alignment, and we have a lot of them given this is C and a kernel) is going away with LLVM 9 which is about to be released next week.

Quoted 4 lines

Ideally one day, something tool like clang-format might be locally applied by every developer for their own personal style with some other neutral style the content actually distributed.

If that day comes, I hope we can all agree to a single format and apply it everywhere as other major projects have done. I think agreeing to a given style is much, much easier for any of us when formatting is fully automatic -- because at that point you don't need to spend mental cycles (and memory!) on it. :-)

If I had to guess, I would say the path forward will start with some subsystem maintainers starting to apply clang-format systematically on their trees. That is why I think it is very useful that Dan tries it out and let us know his impressions.

Cheers,
Miguel

#21 lore raw
In reply to Joe Perches
Quoted 1 line · Joe Perches

Rather than have a local coding style, use the typical kernel style.

The coding style isn't that different from the core kernel, and it's still quite readable. I'd rather avoid the churn and the risk of introducing regressions. This will also make backports to stable more of a pain, so it isn't without cost. Dan, is this really something you want to do?

-Jeff

Quoted 35 lines

Joe Perches (13):
nvdimm: Use more typical whitespace
nvdimm: Move logical continuations to previous line
nvdimm: Use octal permissions
nvdimm: Use a more common kernel spacing style
nvdimm: Use "unsigned int" in preference to "unsigned"
nvdimm: Add and remove blank lines
nvdimm: Use typical kernel brace styles
nvdimm: Use typical kernel style indentation
nvdimm: btt.h: Neaten #defines to improve readability
nvdimm: namespace_devs: Move assignment operators
nvdimm: Use more common logic testing styles and bare ; positions
nvdimm: namespace_devs: Change progess typo to progress
nvdimm: Miscellaneous neatening

 drivers/nvdimm/badrange.c       |  22 +-
 drivers/nvdimm/blk.c            |  39 ++--
 drivers/nvdimm/btt.c            | 249 +++++++++++----------
 drivers/nvdimm/btt.h            |  56 ++---
 drivers/nvdimm/btt_devs.c       |  68 +++---
 drivers/nvdimm/bus.c            | 138 ++++++------
 drivers/nvdimm/claim.c          |  50 ++---
 drivers/nvdimm/core.c           |  42 ++--
 drivers/nvdimm/dax_devs.c       |   3 +-
 drivers/nvdimm/dimm.c           |   3 +-
 drivers/nvdimm/dimm_devs.c      | 107 ++++-----
 drivers/nvdimm/e820.c           |   2 +-
 drivers/nvdimm/label.c          | 213 +++++++++---------
 drivers/nvdimm/label.h          |   6 +-
 drivers/nvdimm/namespace_devs.c | 472 +++++++++++++++++++++-------------------
 drivers/nvdimm/nd-core.h        |  31 +--
 drivers/nvdimm/nd.h             |  94 ++++----
 drivers/nvdimm/nd_virtio.c      |  20 +-
 drivers/nvdimm/of_pmem.c        |   6 +-
Quoted 8 lines
 drivers/nvdimm/pfn_devs.c       | 136 ++++++------
 drivers/nvdimm/pmem.c           |  57 ++---
 drivers/nvdimm/pmem.h           |   2 +-
 drivers/nvdimm/region.c         |  20 +-
 drivers/nvdimm/region_devs.c    | 160 +++++++-------
 drivers/nvdimm/security.c       | 138 ++++++------
 drivers/nvdimm/virtio_pmem.c    |  10 +-
 26 files changed, 1115 insertions(+), 1029 deletions(-)

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#22 lore raw
Quoted 4 lines · Jeff Moyer

I'd rather avoid the churn and the risk of
introducing regressions. This will also make backports to stable more of a pain, so it isn't without cost. Dan, is this really something you want to do?

I'm a 100% with Jeff on this!

Signature · 8 lines
Johannes Thumshirn                            SUSE Labs Filesystems
[email protected]                                +49 911 74053 689
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 Nürnberg
Germany
(HRB 247165, AG München)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#24 lore raw
In reply to Jeff Moyer
Quoted 10 lines · Jeff Moyer
Quoted 1 line · Joe Perches

Rather than have a local coding style, use the typical kernel style.

The coding style isn't that different from the core kernel, and it's still quite readable. I'd rather avoid the churn and the risk of introducing regressions. This will also make backports to stable more of a pain, so it isn't without cost. Dan, is this really something you want to do?

+1 As soon as you get accustomed to have formatting done and enforced automatically, it is great. Other major projects have done so for quite a while now.

If doesn't think it is good enough, please let us know and, if it is close enough, we can look at going for a newer LLVM to match the style a bit more. Also note that one can disable formatting for some sections of code if really needed.

Cheers,
Miguel
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#25 lore raw
Quoted 3 lines · Miguel Ojeda

As soon as you get accustomed to have formatting done and enforced automatically, it is great. Other major projects have done so for quite a while now.

Please name the major projects and then point to their .clang-format equivalents.

Also note the size/scope/complexity of the major projects.

thanks.

Quoted 3 lines

If doesn't think it is good enough, please let us know and, if it is close enough, we can look at going for a newer LLVM to match the style a bit more.

I used the latest one, and quite a bit of the conversion was unpleasant to read.

Quoted 2 lines

Also note that one can disable formatting for some
sections of code if really needed.

Marking sections _no_auto_format_ isn't really a
good solution is it?
.

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#26 lore raw
Quoted 5 lines · Joe Perches

Please name the major projects and then point to their .clang-format equivalents.

Also note the size/scope/complexity of the major projects.

Mozilla, WebKit, LLVM and Microsoft. They have their style distributed with the official clang-format, not sure if they enforce it.

Same for Chromium/Chrome, but it looks like they indeed enforce it:

"A checkout should give you clang-format to automatically format C++
code. By policy, Clang's formatting of code should always be accepted in code reviews."

I would bet other Google projects do so as well (since Chandler Carruth has been giving talks about clang-format for 7+ years). Nick?

I hope those are major enough. There is also precedent in other languages (e.g. Java, C#, Rust).

Quoted 2 lines

I used the latest one, and quite a bit of the conversion was unpleasant to read.

It would be good to see particularly bad snippets to see if we can do something about them (and, if needed, try to improve clang-format to support whatever we need).

Did you tweak the parameters with the new ones? I am preparing an RFC patch for an updated .clang-format configuration that improves quite a bit the results w.r.t. to the current one (and allows for some leeway on the developer's side, which helps prevent some cases too).

Quoted 2 lines

Marking sections _no_auto_format_ isn't really a
good solution is it?

I am thinking about special tables that are hand-crafted or very complex macros. For those, yes, I think it is a fine solution. That is why clang-format has that feature to begin with, and you can see an example in Mozilla's style guide which points here:

https://github.com/mozilla/gecko-dev/blob/master/xpcom/io/nsEscape.cpp#L22

Cheers,
Miguel
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#27 lore raw
Quoted 10 lines · Miguel Ojeda
Quoted 4 lines · Joe Perches

Please name the major projects and then point to their .clang-format equivalents.

Also note the size/scope/complexity of the major projects.

Mozilla, WebKit, LLVM and Microsoft. They have their style distributed with the official clang-format, not sure if they enforce it.

Same for Chromium/Chrome, but it looks like they indeed enforce it:

thanks for that list.

Quoted 6 lines
Quoted 2 lines

I used the latest one, and quite a bit of the conversion was unpleasant to read.

It would be good to see particularly bad snippets to see if we can do something about them (and, if needed, try to improve clang-format to support whatever we need).

As I mentioned earlier, look at the __stringify conversion. Also the C() blocks.

btw: emacs 'mark-whole-buffer indent-region',
the tool I used for each file in patch 1, also
made a mess of the C() block.

Quoted 1 line

Did you tweak the parameters with the new ones?

No. I used

$ clang-format --version
clang-format version 10.0.0 (git://github.com/llvm/llvm-project.git 305b961f64b75e73110e309341535f6d5a48ed72)

and the existing .clang_format from next-20190904 35394d031b710e832849fca60d0f53b513f0c390

Quoted 4 lines

I am preparing an RFC
patch for an updated .clang-format configuration that improves quite a bit the results w.r.t. to the current one (and allows for some leeway on the developer's side, which helps prevent some cases too).

Well, one day no doubt an automated tool will be
more useful for the kernel. Hope you keep at it
and good luck.

Quoted 8 lines
Quoted 2 lines

Marking sections _no_auto_format_ isn't really a
good solution is it?

I am thinking about special tables that are hand-crafted or very complex macros. For those, yes, I think it is a fine solution. That is why clang-format has that feature to begin with, and you can see an example in Mozilla's style guide which points here:

Quoted 4 lines

https://github.com/mozilla/gecko-dev/blob/master/xpcom/io/nsEscape.cpp#L22

Cheers,
Miguel

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#28 lore raw
In reply to Miguel Ojeda
Quoted 8 lines · Miguel Ojeda
Quoted 4 lines · Joe Perches

Please name the major projects and then point to their .clang-format equivalents.

Also note the size/scope/complexity of the major projects.

Mozilla, WebKit, LLVM and Microsoft. They have their style distributed with the official clang-format, not sure if they enforce it.

At least for LLVM, it appears not.

I just tried a very small portion of the clang compiler:

$ git ls-files llvm/lib/CodeGen/ | wc -l
293
$ git ls-files llvm/lib/CodeGen/ | xargs clang-format -i

and got:

$ git diff --shortstat
 245 files changed, 19519 insertions(+), 17794 deletions(-)

btw: that seems a pretty small ~7% of the overall lines

$ git ls-files llvm/lib/CodeGen/ | xargs wc -l | tail -1
 251034 total
#29 lore raw
Quoted 6 lines · Joe Perches
Quoted 4 lines · Miguel Ojeda
Quoted 3 lines · Joe Perches

Please name the major projects and then point to their .clang-format equivalents.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Also note the size/scope/complexity of the major projects.

Mozilla, WebKit, LLVM and Microsoft. They have their style distributed with the official clang-format, not sure if they enforce it.

At least for LLVM, it appears not.

I acknowledge the irony you present, but that's because there's no enforcement on the LLVM side. I frequently forget to run:

$ git-clang-format HEAD~

If you have automated systems that help encourage (ie. force) the use of the formatter, this helps.

Consider the fact that not all kernel developers run checkpatch.pl. Is that a deficiency in checkpatch.pl, or the lack of enforcement in kernel developers' workflows?

Signature · 6 lines
Thanks,
~Nick Desaulniers
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#30 lore raw
Quoted 3 lines · Nick Desaulniers

Consider the fact that not all kernel developers run checkpatch.pl. Is that a deficiency in checkpatch.pl, or the lack of enforcement in kernel developers' workflows?

No. Mostly it's because the kernel is like a bunch of little untethered development planets, each with a little prince that wants to keep their own little fiefdom separate from the others.

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#31 lore raw
In reply to Miguel Ojeda
Quoted 11 lines · Miguel Ojeda
Quoted 5 lines · Joe Perches

Please name the major projects and then point to their .clang-format equivalents.

Also note the size/scope/complexity of the major projects.

Mozilla, WebKit, LLVM and Microsoft. They have their style distributed with the official clang-format, not sure if they enforce it.

Quoted 8 lines

Same for Chromium/Chrome, but it looks like they indeed enforce it:

"A checkout should give you clang-format to automatically format C++
code. By policy, Clang's formatting of code should always be accepted in code reviews."

I would bet other Google projects do so as well (since Chandler Carruth has been giving talks about clang-format for 7+ years). Nick?

So Google3 (the internal monorepo that Android, Chromium, ChromiumOS, Fuchsia are not a part of) is pretty sweet. You cannot even post code unless the linter has been run on it (presubmit hook), which for our ~350 millions LoC of C++ is clang-format. If you bypass local presubmit hooks, our code review tool ("critique") won't let you submit code that fails lint presubmit checks. I suspect the initial conversion was probably committed by bots.

Quoted 3 lines

I hope those are major enough. There is also precedent in other languages (e.g. Java, C#, Rust).

Yep! Other people coming to C/C++ from these languages find the discussion about tabs vs spaces to be highly entertaining! When you have an automated code formatter and an agreed upon coding style (and hopefully enforcement), you save so much time from avoided bikesheds! Don't like the codebase's coding style? Then write the code how you like and just run the formatter when you're done (might not help with conventions though, maybe that's where checkpatch.pl can shine). Done! No more wasted time on what color to paint the bikeshed!

Signature · 6 lines
Thanks,
~Nick Desaulniers
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#32 lore raw

clang-format and 'clang-format on' and 'clang-format off'

In reply to Miguel Ojeda
Quoted 7 lines · Miguel Ojeda
Quoted 2 lines · Joe Perches

Marking sections _no_auto_format_ isn't really a
good solution is it?

I am thinking about special tables that are hand-crafted or very complex macros. For those, yes, I think it is a fine solution.

Can the 'clang-format on/off' trigger be indirected into something non-clang specific via a macro?

Not every project is going to use only the clang-format tool.

#33 lore raw

Re: clang-format and 'clang-format on' and 'clang-format off'

Quoted 2 lines · Joe Perches

Not every project is going to use only the clang-format tool.

Why? The end goal would be to enforce all code to be running under the same formatting rules (which, in practice, means the same tool at the moment).

Note that you can use clang-format with most editors (including vim, emacs, VS, VSCode, XCode, Sublime, Atom...).

Cheers,
Miguel
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm