Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11533262imu; Tue, 1 Jan 2019 01:15:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN4nfqwZHw+mnBfSBFsVtyAeE9w07O45/SH+pBluYki/9KdAQUzyceiblY75K8xuWYCkafnM X-Received: by 2002:a17:902:b592:: with SMTP id a18mr34405832pls.293.1546334150358; Tue, 01 Jan 2019 01:15:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546334150; cv=none; d=google.com; s=arc-20160816; b=doSFb19i1suTVZ9PKkgsQaBjf/K1qa4JEipb3nHEAm8MR3I2Crc9RpbhRjbAMphvl2 +i5RabAfQH/LE3/PWjpGBKyd1hD2u5OXEwmT8WdwMEOBmuCgnKLY/XhB8RFEyUfmf+MM lUvYmhql/SIJmDIUmyHgQiSuud9nbb1hrzrCzoc71kqVwNWqNP7fQH8C+w5zE66hyWGg n4TCASegO+mALKSvyJC6Pg9dn2QR3YRpolukXXd8DOGf2HhyaBW/3wPuT3ZrLnAIzd8/ kBThWUKTw7Hk1bbrAOgpei/2Ux7ZqxSB+h8dxMB2yrWeMziQu9Fq70QAhGoODjuAkCI0 FW3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=FHZtkkiIvRBqJBMt/yMlsDpY83/MpbYX89dqsLIR7mc=; b=ZxA3eajIc7QNgsGCa+nmrJ2XjMplCL9qR/735rKOfPs9a5EpEiTFbptxzDC7jvtdGY WWmcpOVk5t3gf9b6+ip7lX2AaNE8S0A41A49KivkUXf47bnQb4btGdOy92hdHQv8LuPp hjTpzHd8+u5ogTlGyxqCMPli/zYutV3QH7DI85tPSQI0AqZpY13d07tvXjUOqR771u3d yoPsXK5PbLPzUBTUEtXZY9j8iuuVG2QBiWnOa61kZebhWtRHaEgQJKKlwHNivstGUqBG x+9fAwDcNVw6rRp7jeqcqFUKAlgdCZKYr9Y4clAJwrzYS4z36sQwq4fk7ErjiXiX8D1F noig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b30si7447444pla.285.2019.01.01.01.15.12; Tue, 01 Jan 2019 01:15:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbfAAEv6 (ORCPT + 99 others); Mon, 31 Dec 2018 23:51:58 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:37377 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726740AbfAAEv6 (ORCPT ); Mon, 31 Dec 2018 23:51:58 -0500 X-UUID: 7edc5f1ea9404f02b99ab1f00cd5f1fb-20190101 X-UUID: 7edc5f1ea9404f02b99ab1f00cd5f1fb-20190101 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1466982651; Tue, 01 Jan 2019 12:51:50 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 1 Jan 2019 12:51:48 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 1 Jan 2019 12:51:48 +0800 From: Yong Wu To: Joerg Roedel , Greg Kroah-Hartman , Matthias Brugger , Rob Herring CC: Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , , , Nicolas Boichat Subject: [PATCH 02/13] driver core: Remove the link if there is no driver with AUTO flag Date: Tue, 1 Jan 2019 12:51:05 +0800 Message-ID: <1546318276-18993-3-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546318276-18993-1-git-send-email-yong.wu@mediatek.com> References: <1546318276-18993-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 79505BBE12833B41BBCDE2CAFB788151A8D5FC51391A36032ADF8B6884827C3C2000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DL_FLAG_AUTOREMOVE_CONSUMER/SUPPLIER means "Remove the link automatically on consumer/supplier driver unbind", that means we should remove whole the device_link when there is no this driver no matter what the ref_count of the link is. CC: Greg Kroah-Hartman Signed-off-by: Yong Wu --- The ref_count of our device_link normally is over 1. When the consumer device driver is removed, whole the device_link should be removed. Thus, I add this patch. --- drivers/base/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 04bbcd7..4f3c5bc 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -511,7 +511,7 @@ static void __device_links_no_driver(struct device *dev) continue; if (link->flags & DL_FLAG_AUTOREMOVE_CONSUMER) - kref_put(&link->kref, __device_link_del); + __device_link_del(&link->kref); else if (link->status != DL_STATE_SUPPLIER_UNBIND) WRITE_ONCE(link->status, DL_STATE_AVAILABLE); } @@ -556,7 +556,7 @@ void device_links_driver_cleanup(struct device *dev) */ if (link->status == DL_STATE_SUPPLIER_UNBIND && link->flags & DL_FLAG_AUTOREMOVE_SUPPLIER) - kref_put(&link->kref, __device_link_del); + __device_link_del(&link->kref); WRITE_ONCE(link->status, DL_STATE_DORMANT); } -- 1.9.1