diff mbox series

[9/9] block: make the init_part_stats return value more logical

Message ID 20200325154843.1349040-10-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/9] block: mark block_depr static | expand

Commit Message

Christoph Hellwig March 25, 2020, 3:48 p.m. UTC
Return 0 / -ENOMEM instead of a boolean dressed up as int.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/genhd.c             | 2 +-
 block/partitions/core.c   | 2 +-
 include/linux/part_stat.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 6323cc789efa..95aef19ca8ed 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1644,7 +1644,7 @@  struct gendisk *__alloc_disk_node(int minors, int node_id)
 
 	disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
 	if (disk) {
-		if (!init_part_stats(&disk->part0)) {
+		if (init_part_stats(&disk->part0)) {
 			kfree(disk);
 			return NULL;
 		}
diff --git a/block/partitions/core.c b/block/partitions/core.c
index b79c4513629b..6509351cb9d3 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -377,7 +377,7 @@  struct hd_struct *add_partition(struct gendisk *disk, int partno,
 	if (!p)
 		return ERR_PTR(-EBUSY);
 
-	if (!init_part_stats(p)) {
+	if (init_part_stats(p)) {
 		err = -ENOMEM;
 		goto out_free;
 	}
diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h
index ece607607a86..521ad787b0ec 100644
--- a/include/linux/part_stat.h
+++ b/include/linux/part_stat.h
@@ -48,8 +48,8 @@  static inline int init_part_stats(struct hd_struct *part)
 {
 	part->dkstats = alloc_percpu(struct disk_stats);
 	if (!part->dkstats)
-		return 0;
-	return 1;
+		return -ENOMEM;
+	return 0;
 }
 
 static inline void free_part_stats(struct hd_struct *part)
@@ -72,7 +72,7 @@  static inline void part_stat_set_all(struct hd_struct *part, int value)
 
 static inline int init_part_stats(struct hd_struct *part)
 {
-	return 1;
+	return 0;
 }
 
 static inline void free_part_stats(struct hd_struct *part)