From patchwork Mon Sep 23 14:27:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 2928371 Return-Path: X-Original-To: patchwork-linux-fbdev@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 B8A06BFF05 for ; Mon, 23 Sep 2013 14:33:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6391F2024F for ; Mon, 23 Sep 2013 14:33:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2C5F2014B for ; Mon, 23 Sep 2013 14:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753302Ab3IWOaK (ORCPT ); Mon, 23 Sep 2013 10:30:10 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:41836 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752338Ab3IWO14 (ORCPT ); Mon, 23 Sep 2013 10:27:56 -0400 Received: by mail-la0-f53.google.com with SMTP id el20so2605851lab.12 for ; Mon, 23 Sep 2013 07:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5OOyriDnzNO101WGDurwZrLoTjMNRn47bkKpDEIlAwI=; b=qsRcBuX9sU+bPOo3iLW8EfS2q2kR/WsZ/yIc0TnyRpYgED/Les3pohjWMhD62wlOTu zZ/+QkbGj1oBWoobmuY6R74mOKOOKd4ONrI+RRXwsjr70EhzOkwZEiauXrLyvaRrRMUB 4U4Efi4IE9xBfrUNOf7jEE5XwxWnPp2Y286orU4eEwF3uO0wf0h+OHj+iqCnKrJJh8TN 54NR8P977x/HN8QsOgeiui5y7ZWYh/C4IW1oOoGq8VMDXyZsaXWZcGTZWIVYsqYu7/d4 vpe5kGoZ4Fgb+K36TM2KOmECqcagzj+CK3axlxUlpOqaB75pPLJjLV69nu8muPV0M3C3 4Yqw== X-Received: by 10.152.87.143 with SMTP id ay15mr20564038lab.2.1379946472171; Mon, 23 Sep 2013 07:27:52 -0700 (PDT) Received: from xi.terra (c193-14-141-227.cust.tele2.se. [193.14.141.227]) by mx.google.com with ESMTPSA id b1sm12868151lah.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 23 Sep 2013 07:27:50 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.80.1) (envelope-from ) id 1VO775-0006ga-9N; Mon, 23 Sep 2013 16:27:47 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Grant Likely , Mark Brown , linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pcmcia@lists.infradead.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, Johan Hovold Subject: [PATCH 1/7] driver core: prevent deferred probe with platform_driver_probe Date: Mon, 23 Sep 2013 16:27:26 +0200 Message-Id: <1379946452-25649-2-git-send-email-jhovold@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1379946452-25649-1-git-send-email-jhovold@gmail.com> References: <20130923134028.GF21013@sirena.org.uk> <1379946452-25649-1-git-send-email-jhovold@gmail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Prevent drivers relying on platform_driver_probe from requesting deferred probing in order to avoid further futile probe attempts (either the driver has been unregistered or its probe function has been set to platform_drv_probe_fail when probing is retried). Note that several platform drivers currently return subsystem errors from probe and that these can include -EPROBE_DEFER (e.g. if a gpio request fails). Add a warning to platform_drv_probe that can be used to catch drivers that inadvertently request probe deferral while using platform_driver_probe. Signed-off-by: Johan Hovold --- drivers/base/platform.c | 17 +++++++++++++---- include/linux/platform_device.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4f8bef3..47051cd 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -488,6 +488,11 @@ static int platform_drv_probe(struct device *_dev) if (ret && ACPI_HANDLE(_dev)) acpi_dev_pm_detach(_dev, true); + if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) { + dev_warn(_dev, "probe deferral not supported\n"); + ret = -ENXIO; + } + return ret; } @@ -553,8 +558,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister); /** * platform_driver_probe - register driver for non-hotpluggable device * @drv: platform driver structure - * @probe: the driver probe routine, probably from an __init section, - * must not return -EPROBE_DEFER. + * @probe: the driver probe routine, probably from an __init section * * Use this instead of platform_driver_register() when you know the device * is not hotpluggable and has already been registered, and you want to @@ -565,8 +569,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister); * into system-on-chip processors, where the controller devices have been * configured as part of board setup. * - * This is incompatible with deferred probing so probe() must not - * return -EPROBE_DEFER. + * Note that this is incompatible with deferred probing. * * Returns zero if the driver registered and bound to a device, else returns * a negative error code and with the driver not registered. @@ -576,6 +579,12 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv, { int retval, code; + /* + * Prevent driver from requesting probe deferral to avoid further + * futile probe attempts. + */ + drv->prevent_deferred_probe = true; + /* make sure driver won't have bind/unbind attributes */ drv->driver.suppress_bind_attrs = true; diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index ce8e4ff..16f6654 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -178,6 +178,7 @@ struct platform_driver { int (*resume)(struct platform_device *); struct device_driver driver; const struct platform_device_id *id_table; + bool prevent_deferred_probe; }; #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \