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: 71625 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp126029qgy; Thu, 7 Jul 2016 15:21:41 -0700 (PDT) X-Received: by 10.66.249.161 with SMTP id yv1mr4186598pac.39.1467930098862; Thu, 07 Jul 2016 15:21:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tv9si356088pac.85.2016.07.07.15.21.38; Thu, 07 Jul 2016 15:21:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S932153AbcGGWVd (ORCPT + 7 others); Thu, 7 Jul 2016 18:21:33 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33357 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932126AbcGGWVU (ORCPT ); Thu, 7 Jul 2016 18:21:20 -0400 Received: by mail-pf0-f171.google.com with SMTP id i123so9703031pfg.0 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=PC4BnyltNk4wiAVlhlZM6zVZNIdBKHTaO8M4hNTxic2xltt17aLP2ZQ91YiA8bX3sP BuRLy/0if9czbya0N4vIpHFbLnjzztzHTw4dw6fQJixEE5Grs2UyucsavsH31lhbh+A3 7gmE7EhODiseZrsJyPDQncmQK+F4+gE+XXDx5XgmODXocyE0PnrqnfZQ+xGEClKvtWM+ w/pszvtQuv8syz18iT4v/mwD83K1l0UPupj0TenN8btawTSdFAfTWYiBEldAwll2Ut81 XJMW8WBNN0gRSzG0tQge01aII4taAejiARK7/pNZxxdqb9CSfi/o3epgT8vjpvOCLZit ovdw== X-Gm-Message-State: ALyK8tIf5r/9P6h6lfDmlRVnxeOW0nCmFPLmR2MybnRN9ixYoRJ02ekfEea31d9ht+obEoK2 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 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 , Rob Herring , devicetree@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> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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. 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(+) -- 2.9.0.rc2.8.ga28705d -- To unsubscribe from this list: send the line "unsubscribe devicetree" 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) {