From patchwork Fri Aug 14 20:50:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KY Srinivasan X-Patchwork-Id: 7019291 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0BF329F39D for ; Fri, 14 Aug 2015 19:24:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D22E92078F for ; Fri, 14 Aug 2015 19:24:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC1D820788 for ; Fri, 14 Aug 2015 19:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751328AbbHNTYX (ORCPT ); Fri, 14 Aug 2015 15:24:23 -0400 Received: from p3plsmtps2ded03.prod.phx3.secureserver.net ([208.109.80.60]:43451 "EHLO p3plsmtps2ded03.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750913AbbHNTYX (ORCPT ); Fri, 14 Aug 2015 15:24:23 -0400 Received: from linuxonhyperv.com ([72.167.245.219]) by p3plsmtps2ded03.prod.phx3.secureserver.net with : DED : id 4jQM1r00f4kklxU01jQMY0; Fri, 14 Aug 2015 12:24:22 -0700 x-originating-ip: 72.167.245.219 Received: by linuxonhyperv.com (Postfix, from userid 507) id B69EC19024D; Fri, 14 Aug 2015 13:50:14 -0700 (PDT) From: "K. Y. Srinivasan" To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, ohering@suse.com, jbottomley@parallels.com, hch@infradead.org, linux-scsi@vger.kernel.org, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, jthumshirn@suse.de Cc: "K. Y. Srinivasan" Subject: [PATCH 1/1] scsi: storvsc: Use ARRAY_SIZE() to compute the elements in the protocol array Date: Fri, 14 Aug 2015 13:50:13 -0700 Message-Id: <1439585413-3279-1-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rather than hard coding the number of elements in the array, use the ARRAY_SIZE() macro to compute the number of elements in the array. This would minimize the changes needed when we have to extend the protocols supported. This was suggested by Johannes Thumshirn . Signed-off-by: K. Y. Srinivasan --- drivers/scsi/storvsc_drv.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 64fa305..4dffc3b 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -226,9 +226,8 @@ struct vmstor_protocol { int vmscsi_size_delta; }; -#define VMSTOR_NUM_PROTOCOLS 5 -const struct vmstor_protocol vmstor_protocols[VMSTOR_NUM_PROTOCOLS] = { +const struct vmstor_protocol vmstor_protocols[] = { { VMSTOR_PROTO_VERSION_WIN10, POST_WIN7_STORVSC_SENSE_BUFFER_SIZE, @@ -959,7 +958,7 @@ static int storvsc_channel_init(struct hv_device *device) } - for (i = 0; i < VMSTOR_NUM_PROTOCOLS; i++) { + for (i = 0; i < ARRAY_SIZE(vmstor_protocols); i++) { /* reuse the packet for version range supported */ memset(vstor_packet, 0, sizeof(struct vstor_packet)); vstor_packet->operation =