From patchwork Thu Jul 7 22:20:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9219707 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 35BE5607D9 for ; Thu, 7 Jul 2016 22:23:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2672028488 for ; Thu, 7 Jul 2016 22:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B2D02848A; Thu, 7 Jul 2016 22:23:52 +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 D08F628488 for ; Thu, 7 Jul 2016 22:23:51 +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 1bLHfy-0007gJ-G7; Thu, 07 Jul 2016 22:21:42 +0000 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bLHfw-0007eC-1a for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2016 22:21:40 +0000 Received: by mail-pf0-x236.google.com with SMTP id h14so9716617pfe.1 for ; Thu, 07 Jul 2016 15:21:19 -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=VCIyuJUWc1DA7lSE7A4JZJitdG8+nHu+a2oamBZ5A2ddZlbnDCUg9zadgy+eXmBvSb FmhxLxyc6ABQq59Z9PRr2RMj5BXJxdg+qJorfDHjSoEuxS8cOilEHgxIOsIEz1PDNThf 9zP1jxw8Qnl6wsB8ykythxp89kD4HxyqHOYiQ= 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=dz1ClQpNXCgv0IYSJbF+zdxl4TVZ9yei+1X1OrL3GSTkzMYHyhFX4pbvpSsgXuwpck FAjcO8jEXvfMvS23b8uR9J2G6ns39nqf+0xYS2Mho2Co+W8p4qxOBMdcRAGruj8f8ks2 vobwXQByKgwggthBqEWU5gCyCZubbjvZM6ftXAFZxD5PdbLuoStip7bTEx05wzoOUHYc 6phq01e4fbuh3drSFMMsUmt1mmsD0KdKMKIbEhsoMlbOO/vZK1bVAcfLLJekArRAVld8 yVjix4sxYMGcJitumO2zra8quXnEEHFD/nXfMIw3pxc/9T/geUAKbw/F+arQ1HIQDyUu PjUA== X-Gm-Message-State: ALyK8tJYAJhrYfFn4A1kQuJDYrCOPhKvgaqkux+SSoNqg0S0KT71F+GbwUtzHIsnVvasRKKt X-Received: by 10.98.20.216 with SMTP id 207mr4265305pfu.144.1467930079059; Thu, 07 Jul 2016 15:21:19 -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 j8sm6781807paj.22.2016.07.07.15.21.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 15:21:18 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Subject: [PATCH v2 01/22] of: device: Support loading a module with OF based modalias Date: Thu, 7 Jul 2016 15:20:52 -0700 Message-Id: <20160707222114.1673-2-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160707222114.1673-1-stephen.boyd@linaro.org> References: <20160707222114.1673-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160707_152140_111112_6442B65B X-CRM114-Status: GOOD ( 13.93 ) 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, Rob Herring , 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. 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(+) 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) {