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: 34921 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 57E2A20523 for ; Tue, 5 Aug 2014 10:49:49 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wn1sf3184171obc.6 for ; Tue, 05 Aug 2014 03:49:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=nCt6z8fewVOvcquZ4QpxhTfZeR4rElgDIq7DNqFHSAg=; b=YfscEtZ6YN9ldxKFkMR18SvjqLyafIHWu+tXp00xDl3Qr7j+D/krxzO0zEyQx0U0AB dDV0UoNExevPvafz+j91uiBSKqYWZV8SZyaL2B7GegQTB/i/ZeUoAc7VOz/7KWP9ejxn bjUlarDbmQV+HBe2s6JmXWGCpp6xkcuFqv+83bS0pts5LQVOonWiEospNfBL35oL2Bmw GtaMYzCvXqfp/MBigY1I5o0yrEZsA2E1tkP8MPbuyxeirTYcUf1WhsisrpvBObWPhGSo lZkviesL2y2aYwnR78+iRIu6y0dJ70O3fJT8+6vhx4rnhi9svPKCR+Om5zs6uhxJauVW nI4Q== X-Gm-Message-State: ALoCoQk2AjpO477u+6s02qUwgXvXq5CA0B/XVj87HkzPCTco9qCFeUezy2+DZ6w+zTwxvQptIAdX X-Received: by 10.182.142.5 with SMTP id rs5mr1392254obb.15.1407235788004; Tue, 05 Aug 2014 03:49:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.239 with SMTP id p102ls218417qgd.57.gmail; Tue, 05 Aug 2014 03:49:47 -0700 (PDT) X-Received: by 10.220.96.137 with SMTP id h9mr2397834vcn.46.1407235787880; Tue, 05 Aug 2014 03:49:47 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id tu4si778386vcb.61.2014.08.05.03.49.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Aug 2014 03:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id hy10so1102913vcb.18 for ; Tue, 05 Aug 2014 03:49:47 -0700 (PDT) X-Received: by 10.52.8.71 with SMTP id p7mr424099vda.77.1407235787809; Tue, 05 Aug 2014 03:49:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp374590vcb; Tue, 5 Aug 2014 03:49:47 -0700 (PDT) X-Received: by 10.224.114.74 with SMTP id d10mr4138236qaq.33.1407235787206; Tue, 05 Aug 2014 03:49:47 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id f1si2177522qai.2.2014.08.05.03.49.46 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Aug 2014 03:49:47 -0700 (PDT) Received-SPF: none (google.com: linaro-mm-sig-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEcJO-0005Kt-2O; Tue, 05 Aug 2014 10:49:46 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEcId-0005Ef-9O for linaro-mm-sig@lists.linaro.org; Tue, 05 Aug 2014 10:48:59 +0000 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> for linaro-mm-sig@lists.linaro.org; 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 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 Cc: Rob Herring , Thierry Reding , Shaik Ameer Basha , Arnd Bergmann , Inki Dae , Greg Kroah-Hartman , Joerg Roedel , "Rafael J. Wysocki" , Tomasz Figa , linaro-mm-sig@lists.linaro.org, Kyungmin Park , Kukjin Kim , Laurent Pinchart , Sylwester Nawrocki , Olof Johansson , Cho KyongHo Subject: [Linaro-mm-sig] [PATCH 04/29] drivers: base: add notifier for failed driver bind X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: linaro-mm-sig-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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);