Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6298929rwl; Tue, 4 Apr 2023 10:23:53 -0700 (PDT) X-Google-Smtp-Source: AKy350afW9miosBoo+x1JyTglCKxSV2uEUTxP1NQsYi7QRJE4y2TqlTukPkQtsQrSXYQ/2tSG1tg X-Received: by 2002:a17:90b:3a83:b0:23f:9925:6f8b with SMTP id om3-20020a17090b3a8300b0023f99256f8bmr3671549pjb.17.1680629033087; Tue, 04 Apr 2023 10:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680629033; cv=none; d=google.com; s=arc-20160816; b=jtjjeoqh/oZNV0eyPuBmvzm25TX0OUHeQCemm/DOUWYidimx3i9502QdxqEukzZ3C0 IPf2IdTl0qGcxwGYXXaEfU3t0kmD8hDVa729DWMAgUW1HB+bMF4owSsewUvKI+XR20uW CSrdXfdH52xkz9ZRGsrXA16gnAPb6FvZPlnpCYlmFQomNwKSy/6RX5+6dNN+WD7USDYc SmbhJywupjcl1A+07AQb9PNzXu11oSBDuWiyJXTI0EsFb/AY1UBjP/YGf+NvNYjwDlxH 41nuFxSEjKykP58lOwurRWhbZOCYn/XkPqJJJYXi/z2oo3gFK7w4R1hlAabxfa/JlBrL o+2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b0yKnw9nXKYVaFHn5olSAf00S375pzRbEb0HhrzPylE=; b=yHF34lVcpSzhHutr5kHofgUZL6Iq5v6sfIaNv0lZa5FpdswXp6mDFwIOVfLF+GgRSY eqr6siEwzyxhcBqA9HXSvTwCrZG7EJ4BTStAfj+l4ZuQbB6SRw4th+EOg+nAoIiopbl0 hR0WncgmpnsbWHpzHlh8m0cUA6O7rjM90CIp8X8m/7BbOPdawIxQbdV71gfEF5nqUHrq XSKKNcouU/Q+AMOMt3/nKe1dMk6ZXZXgdwm0I20+rfJQHel428wk5ZdkCNzFtUxKFLPz x1uyyYf8ij9MdDsWEdBvChh3Ks7UB6iN5G0+8MaXRdXTIpCAZo8RAjqekNeTlK9Pg/k7 s25A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="d/vq4Kgv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 143-20020a630095000000b00513f070aaa1si4752447pga.892.2023.04.04.10.23.41; Tue, 04 Apr 2023 10:23:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="d/vq4Kgv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236130AbjDDRXP (ORCPT + 99 others); Tue, 4 Apr 2023 13:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236065AbjDDRXB (ORCPT ); Tue, 4 Apr 2023 13:23:01 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F0DC4687 for ; Tue, 4 Apr 2023 10:22:36 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id ek18so133632969edb.6 for ; Tue, 04 Apr 2023 10:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680628955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b0yKnw9nXKYVaFHn5olSAf00S375pzRbEb0HhrzPylE=; b=d/vq4KgvL2/h/ziRCZW1cqyulvHodNQXjKQwHAOT1K76ObCCR5b5FjbqxG8JTUXNFI k/FnMf5tNUjxKJQaGuJGhu36t4xYrTFlJkpjpVpdI0e6QPoV28RknJJqDfStpLqVU5JZ UAPilvg8Z3+gX3e4zaOy2NjHBS67QwyeehB6bm3i/Rs8zkFESEeplqe3oiwuqI6DoO5Y EpukhA2vzPf98mwHtQG3q1fGkZqC+FNNteWf/P3V3sGyzSNN3MPNr4zOHKMmoNRy4LZm ePCsbFlBQiiqkU3KMOveRk/460hqLTMOEtyT4DIHnQkRv7HXXIt4spVsiThLgYLZ1okp r5xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680628955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b0yKnw9nXKYVaFHn5olSAf00S375pzRbEb0HhrzPylE=; b=h2KmgTx0qvISLQjXQlK+tCwF6WFPujI2btbcNFJftUm6poS2yUdiqxCwqp/XBOlrZw 05d/e68AevSCXbSVEXnEwC1P00JN/c7irKcZMbNCyb+1S6Ju+qXxSQ0/uRuybBxZyV+I bjC9WX9F3lQ/Pi70zPdUaA07PxxNK0pH+rVTO4UAQeK17GudrgreFHyRST+8NwaOIxj3 ikjS34uZ7Ympak4cXvnyEPuOXsm2gsS2ZTDIDsRJUBsIHDdjcOmUcpCr+8ktQAo10+Yh UwunEOb4sr9chsCft0cYVl2gKpkMkRcz4uq1/IEyWlQ2MEfw5IIbBkvMXQfEWuBtrpSB Rcsw== X-Gm-Message-State: AAQBX9fcWQMBvsDk3ml2vyd7cEPeIgRmag/rBPksQE/KR0XfMr3gaOZe RkE0wvmAtAsuQT/HhfWlWoklCaSMPicPleK0mzQ= X-Received: by 2002:aa7:c64a:0:b0:4fd:1f7b:9fbd with SMTP id z10-20020aa7c64a000000b004fd1f7b9fbdmr62683edr.6.1680628955044; Tue, 04 Apr 2023 10:22:35 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bv20-20020a170906b1d400b009447277c2aasm6208333ejb.39.2023.04.04.10.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 10:22:34 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Miquel Raynal , Rob Herring , Srinivas Kandagatla Subject: [PATCH 10/40] of: Move the request module helper logic to module.c Date: Tue, 4 Apr 2023 18:21:18 +0100 Message-Id: <20230404172148.82422-11-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404172148.82422-1-srinivas.kandagatla@linaro.org> References: <20230404172148.82422-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miquel Raynal Depending on device.c for pure OF handling is considered backwards. Let's extract the content of of_device_request_module() to have the real logic under module.c. The next step will be to convert users of of_device_request_module() to use the new helper. Signed-off-by: Miquel Raynal Reviewed-by: Rob Herring Signed-off-by: Srinivas Kandagatla --- drivers/of/device.c | 25 ++----------------------- drivers/of/module.c | 30 ++++++++++++++++++++++++++++++ include/linux/of.h | 6 ++++++ 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 7183cfd754db..874a2e1f6308 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -8,7 +8,6 @@ #include /* for bus_dma_region */ #include #include -#include #include #include #include @@ -249,30 +248,10 @@ EXPORT_SYMBOL(of_device_get_match_data); int of_device_request_module(struct device *dev) { - char *str; - ssize_t size; - int ret; - - if (!dev || !dev->of_node) + if (!dev) return -ENODEV; - size = of_modalias(dev->of_node, NULL, 0); - if (size < 0) - return size; - - /* Reserve an additional byte for the trailing '\0' */ - size++; - - str = kmalloc(size, GFP_KERNEL); - if (!str) - return -ENOMEM; - - of_modalias(dev->of_node, str, size); - str[size - 1] = '\0'; - ret = request_module(str); - kfree(str); - - return ret; + return of_request_module(dev->of_node); } EXPORT_SYMBOL_GPL(of_device_request_module); diff --git a/drivers/of/module.c b/drivers/of/module.c index 4c59752bc8d6..0e8aa974f0f2 100644 --- a/drivers/of/module.c +++ b/drivers/of/module.c @@ -4,6 +4,7 @@ */ #include +#include #include #include @@ -42,3 +43,32 @@ ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len) return tsize; } + +int of_request_module(const struct device_node *np) +{ + char *str; + ssize_t size; + int ret; + + if (!np) + return -ENODEV; + + size = of_modalias(np, NULL, 0); + if (size < 0) + return size; + + /* Reserve an additional byte for the trailing '\0' */ + size++; + + str = kmalloc(size, GFP_KERNEL); + if (!str) + return -ENOMEM; + + of_modalias(np, str, size); + str[size - 1] = '\0'; + ret = request_module(str); + kfree(str); + + return ret; +} +EXPORT_SYMBOL_GPL(of_request_module); diff --git a/include/linux/of.h b/include/linux/of.h index be26c7e8ef9e..9b7a99499ef3 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -387,6 +387,7 @@ extern int of_count_phandle_with_args(const struct device_node *np, /* module functions */ extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len); +extern int of_request_module(const struct device_node *np); /* phandle iterator functions */ extern int of_phandle_iterator_init(struct of_phandle_iterator *it, @@ -751,6 +752,11 @@ static inline ssize_t of_modalias(const struct device_node *np, char *str, return -ENODEV; } +static inline int of_request_module(const struct device_node *np) +{ + return -ENODEV; +} + static inline int of_phandle_iterator_init(struct of_phandle_iterator *it, const struct device_node *np, const char *list_name, -- 2.25.1