From patchwork Fri May 29 13:47:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 11578751 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B30B4739 for ; Fri, 29 May 2020 13:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4930207BC for ; Fri, 29 May 2020 13:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726939AbgE2Nri (ORCPT ); Fri, 29 May 2020 09:47:38 -0400 Received: from mx2.suse.de ([195.135.220.15]:35664 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbgE2Nri (ORCPT ); Fri, 29 May 2020 09:47:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D113EAF5C; Fri, 29 May 2020 13:47:36 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , Doug Gilbert , Daniel Wagner , Johannes Thumshirn , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 2/5] target_core_pscsi: use __scsi_device_lookup() Date: Fri, 29 May 2020 15:47:27 +0200 Message-Id: <20200529134730.146573-3-hare@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200529134730.146573-1-hare@suse.de> References: <20200529134730.146573-1-hare@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of walking the list of devices manually use the helper function to return the device directly. Signed-off-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn Reviewed-by: Bart van Assche --- drivers/target/target_core_pscsi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index c9d92b3e777d..5fb852d1281f 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -496,11 +496,9 @@ static int pscsi_configure_device(struct se_device *dev) } spin_lock_irq(sh->host_lock); - list_for_each_entry(sd, &sh->__devices, siblings) { - if ((pdv->pdv_channel_id != sd->channel) || - (pdv->pdv_target_id != sd->id) || - (pdv->pdv_lun_id != sd->lun)) - continue; + sd = __scsi_device_lookup(sh, pdv->pdv_channel_id, + pdv->pdv_target_id, pdv->pdv_lun_id); + if (sd) { /* * Functions will release the held struct scsi_host->host_lock * before calling calling pscsi_add_device_to_list() to register