Re: [PATCH 13/38] Implement scsi_opcode_sa_name

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

 



On 09/29/2014 09:29 PM, Douglas Gilbert wrote:
On 14-09-29 07:58 AM, Hannes Reinecke wrote:
Implement a lookup array for SERVICE ACTION commands instead
of hardcoding it in a large switch statement.

Reviewed-by: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
---
  drivers/scsi/constants.c | 132
+++++++++++++++++++----------------------------
  1 file changed, 54 insertions(+), 78 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 6e16b19..b9eb6a1 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -244,102 +244,77 @@ static const struct value_name_pair
variable_length_arr[] = {
  };
  #define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)

-static const char * get_sa_name(const struct value_name_pair * arr,
-                    int arr_sz, int service_action)
+struct sa_name_list {
+    int cmd;
+    const struct value_name_pair *arr;
+    int arr_sz;
+};
+
+static struct sa_name_list sa_names_arr[] = {
+    {VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
+    {MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
+    {MAINTENANCE_OUT, maint_out_arr, MAINT_OUT_SZ},
+    {PERSISTENT_RESERVE_IN, pr_in_arr, PR_IN_SZ},
+    {PERSISTENT_RESERVE_OUT, pr_out_arr, PR_OUT_SZ},
+    {SERVICE_ACTION_IN_12, serv_in12_arr, SERV_IN12_SZ},
+    {SERVICE_ACTION_OUT_12, serv_out12_arr, SERV_OUT12_SZ},
+    {SERVICE_ACTION_BIDIRECTIONAL, serv_bidi_arr, SERV_BIDI_SZ},
+    {SERVICE_ACTION_IN_16, serv_in16_arr, SERV_IN16_SZ},
+    {SERVICE_ACTION_OUT_16, serv_out16_arr, SERV_OUT16_SZ},
+    {THIRD_PARTY_COPY_IN, tpc_in_arr, TPC_IN_SZ},
+    {THIRD_PARTY_COPY_OUT, tpc_out_arr, TPC_OUT_SZ},
+    {0, NULL, 0},
+};
+#define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)

Since you placed a terminating element on sa_names_arr[] then
you don't need the SA_NAME_LIST_SZ define any more.

The for loop can become:
   for (sa_name_ptr = sa_names_arr; sa_name_ptr->arr; ++sa_name_ptr) {
...

Good point. Will be including this for the next round.

Cheers,

Hannes
--
Dr. Hannes Reinecke		      zSeries & Storage
hare@xxxxxxx			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux