From nobody Wed Feb 11 04:00:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2658FC6FD1D for ; Tue, 4 Apr 2023 17:23:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236092AbjDDRXH (ORCPT ); Tue, 4 Apr 2023 13:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236046AbjDDRW7 (ORCPT ); Tue, 4 Apr 2023 13:22:59 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B836444B5 for ; Tue, 4 Apr 2023 10:22:31 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id cn12so133617667edb.4 for ; Tue, 04 Apr 2023 10:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680628950; 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=kqPgD/iPpDsbHZcAXUeeUavFA2MxWf1NdZYvsMxlqGU=; b=kbcfXHB/OdnfMxWx68lSgdoekOL26dxAi/dLe41r/5LzrX671939MlHlLh4aHOPW5Y FJHF1j1nqKdsXeIJVbAr1NH4v/PeloFSbpblwvh9C/tSc3yChkYyIAq1MMrU9uhr0xCb 6o3mhRvWoMSi1tamKGGOPR9iMFclUbbDrlA8y4uSdNEBdTB4Shp+00vWMDzWBwfLqKib 6jy4j1rK+98L6KXUO8JICe8Pkb3iL/e89DeSP2JbnTjjNHSVZUMsSFWgmi/rFgbJn+jV dtYQ8x4hOuQeMUgmKnuNv1V1GmOFrPlpc0i/jsOT+BGK4n6bSEEz7nWB7pKzHv2x4+u7 W+cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680628950; 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=kqPgD/iPpDsbHZcAXUeeUavFA2MxWf1NdZYvsMxlqGU=; b=z6M8E/nIR74WC/QPsq8Um1u5Q02yi1zE6VeZ5r8jSJ4o/zBh1+qDbauDqGtCEKP6BD t7fxLs62NoGSArAstmnKh5M+tzteAiDzTcAtHDjgv32HH7l4UB1uat1veieOVvg4RsNs LI6Gs7yqYFK5eT+9FPbFSnpsH9/fPCl2jkSMlBsedfArYZMVSBiu+OJGPJly9CTw3SGy ePDu7mRYmt5bswpT0XpdLbT5dkPLlmevVPDYsD4HpZtHF/LnkQzef+Gdi0SmDjkiayXd XhmBKzGeFamarrMxtMF5PtCN6L8m/Grtn27DmKRNj2QIjYWOL64P6mLJ7cbhX4RPT6h0 YRAA== X-Gm-Message-State: AAQBX9dUwTBB8IuagJP0HpzF/deydBCLRD9/f5LT/8AtaN8y9Z04XdQ4 6WuMvCSmFTDptOhORw915GXd/w== X-Google-Smtp-Source: AKy350bGQLOIAitsi9vliIeBN5Wtntogmr+4OD2TvfszxOgb8Q8zWp2s14jkNLHymawXlAdyYTIJeQ== X-Received: by 2002:aa7:d809:0:b0:502:91c6:fa8f with SMTP id v9-20020aa7d809000000b0050291c6fa8fmr157668edq.42.1680628950336; Tue, 04 Apr 2023 10:22:30 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 10:22:29 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Miquel Raynal , Rob Herring , Srinivas Kandagatla Subject: [PATCH 07/40] of: Update of_device_get_modalias() Date: Tue, 4 Apr 2023 18:21:15 +0100 Message-Id: <20230404172148.82422-8-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miquel Raynal This function only needs a "struct device_node" to work, but for convenience the author (and only user) of this helper did use a "struct device" and put it in device.c. Let's convert this helper to take a "struct device node" instead. This change asks for two additional changes: renaming it "of_modalias()" to fit the current naming, and moving it outside of device.c which will be done in a follow-up commit. Signed-off-by: Miquel Raynal Reviewed-by: Rob Herring Signed-off-by: Srinivas Kandagatla --- drivers/of/device.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index c91bb5899256..351c505ecb50 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -248,7 +248,7 @@ const void *of_device_get_match_data(const struct devic= e *dev) } EXPORT_SYMBOL(of_device_get_match_data); =20 -static ssize_t of_device_get_modalias(const struct device *dev, char *str,= ssize_t len) +static ssize_t of_modalias(const struct device_node *np, char *str, ssize_= t len) { const char *compat; char *c; @@ -256,19 +256,16 @@ static ssize_t of_device_get_modalias(const struct de= vice *dev, char *str, ssize ssize_t csize; ssize_t tsize; =20 - if ((!dev) || (!dev->of_node) || dev->of_node_reused) - return -ENODEV; - /* Name & Type */ /* %p eats all alphanum characters, so %c must be used here */ - csize =3D snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T', - of_node_get_device_type(dev->of_node)); + csize =3D snprintf(str, len, "of:N%pOFn%c%s", np, 'T', + of_node_get_device_type(np)); tsize =3D csize; len -=3D csize; if (str) str +=3D csize; =20 - of_property_for_each_string(dev->of_node, "compatible", p, compat) { + of_property_for_each_string(np, "compatible", p, compat) { csize =3D strlen(compat) + 1; tsize +=3D csize; if (csize > len) @@ -293,7 +290,10 @@ int of_device_request_module(struct device *dev) ssize_t size; int ret; =20 - size =3D of_device_get_modalias(dev, NULL, 0); + if (!dev || !dev->of_node) + return -ENODEV; + + size =3D of_modalias(dev->of_node, NULL, 0); if (size < 0) return size; =20 @@ -304,7 +304,7 @@ int of_device_request_module(struct device *dev) if (!str) return -ENOMEM; =20 - of_device_get_modalias(dev, str, size); + of_modalias(dev->of_node, str, size); str[size - 1] =3D '\0'; ret =3D request_module(str); kfree(str); @@ -321,7 +321,12 @@ EXPORT_SYMBOL_GPL(of_device_request_module); */ ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len) { - ssize_t sl =3D of_device_get_modalias(dev, str, len - 2); + ssize_t sl; + + if (!dev || !dev->of_node || dev->of_node_reused) + return -ENODEV; + + sl =3D of_modalias(dev->of_node, str, len - 2); if (sl < 0) return sl; if (sl > len - 2) @@ -386,8 +391,8 @@ int of_device_uevent_modalias(const struct device *dev,= struct kobj_uevent_env * if (add_uevent_var(env, "MODALIAS=3D")) return -ENOMEM; =20 - sl =3D of_device_get_modalias(dev, &env->buf[env->buflen-1], - sizeof(env->buf) - env->buflen); + sl =3D of_modalias(dev->of_node, &env->buf[env->buflen-1], + sizeof(env->buf) - env->buflen); if (sl < 0) return sl; if (sl >=3D (sizeof(env->buf) - env->buflen)) --=20 2.25.1