From patchwork Tue Dec 1 09:16:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 7734261 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 D997F9F1C2 for ; Tue, 1 Dec 2015 09:17:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0636F206A9 for ; Tue, 1 Dec 2015 09:17:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 156F3206AB for ; Tue, 1 Dec 2015 09:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755763AbbLAJRY (ORCPT ); Tue, 1 Dec 2015 04:17:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:41605 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755584AbbLAJRO (ORCPT ); Tue, 1 Dec 2015 04:17:14 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4EB1DAD73; Tue, 1 Dec 2015 09:17:01 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , Ewan Milne , James Bottomley , Johannes Thumshirn , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 18/18] scsi_dh_alua: use scsi_vpd_tpg_id() Date: Tue, 1 Dec 2015 10:16:58 +0100 Message-Id: <1448961418-29013-19-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1448961418-29013-1-git-send-email-hare@suse.de> References: <1448961418-29013-1-git-send-email-hare@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Use the common function 'scsi_vpd_tpg_id()' instead of open-coding it in scsi_dh_alua. Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig Signed-off-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh_alua.c | 39 +++++------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index abf05b4..20fe981 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -320,38 +320,10 @@ static int alua_check_tpgs(struct scsi_device *sdev) */ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h) { - unsigned char *d; - unsigned char __rcu *vpd_pg83; + int rel_port = -1, group_id; - rcu_read_lock(); - if (!rcu_dereference(sdev->vpd_pg83)){ - rcu_read_unlock(); - return SCSI_DH_DEV_UNSUPP; - } - - /* - * Look for the correct descriptor. - */ - vpd_pg83 = rcu_dereference(sdev->vpd_pg83); - d = vpd_pg83 + 4; - while (d < vpd_pg83 + sdev->vpd_pg83_len) { - switch (d[1] & 0xf) { - case 0x4: - /* Relative target port */ - h->rel_port = get_unaligned_be16(&d[6]); - break; - case 0x5: - /* Target port group */ - h->group_id = get_unaligned_be16(&d[6]); - break; - default: - break; - } - d += d[3] + 4; - } - rcu_read_unlock(); - - if (h->group_id == -1) { + group_id = scsi_vpd_tpg_id(sdev, &rel_port); + if (group_id < 0) { /* * Internal error; TPGS supported but required * VPD identification descriptors not present. @@ -360,10 +332,11 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h) sdev_printk(KERN_INFO, sdev, "%s: No target port descriptors found\n", ALUA_DH_NAME); - h->state = TPGS_STATE_OPTIMIZED; - h->tpgs = TPGS_MODE_NONE; return SCSI_DH_DEV_UNSUPP; } + h->rel_port = rel_port; + h->group_id = group_id; + sdev_printk(KERN_INFO, sdev, "%s: port group %02x rel port %02x\n", ALUA_DH_NAME, h->group_id, h->rel_port);