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: 77886 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp656556qge; Mon, 17 Oct 2016 18:56:51 -0700 (PDT) X-Received: by 10.66.63.40 with SMTP id d8mr576524pas.103.1476755811330; Mon, 17 Oct 2016 18:56:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q24si33108904pfj.175.2016.10.17.18.56.51; Mon, 17 Oct 2016 18:56:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935772AbcJRB4t (ORCPT + 4 others); Mon, 17 Oct 2016 21:56:49 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34234 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933085AbcJRB4l (ORCPT ); Mon, 17 Oct 2016 21:56:41 -0400 Received: by mail-pf0-f175.google.com with SMTP id r16so62372531pfg.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=B0NMbuO2MtCJI7gRlOlIVBEPtXHBTlbBLDjZvmhqbce2lMy0xZy0BbWPAfX/DwJGB+ 1FPxSRvRITnURyPPmPzEWsfxHisaaQ/sFosFnyh09QZkj8hZ3e/uaa6U/SyK0YqmPiBF zavacrWwOmIDevpj6imXv0+H1GVhGMrmwtAl9a54Pa/Q/fEXiqPsE3rx6HQLCQJyzfPo SbtH8J/6aZZDY/7Czmtf3d+MqSzcniFBYLQSiS+jARHf3OM+tMykI6NdS1PVy7hdzqIz SuVMyJv4rzqN/6qljl/V/Rb4x4vDVpd0NE3VpIn6pkYjSKMcEHO20SETIUQ8Cp7vVyrA d8MA== X-Gm-Message-State: AA6/9Rk18hQiHZ1GH+2j/NsY0/ipKdgWgV+/kGRv6KgbpM+KOWwnMc4veaNIi5ts5UHX8uC3 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 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 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> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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. 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(+) -- 2.10.0.297.gf6727b0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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) {