diff mbox series

[1/2] qla2xxx: Use named initializers for port_[d]state_str

Message ID AS8PR10MB495215841EB25C16DBC0CB409D349@AS8PR10MB4952.EURPRD10.PROD.OUTLOOK.COM
State New
Headers show
Series [1/2] qla2xxx: Use named initializers for port_[d]state_str | expand

Commit Message

Chesnokov Gleb Feb. 15, 2022, 5:13 p.m. UTC
Make port_state_str and port_dstate_str a little more readable and
maintainable by using named initializers.

Also convert FCS_* macros into an enum.

Signed-off-by: Gleb Chesnokov <Chesnokov.G@raidix.com>
---
 drivers/scsi/qla2xxx/qla_def.h | 35 ++++++++++++++++++----------------
 drivers/scsi/qla2xxx/qla_isr.c | 10 +++++-----
 2 files changed, 24 insertions(+), 21 deletions(-)

Comments

Himanshu Madhani Feb. 16, 2022, 2:16 a.m. UTC | #1
> On Feb 15, 2022, at 9:13 AM, Chesnokov Gleb <Chesnokov.G@raidix.com> wrote:
> 
> Make port_state_str and port_dstate_str a little more readable and
> maintainable by using named initializers.
> 
> Also convert FCS_* macros into an enum.
> 
> Signed-off-by: Gleb Chesnokov <Chesnokov.G@raidix.com>
> ---
> drivers/scsi/qla2xxx/qla_def.h | 35 ++++++++++++++++++----------------
> drivers/scsi/qla2xxx/qla_isr.c | 10 +++++-----
> 2 files changed, 24 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
> index 9ebf4a234d9a..b0c40f6ab25d 100644
> --- a/drivers/scsi/qla2xxx/qla_def.h
> +++ b/drivers/scsi/qla2xxx/qla_def.h
> @@ -2666,25 +2666,28 @@ struct event_arg {
> /*
>  * Fibre channel port/lun states.
>  */
> -#define FCS_UNCONFIGURED	1
> -#define FCS_DEVICE_DEAD		2
> -#define FCS_DEVICE_LOST		3
> -#define FCS_ONLINE		4
> +enum {
> +	FCS_UNKNOWN,
> +	FCS_UNCONFIGURED,
> +	FCS_DEVICE_DEAD,
> +	FCS_DEVICE_LOST,
> +	FCS_ONLINE,
> +};
> 
> extern const char *const port_state_str[5];
> 
> -static const char * const port_dstate_str[] = {
> -	"DELETED",
> -	"GNN_ID",
> -	"GNL",
> -	"LOGIN_PEND",
> -	"LOGIN_FAILED",
> -	"GPDB",
> -	"UPD_FCPORT",
> -	"LOGIN_COMPLETE",
> -	"ADISC",
> -	"DELETE_PEND",
> -	"LOGIN_AUTH_PEND",
> +static const char *const port_dstate_str[] = {
> +	[DSC_DELETED]		= "DELETED",
> +	[DSC_GNN_ID]		= "GNN_ID",
> +	[DSC_GNL]		= "GNL",
> +	[DSC_LOGIN_PEND]	= "LOGIN_PEND",
> +	[DSC_LOGIN_FAILED]	= "LOGIN_FAILED",
> +	[DSC_GPDB]		= "GPDB",
> +	[DSC_UPD_FCPORT]	= "UPD_FCPORT",
> +	[DSC_LOGIN_COMPLETE]	= "LOGIN_COMPLETE",
> +	[DSC_ADISC]		= "ADISC",
> +	[DSC_DELETE_PEND]	= "DELETE_PEND",
> +	[DSC_LOGIN_AUTH_PEND]	= "LOGIN_AUTH_PEND",
> };
> 
> /*
> diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
> index aaf6504570fd..092e4b5da65a 100644
> --- a/drivers/scsi/qla2xxx/qla_isr.c
> +++ b/drivers/scsi/qla2xxx/qla_isr.c
> @@ -49,11 +49,11 @@ qla27xx_process_purex_fpin(struct scsi_qla_host *vha, struct purex_item *item)
> }
> 
> const char *const port_state_str[] = {
> -	"Unknown",
> -	"UNCONFIGURED",
> -	"DEAD",
> -	"LOST",
> -	"ONLINE"
> +	[FCS_UNKNOWN]		= "Unknown",
> +	[FCS_UNCONFIGURED]	= "UNCONFIGURED",
> +	[FCS_DEVICE_DEAD]	= "DEAD",
> +	[FCS_DEVICE_LOST]	= "LOST",
> +	[FCS_ONLINE]		= "ONLINE"
> };
> 
> static void
> -- 
> 2.35.1

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

--
Himanshu Madhani	 Oracle Linux Engineering
Martin K. Petersen Feb. 19, 2022, 10:15 p.m. UTC | #2
> Make port_state_str and port_dstate_str a little more readable and
> maintainable by using named initializers.

Applied to 5.18/scsi-staging, thanks!
Martin K. Petersen Feb. 28, 2022, 3:43 a.m. UTC | #3
On Tue, 15 Feb 2022 17:13:53 +0000, Chesnokov Gleb wrote:

> Make port_state_str and port_dstate_str a little more readable and
> maintainable by using named initializers.
> 
> Also convert FCS_* macros into an enum.
> 
> 

Applied to 5.18/scsi-queue, thanks!

[1/2] qla2xxx: Use named initializers for port_[d]state_str
      https://git.kernel.org/mkp/scsi/c/6e0e85d39e52
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 9ebf4a234d9a..b0c40f6ab25d 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2666,25 +2666,28 @@  struct event_arg {
 /*
  * Fibre channel port/lun states.
  */
-#define FCS_UNCONFIGURED	1
-#define FCS_DEVICE_DEAD		2
-#define FCS_DEVICE_LOST		3
-#define FCS_ONLINE		4
+enum {
+	FCS_UNKNOWN,
+	FCS_UNCONFIGURED,
+	FCS_DEVICE_DEAD,
+	FCS_DEVICE_LOST,
+	FCS_ONLINE,
+};
 
 extern const char *const port_state_str[5];
 
-static const char * const port_dstate_str[] = {
-	"DELETED",
-	"GNN_ID",
-	"GNL",
-	"LOGIN_PEND",
-	"LOGIN_FAILED",
-	"GPDB",
-	"UPD_FCPORT",
-	"LOGIN_COMPLETE",
-	"ADISC",
-	"DELETE_PEND",
-	"LOGIN_AUTH_PEND",
+static const char *const port_dstate_str[] = {
+	[DSC_DELETED]		= "DELETED",
+	[DSC_GNN_ID]		= "GNN_ID",
+	[DSC_GNL]		= "GNL",
+	[DSC_LOGIN_PEND]	= "LOGIN_PEND",
+	[DSC_LOGIN_FAILED]	= "LOGIN_FAILED",
+	[DSC_GPDB]		= "GPDB",
+	[DSC_UPD_FCPORT]	= "UPD_FCPORT",
+	[DSC_LOGIN_COMPLETE]	= "LOGIN_COMPLETE",
+	[DSC_ADISC]		= "ADISC",
+	[DSC_DELETE_PEND]	= "DELETE_PEND",
+	[DSC_LOGIN_AUTH_PEND]	= "LOGIN_AUTH_PEND",
 };
 
 /*
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index aaf6504570fd..092e4b5da65a 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -49,11 +49,11 @@  qla27xx_process_purex_fpin(struct scsi_qla_host *vha, struct purex_item *item)
 }
 
 const char *const port_state_str[] = {
-	"Unknown",
-	"UNCONFIGURED",
-	"DEAD",
-	"LOST",
-	"ONLINE"
+	[FCS_UNKNOWN]		= "Unknown",
+	[FCS_UNCONFIGURED]	= "UNCONFIGURED",
+	[FCS_DEVICE_DEAD]	= "DEAD",
+	[FCS_DEVICE_LOST]	= "LOST",
+	[FCS_ONLINE]		= "ONLINE"
 };
 
 static void