diff mbox

[U-Boot,v2,07/32] dm: blk: Convert interface type to an enum

Message ID 1456784765-10788-8-git-send-email-sjg@chromium.org
State Accepted
Commit 5ec4f1a5f35dc71881f88c84176c568308133640
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Feb. 29, 2016, 10:25 p.m. UTC
Since these are sequentially numbered it makes sense to use an enum. It
avoids having to maintain the maximum value, and provides a type we can use
if it is useful.

In fact the maximum value is not used. Rename it to COUNT, since MAX suggests
it is the maximum valid value, but it is not.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add a missing word 'is' to the commit message
- Rename the enum to 'if_type' instead of 'if_type_t'

 include/blk.h | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

Comments

Simon Glass March 13, 2016, 1:52 a.m. UTC | #1
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> Since these are sequentially numbered it makes sense to use an enum. It
> avoids having to maintain the maximum value, and provides a type we can use
> if it is useful.
>
> In fact the maximum value is not used. Rename it to COUNT, since MAX suggests
> it is the maximum valid value, but it is not.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Add a missing word 'is' to the commit message
> - Rename the enum to 'if_type' instead of 'if_type_t'
>
>  include/blk.h | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)

Applied to u-boot-dm/next.
diff mbox

Patch

diff --git a/include/blk.h b/include/blk.h
index 1e8334c..fd54520 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -19,20 +19,23 @@  typedef ulong lbaint_t;
 #define LBAFU "%" LBAFlength "u"
 
 /* Interface types: */
-#define IF_TYPE_UNKNOWN		0
-#define IF_TYPE_IDE		1
-#define IF_TYPE_SCSI		2
-#define IF_TYPE_ATAPI		3
-#define IF_TYPE_USB		4
-#define IF_TYPE_DOC		5
-#define IF_TYPE_MMC		6
-#define IF_TYPE_SD		7
-#define IF_TYPE_SATA		8
-#define IF_TYPE_HOST		9
-#define IF_TYPE_MAX		10	/* Max number of IF_TYPE_* supported */
+enum if_type {
+	IF_TYPE_UNKNOWN = 0,
+	IF_TYPE_IDE,
+	IF_TYPE_SCSI,
+	IF_TYPE_ATAPI,
+	IF_TYPE_USB,
+	IF_TYPE_DOC,
+	IF_TYPE_MMC,
+	IF_TYPE_SD,
+	IF_TYPE_SATA,
+	IF_TYPE_HOST,
+
+	IF_TYPE_COUNT,			/* Number of interface types */
+};
 
 struct blk_desc {
-	int		if_type;	/* type of the interface */
+	enum if_type	if_type;	/* type of the interface */
 	int		dev;		/* device number */
 	unsigned char	part_type;	/* partition type */
 	unsigned char	target;		/* target SCSI ID */