From patchwork Wed Sep 7 21:34:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9320053 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 900C6607D3 for ; Wed, 7 Sep 2016 21:40:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AE78292CF for ; Wed, 7 Sep 2016 21:40:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F3DE2931F; Wed, 7 Sep 2016 21:40:22 +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 2F427292CF for ; Wed, 7 Sep 2016 21:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757145AbcIGVf1 (ORCPT ); Wed, 7 Sep 2016 17:35:27 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34468 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757042AbcIGVfY (ORCPT ); Wed, 7 Sep 2016 17:35:24 -0400 Received: by mail-pa0-f50.google.com with SMTP id to9so9973296pac.1 for ; Wed, 07 Sep 2016 14:35:23 -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=b2ikdrS7TCPjzYvqhW81AawaUHaJ7l2iW8m3Wyqtw8atZS3QXitnD4p840b07WesTp 5vxikvcxQYfBA1OPtKU2xCb39C8fqjakW4OYy5TRewgWV+u7YTXOeI1sH/v44PXlxPJo TB772JpeDI3Lac1/U7Uhmm9eUsrDJsJheSusU= 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=LYb1lE3BqA1hI7OdUkAK1vzq2QPBaZUbfuUjC/xfSs0tbL51gN5g2D3MwgziZy1Whv e76ecGwTqTX3Rbrzf/clJ5h/G0+F7hgjJKoROMTqeaxaOXxk+nXIteOLqF2B1ZGxr249 50bgA6ySPR84nTfZpkqMXqrLe6MxSz88YuEWVilkEIkmRjzOXBMniU7r842wzZrMqqgu Pq4Skuzby86YKE9ttteZMV+zzsN5kjf0V/WjM8v8RDEAcCoQs9B7neg7+jcSaDX89qPT hyIBX89BLcIliD8w+gM1JGiFT7u81Z8tzt+EoWLZgzXaQnthPnBnPbyea3nv86gPovPL 6N5w== X-Gm-Message-State: AE9vXwOETLHfCpZuNKC3UlrrVgCL17y2Ax+zHwENVNSBmhS0r+gU4dsy1uTA0ex/txtrrLZu X-Received: by 10.66.75.4 with SMTP id y4mr4801292pav.139.1473284123397; Wed, 07 Sep 2016 14:35:23 -0700 (PDT) Received: from localhost.localdomain (ip68-101-172-78.sd.sd.cox.net. [68.101.172.78]) by smtp.gmail.com with ESMTPSA id 75sm51015417pfw.92.2016.09.07.14.35.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Sep 2016 14:35:22 -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 v4 01/22] of: device: Support loading a module with OF based modalias Date: Wed, 7 Sep 2016 14:34:58 -0700 Message-Id: <20160907213519.27340-2-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160907213519.27340-1-stephen.boyd@linaro.org> References: <20160907213519.27340-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. Cc: Rob Herring Cc: Signed-off-by: Stephen Boyd Acked-by: Rob Herring --- 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) {