[PATCH v2 14/19] block: add cdev_is_block_(device|partition|disk) helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We look too much into struct cdev's guts. Let's add helpers to make
operating on block device cdevs more concise.

Reviewed-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx>
Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
v1 -> v2:
  - Adjust commit message title (Ulrich)
  - Add Marco's Reviewed-by
---
 include/block.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/block.h b/include/block.h
index 4dd2aa1f80ef..da258f509b41 100644
--- a/include/block.h
+++ b/include/block.h
@@ -58,4 +58,19 @@ static inline struct block_device *cdev_get_block_device(const struct cdev *cdev
 }
 #endif
 
+static inline bool cdev_is_block_device(const struct cdev *cdev)
+{
+	return cdev_get_block_device(cdev) != NULL;
+}
+
+static inline bool cdev_is_block_partition(const struct cdev *cdev)
+{
+	return cdev_is_block_device(cdev) && cdev_is_partition(cdev);
+}
+
+static inline bool cdev_is_block_disk(const struct cdev *cdev)
+{
+	return cdev_is_block_device(cdev) && !cdev_is_partition(cdev);
+}
+
 #endif /* __BLOCK_H */
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux