From patchwork Wed Apr 13 09:35:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 65707 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2398176qge; Wed, 13 Apr 2016 02:36:53 -0700 (PDT) X-Received: by 10.66.221.167 with SMTP id qf7mr11482266pac.94.1460540213553; Wed, 13 Apr 2016 02:36:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si838064paw.32.2016.04.13.02.36.53; Wed, 13 Apr 2016 02:36:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-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-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965448AbcDMJgw (ORCPT + 4 others); Wed, 13 Apr 2016 05:36:52 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:23515 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965471AbcDMJgM (ORCPT ); Wed, 13 Apr 2016 05:36:12 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O5K003WAG096F10@mailout2.w1.samsung.com>; Wed, 13 Apr 2016 10:36:09 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-32-570e1309b7c6 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 0E.95.04866.9031E075; Wed, 13 Apr 2016 10:36:09 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O5K005BCG05JE40@eusync1.samsung.com>; Wed, 13 Apr 2016 10:36:09 +0100 (BST) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Russell King - ARM Linux , Ulf Hansson , Greg Kroah-Hartman , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v7 1/2] drivers: base: add support for registering notifier about deferred probe Date: Wed, 13 Apr 2016 11:35:59 +0200 Message-id: <1460540160-18762-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1460540160-18762-1-git-send-email-m.szyprowski@samsung.com> References: <1460540160-18762-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPLMWRmVeSWpSXmKPExsVy+t/xy7qcwnzhBq++SVtsnLGe1aJ58Xo2 i9cvDC02Pb7GanF51xw2ixnn9zFZ3L7Ma7H2yF12i+Nrwx04PVqae9g87lzbw+axf+4ado/N S+o9+rasYvT4vEkugC2KyyYlNSezLLVI3y6BK2PPqk1sBXskKpZemMPYwPhQpIuRk0NCwETi VPMCRghbTOLCvfVsXYxcHEICSxklbnV3sEM4TUwS9943gFWxCRhKdL3tYgOxRQSyJebv7QYr YhZYwSTR//ABUIKDQ1ggSWLhO1WQGhYBVYn2GS/YQWxeAQ+JK7vOQ22Tk/j/cgUTiM0p4Clx 9M42FhBbCKjm1a4d7BMYeRcwMqxiFE0tTS4oTkrPNdIrTswtLs1L10vOz93ECAm2rzsYlx6z OsQowMGoxMOrsZ43XIg1say4MvcQowQHs5II7xc+vnAh3pTEyqrUovz4otKc1OJDjNIcLEri vDN3vQ8REkhPLEnNTk0tSC2CyTJxcEo1MMaGLBbK+JVZMMVriWr1HpeNxbtdH+Twf2288vly FxfHjF9TuCKE17S4+osbWe89XKvUOSUqy+9FiRJ33Xf1z/svqz2tTimbz3dORvSB8aLm9S8T vPbcb+1SyxRo/98h5sx1X/DOp6aVLyOYZt1RcghREDxnJlrXvcSUr87t0avI2N+z6v5HKLEU ZyQaajEXFScCAOqOQcEyAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds code which allow other subsystems get a notification when deferred probe has been triggered. This way one can retry some actions, which earlier failed with -EPROBE_DEFER error code. Signed-off-by: Marek Szyprowski --- drivers/base/dd.c | 31 +++++++++++++++++++++++++++++++ include/linux/device.h | 3 +++ 2 files changed, 34 insertions(+) -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 16688f50729c..208466eb83fb 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -53,6 +54,7 @@ static LIST_HEAD(deferred_probe_pending_list); static LIST_HEAD(deferred_probe_active_list); static struct workqueue_struct *deferred_wq; static atomic_t deferred_trigger_count = ATOMIC_INIT(0); +static BLOCKING_NOTIFIER_HEAD(deferred_notifier_head); /* * In some cases, like suspend to RAM or hibernation, It might be reasonable @@ -113,6 +115,9 @@ static void deferred_probe_work_func(struct work_struct *work) put_device(dev); } mutex_unlock(&deferred_probe_mutex); + + /* Notify any listeners about triggering deferred probe */ + blocking_notifier_call_chain(&deferred_notifier_head, 0, NULL); } static DECLARE_WORK(deferred_probe_work, deferred_probe_work_func); @@ -224,6 +229,32 @@ static int deferred_probe_initcall(void) late_initcall(deferred_probe_initcall); /** + * deferred_probe_register_notifier - Register a notifier for deferred probe + * @nb: notifier block to signal + * + * This function allows caller to get a notification when deferred probe has + * been triggered. This lets it to retry some actions, which earlier failed + * with -EPROBE_DEFER error code. + */ +int deferred_probe_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&deferred_notifier_head, nb); +} +EXPORT_SYMBOL_GPL(deferred_probe_register_notifier); + +/** + * deferred_probe_unregister_notifier - Unregister a notifier + * @nb: notifier block to signal + * + * Unregister a previously registered deferred probe notifier. + */ +int deferred_probe_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&deferred_notifier_head, nb); +} +EXPORT_SYMBOL_GPL(deferred_probe_unregister_notifier); + +/** * device_is_bound() - Check if device is bound to a driver * @dev: device to check * diff --git a/include/linux/device.h b/include/linux/device.h index 002c59728dbe..c6496d1db5de 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1066,6 +1066,9 @@ extern int __must_check device_reprobe(struct device *dev); extern bool device_is_bound(struct device *dev); +extern int deferred_probe_register_notifier(struct notifier_block *nb); +extern int deferred_probe_unregister_notifier(struct notifier_block *nb); + /* * Easy functions for dynamically creating devices on the fly */