From patchwork Wed Dec 28 22:56:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9490791 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B4CE62AB0 for ; Wed, 28 Dec 2016 23:03:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3356026242 for ; Wed, 28 Dec 2016 23:03:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2526F26530; Wed, 28 Dec 2016 23:03:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F4BC26242 for ; Wed, 28 Dec 2016 23:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbcL1W5T (ORCPT ); Wed, 28 Dec 2016 17:57:19 -0500 Received: from mail-pg0-f44.google.com ([74.125.83.44]:33782 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752076AbcL1W5Q (ORCPT ); Wed, 28 Dec 2016 17:57:16 -0500 Received: by mail-pg0-f44.google.com with SMTP id g1so120718430pgn.0 for ; Wed, 28 Dec 2016 14:57:15 -0800 (PST) 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=dvY89DX/gTxupcZmHNFKKuoEzxS+g7fsnytbgsbXu00=; b=R7Tavrc99fQLygzFsfcWjmyT1YopFGlsMIzjgFwyU2Q/V7ur8vsdQ2gH2SMdgAq43d EDoMVKrDdAVy/ZXHxY4UQ6tGVy8oPZqbl9H+WrRvNcoReMtU+Mn8qCZZcplbLOiyJFzj LygmnEZ9sV5sqRt0zYNFMohZoMvCnjaYhf/Co= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dvY89DX/gTxupcZmHNFKKuoEzxS+g7fsnytbgsbXu00=; b=f1SpYBqNvR8U7x8kQmSnJlBILXJohva6DLMmuVQvXKb+0KRM8vBqQkFKLRvwdwFOah Lgq7y+kGmaXldRk/5BE+Vc9+Bh/26wwoU0t8mpYTDDZE0laEDVyvXopyQnzc7l9FUON3 ULXDGFREWO316VdLNHfy6xTAz73SJ8LuocDT55pCXO7tef1brU/4Jia8FVEaHrqCatsW 0WQa7RPlGV5Js6tjH14eDXoaF9ZzH+wa0z0qFJfwzfvbFz6BcxrAjDtFiBIOX4njHjhU csnUiHGvNEMHeJcH+aP/GLHkbC2r3tDDNykuYUZ9Qo9NdFDJpT4L00BGaPYJ5uaZaSyZ WYFQ== X-Gm-Message-State: AIkVDXI75s9H6aEWi+R0Uq8ldqGaQ7T7pYFAMZ2RlxRTC92Chd+yieHh5JRJdR4Ac1/2S+Cr X-Received: by 10.98.75.75 with SMTP id y72mr31866769pfa.23.1482965835003; Wed, 28 Dec 2016 14:57:15 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id x4sm100355741pgc.14.2016.12.28.14.57.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Dec 2016 14:57:14 -0800 (PST) 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 , devicetree@vger.kernel.org Subject: [PATCH v6 01/25] of: device: Support loading a module with OF based modalias Date: Wed, 28 Dec 2016 14:56:47 -0800 Message-Id: <20161228225711.698-2-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 In-Reply-To: <20161228225711.698-1-stephen.boyd@linaro.org> References: <20161228225711.698-1-stephen.boyd@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Acked-by: Rob Herring Cc: Signed-off-by: Stephen Boyd --- drivers/of/device.c | 23 +++++++++++++++++++++++ include/linux/of_device.h | 6 ++++++ 2 files changed, 29 insertions(+) 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) {