From patchwork Thu Jun 4 15:45:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 213821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EDB6C433E0 for ; Thu, 4 Jun 2020 15:45:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA0D12065C for ; Thu, 4 Jun 2020 15:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729555AbgFDPpi (ORCPT ); Thu, 4 Jun 2020 11:45:38 -0400 Received: from smtp.infotech.no ([82.134.31.41]:50193 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729346AbgFDPpi (ORCPT ); Thu, 4 Jun 2020 11:45:38 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 3DF5020418F; Thu, 4 Jun 2020 17:45:36 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aFkAJMUNwHhp; Thu, 4 Jun 2020 17:45:34 +0200 (CEST) Received: from xtwo70.bingwo.ca (host-23-251-188-50.dyn.295.ca [23.251.188.50]) by smtp.infotech.no (Postfix) with ESMTPA id BC1A120417A; Thu, 4 Jun 2020 17:45:33 +0200 (CEST) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, bvanassche@acm.org Subject: [PATCH] scsi: simplify scsi_target() inline Date: Thu, 4 Jun 2020 11:45:32 -0400 Message-Id: <20200604154532.208869-1-dgilbert@interlog.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org A review of the code indicates this scsi_device.h comment for a struct scsi_device member is misleading: struct scsi_target *sdev_target; /* used only for single_lun */ sdev_target is set once in scsi_alloc_sdev() to the new sdev's parent and not altered thereafter. This in turn implies that the often-used scsi_target(struct scsi_device *sdev) inline function is going the long way around finding its parent. Simplify it and rework that comment. Signed-off-by: Douglas Gilbert --- include/scsi/scsi_device.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index fd1465a73ef4..76eb1782348f 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -141,7 +141,7 @@ struct scsi_device { struct scsi_vpd __rcu *vpd_pg80; struct scsi_vpd __rcu *vpd_pg89; unsigned char current_tag; /* current tag */ - struct scsi_target *sdev_target; /* used only for single_lun */ + struct scsi_target *sdev_target; /* parent of this object */ blist_flags_t sdev_bflags; /* black/white flags as also found in * scsi_devinfo.[hc]. For now used only to @@ -334,7 +334,7 @@ static inline struct Scsi_Host *starget_to_shost(struct scsi_target *starg) #define to_scsi_target(d) container_of(d, struct scsi_target, dev) static inline struct scsi_target *scsi_target(struct scsi_device *sdev) { - return to_scsi_target(sdev->sdev_gendev.parent); + return sdev->sdev_target; } #define transport_class_to_starget(class_dev) \ to_scsi_target(class_dev->parent)