Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4127363pxu; Mon, 30 Nov 2020 18:47:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoKq906b6FTU1UNIUnMrCZ7YN8LA1JXnQTPsTZs5F6TIOtk9gubtgirEl2MRzKetcOfbsC X-Received: by 2002:a17:906:2581:: with SMTP id m1mr979758ejb.28.1606790860721; Mon, 30 Nov 2020 18:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606790860; cv=none; d=google.com; s=arc-20160816; b=wORHUl+ASaJy1sQnJjSCsVNOtb4Pws4FKZdVsmd3yVcz0nOhlc6i4xzL36lIXDCYdK u2129tOjrk1Y6p99ygPRmdOW0/W4XGDM8oBvFegkbh2ahFi8t+NQBSt+V+2qshYKnkMJ Ihs6APj54D5uYuff/5wfvxrNcUajgEgvleYaqobAZsxS+TGjjr0E5GcfDIGgd8KniqmB 2pOVXeqnyGs/+rZEru5hN/prtGEktiholTlYWw6WTO7+cAbOTyqmEXTPI9juY3yQEeLs NJ1ZrNpySjGbp44LDL6Osx9PvfvPtiMRAWFKY4QbhfRoSKLJIBWJWMdFvepb7+kA6q4D 2UWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=q2xoH9qxEqWdx/jbImqyy9fSGbX4lDmFUcT9saDZ7Pw=; b=Iwo/pdrYmF7vZ9EXtpUQizW6HWuTAzUmtX9s0qHa6WQ5KyFcMIH/308xXVdRwllyLX X+KcrGC3je7AYSQsNvz8fS/lv9oV5bS8hH5zR0X0tUswR5Mqd0mZbcoTErigDTV2wktz xy19QUFP069LGCeP9AaSxPBI0ldZzT+PP6IN9y7121JUVCXIac8Tk3Ao537BVa/3aqDX hMdieP7UD9MwewxzXQ9YaPBmPtnlJx/BRn8dHpO1DI47u2DvcItN63nCSC2WXX5BG9Gv 0rXPWOaVLty200U4jAy3xDzFZu0uwaUAj2G15iOGtUd7kRscemOnFNMFnrtMkoBdzzMl AcnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si309484eds.56.2020.11.30.18.47.18; Mon, 30 Nov 2020 18:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbgLACkI (ORCPT + 99 others); Mon, 30 Nov 2020 21:40:08 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:8893 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727041AbgLACkI (ORCPT ); Mon, 30 Nov 2020 21:40:08 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4ClRBF33dlz763R; Tue, 1 Dec 2020 10:39:01 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Tue, 1 Dec 2020 10:39:16 +0800 From: Qinglang Miao To: Steffen Maier , Benjamin Block , Heiko Carstens , Vasily Gorbik , Christian Borntraeger CC: , , "Qinglang Miao" Subject: [PATCH v2] scsi: zfcp: move the position of put_device Date: Tue, 1 Dec 2020 10:47:16 +0800 Message-ID: <20201201024716.42926-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Have the `put_device()` call after `device_unregister()` in both `zfcp_unit_remove()` and `zfcp_sysfs_port_remove_store()` to make it more natural, for put_device() ought to be the last time we touch the object in both functions. And add comments after put_device to make codes clearer. Suggested-by: Steffen Maier Suggested-by: Benjamin Block Signed-off-by: Qinglang Miao --- v2: add comments after put_device as Steffen suggested. drivers/s390/scsi/zfcp_sysfs.c | 4 ++-- drivers/s390/scsi/zfcp_unit.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 8d9662e8b..ef6d35a37 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -327,10 +327,10 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, list_del(&port->list); write_unlock_irq(&adapter->port_list_lock); - put_device(&port->dev); - zfcp_erp_port_shutdown(port, 0, "syprs_1"); device_unregister(&port->dev); + + put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */ out: zfcp_ccw_adapter_put(adapter); return retval ? retval : (ssize_t) count; diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c index e67bf7388..59333f025 100644 --- a/drivers/s390/scsi/zfcp_unit.c +++ b/drivers/s390/scsi/zfcp_unit.c @@ -255,9 +255,9 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun) scsi_device_put(sdev); } - put_device(&unit->dev); - device_unregister(&unit->dev); + put_device(&unit->dev); /* undo _zfcp_unit_find() */ + return 0; } -- 2.23.0