From patchwork Tue Aug 5 10:47:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 4678181 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7FBABC0338 for ; Tue, 5 Aug 2014 10:59:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDA7E20173 for ; Tue, 5 Aug 2014 10:59:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5637C2018B for ; Tue, 5 Aug 2014 10:59:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756257AbaHEK65 (ORCPT ); Tue, 5 Aug 2014 06:58:57 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:44572 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754720AbaHEKsy (ORCPT ); Tue, 5 Aug 2014 06:48:54 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9T00DKCY1A7Y00@mailout1.w1.samsung.com>; Tue, 05 Aug 2014 11:48:46 +0100 (BST) X-AuditID: cbfec7f5-b7f776d000003e54-7a-53e0b694a1ab Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id ED.CC.15956.496B0E35; Tue, 05 Aug 2014 11:48:52 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N9T0057MY17SE80@eusync3.samsung.com>; Tue, 05 Aug 2014 11:48:52 +0100 (BST) From: Marek Szyprowski To: iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , linaro-mm-sig@lists.linaro.org, Arnd Bergmann , Shaik Ameer Basha , Cho KyongHo , Joerg Roedel , Thierry Reding , Olof Johansson , Laurent Pinchart , Rob Herring , Greg Kroah-Hartman , "Rafael J. Wysocki" , Inki Dae , Kukjin Kim , Sylwester Nawrocki , Tomasz Figa , Kyungmin Park Subject: [PATCH 04/29] drivers: base: add notifier for failed driver bind Date: Tue, 05 Aug 2014 12:47:32 +0200 Message-id: <1407235677-26324-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1407235677-26324-1-git-send-email-m.szyprowski@samsung.com> References: <1407235677-26324-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRmVeSWpSXmKPExsVy+t/xq7pTtj0INvj7WNzi76Rj7BbNi9ez WUy6P4HFYsF+a4vO2RvYLXoXXGWzONv0ht2ic+ISdosvVx4yWWx6fI3V4vKuOWwWM87vY7JY e+Quu8Wp65/ZLP71HmS0OHP6EqvF/z072C0Ov2lntTjycDe7xapdfxgtbv/mcxD1eHJwHpPH 71+TGD12zrrL7jG7Yyarx6ZVnWwe++euYffYvKTe4/a/x8wek28sZ/S4cqKJ1aO3+R2bx5ar 7SwefVtWMXp83iQXwBfFZZOSmpNZllqkb5fAlfFybitbwWaRiov/77E1MJ4X6GLk5JAQMJGY 2b2KCcIWk7hwbz1bFyMXh5DAUkaJu9tesEA4fUwSr36uYgWpYhMwlOh62wVWJSLQyyjR3/SD CcRhFljHKrG/9zpQCweHsICnxLrjciAmi4CqxNUv1iC9vAIeEtdnrWGF2CYn8f/lCrDNnEDV h28eAIsLAdX83LCGfQIj7wJGhlWMoqmlyQXFSem5RnrFibnFpXnpesn5uZsYIXHzdQfj0mNW hxgFOBiVeHgV9t4NFmJNLCuuzD3EKMHBrCTCK7HmQbAQb0piZVVqUX58UWlOavEhRiYOTqkG xuDS8i8+3f6z7++J1el3W8pipDpXNDZ/r5MHO/+bA18+6DvZPTghvryq8++XD46/9sy9dvHv TvN6tW9chun1yxQ1TP6cZxK2y74xd96T4j29rY2bjaRMr6b7f6nofnJmk6CK5kqNQwVPBJxD rpy6pWN1dvccuSsMnI2TZSXVKl+90Tx4KkV5gRJLcUaioRZzUXEiAFwsL7d5AgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for getting a notify for failed device driver bind, so all the items done in BUS_NOTIFY_BIND_DRIVER event can be cleaned if the driver fails to bind. Signed-off-by: Marek Szyprowski --- drivers/base/dd.c | 10 +++++++--- include/linux/device.h | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index e4ffbcf..541a41f 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -237,10 +237,14 @@ static int driver_sysfs_add(struct device *dev) return ret; } -static void driver_sysfs_remove(struct device *dev) +static void driver_sysfs_remove(struct device *dev, int failed) { struct device_driver *drv = dev->driver; + if (failed && dev->bus) + blocking_notifier_call_chain(&dev->bus->p->bus_notifier, + BUS_NOTIFY_DRVBIND_FAILED, dev); + if (drv) { sysfs_remove_link(&drv->p->kobj, kobject_name(&dev->kobj)); sysfs_remove_link(&dev->kobj, "driver"); @@ -316,7 +320,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) probe_failed: devres_release_all(dev); - driver_sysfs_remove(dev); + driver_sysfs_remove(dev, true); dev->driver = NULL; dev_set_drvdata(dev, NULL); @@ -509,7 +513,7 @@ static void __device_release_driver(struct device *dev) if (drv) { pm_runtime_get_sync(dev); - driver_sysfs_remove(dev); + driver_sysfs_remove(dev, false); if (dev->bus) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, diff --git a/include/linux/device.h b/include/linux/device.h index b387710..92daded 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -176,7 +176,7 @@ extern int bus_register_notifier(struct bus_type *bus, extern int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb); -/* All 4 notifers below get called with the target struct device * +/* All 7 notifers below get called with the target struct device * * as an argument. Note that those functions are likely to be called * with the device lock held in the core, so be careful. */ @@ -189,6 +189,8 @@ extern int bus_unregister_notifier(struct bus_type *bus, unbound */ #define BUS_NOTIFY_UNBOUND_DRIVER 0x00000006 /* driver is unbound from the device */ +#define BUS_NOTIFY_DRVBIND_FAILED 0x00000007 /* driver failed to bind + to device */ extern struct kset *bus_get_kset(struct bus_type *bus); extern struct klist *bus_get_device_klist(struct bus_type *bus);