From patchwork Tue Oct 18 01:56:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9381055 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 03B0E6086B for ; Tue, 18 Oct 2016 01:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF0EA28CCD for ; Tue, 18 Oct 2016 01:58:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2C3B28CD7; Tue, 18 Oct 2016 01:58:50 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 61F7628CCD for ; Tue, 18 Oct 2016 01:58:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bwJef-0008U8-6H; Tue, 18 Oct 2016 01:57:25 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bwJeG-0008K2-Po for linux-arm-kernel@lists.infradead.org; Tue, 18 Oct 2016 01:57:02 +0000 Received: by mail-pf0-x229.google.com with SMTP id r16so62372527pfg.1 for ; Mon, 17 Oct 2016 18:56:40 -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=dvY89DX/gTxupcZmHNFKKuoEzxS+g7fsnytbgsbXu00=; b=KELNofmqFpiq2jWO6Ry+PvZyAfrVHwKs5Bw3fthLxOf9uDQeuq9m+ruTYbtYbUc+VQ rzgspoCqlxv6l0CN7Un6AzSCDt0mxLg9M+jeu8WYwa/sIrVIX49crRcOkLEPS8yG4hQd G8rEKZDzYt8a2DbGXbzySvyHkP6p1DUrxICfE= 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=dvY89DX/gTxupcZmHNFKKuoEzxS+g7fsnytbgsbXu00=; b=be47SatlgFSJA7TbvKPZi4QnHzYQhQ3V1htBFHwS3K5Vv9Nfwigo1z8V+Rg9HQWyrh Koypuf27kGwsLJzgQppIRgZwh8gFTbujQ4E2rOb29SLzSRbpzITth6sxseOPtXKPEVxO lL3wooe6F6hU+0FM8ahj4j6PGNk8A5HcLaxr4DVJRTMHBrVuXTHYJSYuGiws+VzpYuyU 555V36jZX59gwqU0A2yFK7M37wf1UYr7lMntNr45atfQMHoFMGNzveuqgFL/E0XE1mfG 1vfXaMu5m/XumvbapQYmjaVBy0pI8ItZ7v3P1A1kNTN75uAsINZ3Lm9356BlKBLvvMG8 ROjg== X-Gm-Message-State: AA6/9RlyWhmLHgl9XmzPxV1jej8pSRQ6PAF9S5XcWPi2i2gT3G0z2CdV16yYaMuO/CIAZS5Q X-Received: by 10.99.2.214 with SMTP id 205mr575633pgc.1.1476755800000; Mon, 17 Oct 2016 18:56:40 -0700 (PDT) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id j6sm51020430paa.44.2016.10.17.18.56.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 18:56:39 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Subject: [PATCH v5 01/23] of: device: Support loading a module with OF based modalias Date: Mon, 17 Oct 2016 18:56:14 -0700 Message-Id: <20161018015636.11701-2-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 In-Reply-To: <20161018015636.11701-1-stephen.boyd@linaro.org> References: <20161018015636.11701-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161017_185700_968992_8417DC5E X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , Arnd Bergmann , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , devicetree@vger.kernel.org, Peter Chen , Andy Gross , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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) {