From patchwork Thu Sep 1 00:40:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 75135 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp19968qga; Wed, 31 Aug 2016 17:41:19 -0700 (PDT) X-Received: by 10.66.217.132 with SMTP id oy4mr22076438pac.46.1472690478981; Wed, 31 Aug 2016 17:41:18 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oy8si2396026pac.126.2016.08.31.17.41.18; Wed, 31 Aug 2016 17:41:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933819AbcIAAkr (ORCPT + 27 others); Wed, 31 Aug 2016 20:40:47 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35026 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754700AbcIAAkk (ORCPT ); Wed, 31 Aug 2016 20:40:40 -0400 Received: by mail-pa0-f50.google.com with SMTP id hb8so23569514pac.2 for ; Wed, 31 Aug 2016 17:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jh58yjgIQc80NpUTz9LAAFXymbvxB2t6kOm2ptusEGM=; b=ForAmDCsuFyK8uK9WefcyE4oOLsnmgaXmLJUqgPIJtyZHViz1w7XtW+dC/i6GEGYgD rhLP7ffgi2mNufu+QeODO2b1TwuBlTzGNC2dmtup3hd6plwOQePp6O6WUO7mng86+ZLj PYc6LOfcaJrM6rgTQK8IZgjCiGbWiZ0BZiSig= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jh58yjgIQc80NpUTz9LAAFXymbvxB2t6kOm2ptusEGM=; b=mkq7NsBihP2c4CBj1l/heXauWa5rJcLAfiRtbxi60QRHA+qhfL31s+d5w6ddoTtvMR nWy34IQHpjJb+23Xa9Gp/NxM1/38cBssIJBTPnzqcCUxe46kLdk/uSgFWAuY+/N8QOIG Lo3618HIFYDhEWZxL5PToxITMHSWQKGnfLtd3WVCndVXsw2icUJ7rBub0uD2yUdlEpx/ gfY4xylxrob2fggwptc9Xv6Mk/ZZN74M1WUvC5hW7fXG+HPfFyB5dEadaaTjR/V1xhiG fJVdC9tslQt3CrkMAkiv4W9kDUJTlGpn2ovrQC9aKR0BoNCEhhCcM3ptUdKDFJyvXOmT 3qxw== X-Gm-Message-State: AE9vXwOrPKIMJGJXPJheL8jxt0k6gZLyQUamcuvWUi900rLgEgwzrxLAVXFM4eDn28CT123Y X-Received: by 10.66.144.164 with SMTP id sn4mr19293746pab.0.1472690439399; Wed, 31 Aug 2016 17:40:39 -0700 (PDT) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id m5sm2292303paw.40.2016.08.31.17.40.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Aug 2016 17:40:39 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Peter Chen , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v3 01/22] of: device: Support loading a module with OF based modalias Date: Wed, 31 Aug 2016 17:40:15 -0700 Message-Id: <20160901004036.23936-2-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160901004036.23936-1-stephen.boyd@linaro.org> References: <20160901004036.23936-1-stephen.boyd@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the case of ULPI devices, we want to be able to load the driver before registering the device so that we don't get stuck in a loop waiting for the phy module to appear and failing usb controller probe. Currently we request the ulpi module via the ulpi ids, but in the DT case we might need to request it with the OF based modalias instead. Add a common function that allows anyone to request a module with the OF based modalias. Cc: Rob Herring Cc: Signed-off-by: Stephen Boyd --- drivers/of/device.c | 23 +++++++++++++++++++++++ include/linux/of_device.h | 6 ++++++ 2 files changed, 29 insertions(+) -- 2.9.0.rc2.8.ga28705d diff --git a/drivers/of/device.c b/drivers/of/device.c index fd5cfad7c403..8a22a253a830 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -226,6 +226,29 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) return tsize; } +int of_device_request_module(struct device *dev) +{ + char *str; + ssize_t size; + int ret; + + size = of_device_get_modalias(dev, NULL, 0); + if (size < 0) + return size; + + str = kmalloc(size + 1, GFP_KERNEL); + if (!str) + return -ENOMEM; + + of_device_get_modalias(dev, str, size); + str[size] = '\0'; + ret = request_module(str); + kfree(str); + + return ret; +} +EXPORT_SYMBOL_GPL(of_device_request_module); + /** * of_device_uevent - Display OF related uevent information */ diff --git a/include/linux/of_device.h b/include/linux/of_device.h index cc7dd687a89d..e9afbcc8de12 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -37,6 +37,7 @@ extern const void *of_device_get_match_data(const struct device *dev); extern ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len); +extern int of_device_request_module(struct device *dev); extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env); extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env); @@ -78,6 +79,11 @@ static inline int of_device_get_modalias(struct device *dev, return -ENODEV; } +static inline int of_device_request_module(struct device *dev) +{ + return -ENODEV; +} + static inline int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) {