From patchwork Thu Nov 26 12:49:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 7706521 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E729CBF90C for ; Thu, 26 Nov 2015 12:50:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04A07205F1 for ; Thu, 26 Nov 2015 12:50:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BCE420693 for ; Thu, 26 Nov 2015 12:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750943AbbKZMuI (ORCPT ); Thu, 26 Nov 2015 07:50:08 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:56621 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751046AbbKZMuD (ORCPT ); Thu, 26 Nov 2015 07:50:03 -0500 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 <0NYF00HX6ABDVLA0@mailout2.w1.samsung.com>; Thu, 26 Nov 2015 12:50:01 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-12-5656fff9fd54 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 14.F8.21385.9FFF6565; Thu, 26 Nov 2015 12:50:01 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NYF00CQ1AB8M710@eusync3.samsung.com>; Thu, 26 Nov 2015 12:50:01 +0000 (GMT) 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 , Tomeu Vizoso , Greg Kroah-Hartman , Kukjin Kim , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 2/4] driver core: handle -EPROBE_DEFER from bus_type.match() Date: Thu, 26 Nov 2015 13:49:48 +0100 Message-id: <1448542190-19498-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1448542190-19498-1-git-send-email-m.szyprowski@samsung.com> References: <1448542190-19498-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMLMWRmVeSWpSXmKPExsVy+t/xq7o//4eFGax7IWCxccZ6VovmxevZ LF6/MLTof/ya2WLT42usFpd3zWGzmHF+H5PF7cu8FmuP3GW36Ft7ic3i+NpwB26PluYeNo8d d5cwemxa1cnmcefaHjaP/XPXsHtsXlLv0bdlFaPH501yARxRXDYpqTmZZalF+nYJXBmr33ax FTRKVny5NJm5gbFNpIuRk0NCwETi5Kx9LBC2mMSFe+vZuhi5OIQEljJKfP7RxQ7hNDFJHP7w hRmkik3AUKILaBKILSKQLTF/bzc7iM0s8IVJommLG4gtLOAvca7/HCOIzSKgKrHwx1Qwm1fA Q6Jv/wOobXIS/1+uYAKxOQU8Jab93wBWIwRUM6nnMusERt4FjAyrGEVTS5MLipPSc430ihNz i0vz0vWS83M3MUKC8usOxqXHrA4xCnAwKvHwFtiGhQmxJpYVV+YeYpTgYFYS4f3yECjEm5JY WZValB9fVJqTWnyIUZqDRUmcd+au9yFCAumJJanZqakFqUUwWSYOTqkGxlJDZWf1uQ4/Jq7d 7j//vvKOy3FXvW7UnPzPIXG2ik1zp2SxzZkDKxezNhkZnzntEnd6afXfsparIY1rv87YkVtz bbW2//u5+56XpPywfPVhToO2f0HhAonvobLydza650r6L7iwI33Z826VU8lZdROdJKb5fhC9 XNM+f+2SU3O5Ha8u7udqYlBiKc5INNRiLipOBAA+JuG7RgIAAA== 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.9 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 From: Tomeu Vizoso Lets implementations of the match() callback in struct bus_type to return errors and if it's -EPROBE_DEFER then queue the device for deferred probing. This is useful to buses such as AMBA in which devices are registered before their matching information can be retrieved from the HW (typically because a clock driver hasn't probed yet). Signed-off-by: Tomeu Vizoso Signed-off-by: Marek Szyprowski --- drivers/base/dd.c | 24 ++++++++++++++++++++++-- include/linux/device.h | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index a641cf3..a20c119 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -490,6 +490,7 @@ static int __device_attach_driver(struct device_driver *drv, void *_data) struct device_attach_data *data = _data; struct device *dev = data->dev; bool async_allowed; + int ret; /* * Check if device has already been claimed. This may @@ -500,8 +501,17 @@ static int __device_attach_driver(struct device_driver *drv, void *_data) if (dev->driver) return -EBUSY; - if (!driver_match_device(drv, dev)) + ret = driver_match_device(drv, dev); + if (!ret) return 0; + else if (ret < 0) { + if (ret == -EPROBE_DEFER) { + dev_dbg(dev, "Device match requests probe deferral\n"); + driver_deferred_probe_add(dev); + } else + dev_warn(dev, "Bus failed to match device: %d", ret); + return ret; + } async_allowed = driver_allows_async_probing(drv); @@ -621,6 +631,7 @@ void device_initial_probe(struct device *dev) static int __driver_attach(struct device *dev, void *data) { struct device_driver *drv = data; + int ret; /* * Lock device and try to bind to it. We drop the error @@ -632,8 +643,17 @@ static int __driver_attach(struct device *dev, void *data) * is an error. */ - if (!driver_match_device(drv, dev)) + ret = driver_match_device(drv, dev); + if (!ret) + return 0; + else if (ret < 0) { + if (ret == -EPROBE_DEFER) { + dev_dbg(dev, "Device match requests probe deferral\n"); + driver_deferred_probe_add(dev); + } else + dev_warn(dev, "Bus failed to match device: %d", ret); return 0; + } if (dev->parent) /* Needed for USB */ device_lock(dev->parent); diff --git a/include/linux/device.h b/include/linux/device.h index b8f411b..d4e7d1f 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -70,7 +70,7 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); * @dev_groups: Default attributes of the devices on the bus. * @drv_groups: Default attributes of the device drivers on the bus. * @match: Called, perhaps multiple times, whenever a new device or driver - * is added for this bus. It should return a nonzero value if the + * is added for this bus. It should return a positive value if the * given device can be handled by the given driver. * @uevent: Called when a device is added, removed, or a few other things * that generate uevents to add the environment variables.