From patchwork Wed May 10 15:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 92197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3739154vqo; Wed, 10 May 2023 09:07:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Paf8cybcRKdQqHbOSTOit7gtQ/pJ52y1SKKeDgCqk/6NerIohZDahwOmoWu87AFe+HcT6 X-Received: by 2002:a05:6870:e3c1:b0:187:e437:58d0 with SMTP id y1-20020a056870e3c100b00187e43758d0mr10059718oad.31.1683734844635; Wed, 10 May 2023 09:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683734844; cv=none; d=google.com; s=arc-20160816; b=TvCiLJ0p5tavNG809tfGhEwcQpTWlRh24G49N8BQA7AdmvOUJktyfeK894RFJcKe4s ue+oGXTX5oTfcKnqPydJjbN/32xlGN0Ex7i9Fo8qIkeLdT4SWb8DuUOz+k9MdVrxiDkL igN1YMISabSOsIgJQRbt5brWuGO8MECoOPXQVRX3p6yg0zgaUm8lUxeVcToaI590EiAQ uDVwjk5m6mUZZd0gPZwncnhbyOEcV30WUdSqP82+qL/8I4W0SJnYNMFbg/los+A1K8zo s+S+Ye/OwYeGFxb1ktucz5baP2epEY347hhC9RLcYS7J4DUjkNHP1JS40N6vWtJOtdp0 RHow== 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=IYd4H+SE761zyTPoCHwwfUTe0y6OdgwEBPBK9090C4k=; b=cz3x9WX6UvCN5KERWJuFZcU7bR65v2oE0qkrHaCNWoRE+eQED1JNm4COskuzaeA/ni uX4n59CwwJDOk2oHnBrl0aEmK+cd4Y9u7rXUi2miFo1rB+1vf5V6qmNQtr/Ah8rElznd XxjCsLaZ1W93sq4+LDcizFbuyrEfnipbgLm0fTYH7M+1Nwsr3sZw3o7FrLJsM79kFEaL 3Nqh1950EVwOh7PADxOjMWfWmIkO4Axte9WnYJD+LgguVBDXGpujmXid1ZMOlwFpIo55 yD95w2elt3Stk+Zc1FC5Ix+Ji6A9H3TvKTo3Pw2f5mnQsHEvMu1/ipHdutP8a5BCDal7 TaoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=IQoZhvrg; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a056870c08300b00192adaecdccsi9500195oad.223.2023.05.10.09.07.08; Wed, 10 May 2023 09:07:24 -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=@bootlin.com header.s=gm1 header.b=IQoZhvrg; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237549AbjEJPsO (ORCPT + 99 others); Wed, 10 May 2023 11:48:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbjEJPsJ (ORCPT ); Wed, 10 May 2023 11:48:09 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC1F5E7C; Wed, 10 May 2023 08:48:06 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 95F6AC000C; Wed, 10 May 2023 15:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683733685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IYd4H+SE761zyTPoCHwwfUTe0y6OdgwEBPBK9090C4k=; b=IQoZhvrgB3cVqfOcAidaOCXCDeka1k9jJNjEQCom89NHXBuF+Rd/VZQZm0xj1Lrnm+40OE yTnjpZ0ASEqix34tB5MCwIPGVPcluPhv33R1VUlHanMqfYx7ZZ54ok9Ay0tMHwhc5W4UTo mtCwLMx8QmydsfOf8fct3GR20/Y5y7E8Kw3VfjDG7oaEo66EQgJlU59n0ZWvmpMIqvTRXY KDjACF3kEmG21kGVtCoYBKBeLv0OlVKTst0l90iKdXXRLE079dHee+AVqQImXxMPitDZE+ 3rAq+3cRIWclHdDEhOxh5Ob/xkf2nAJFDgcrAvzZF2ZXsoIuxcrf3/h+35P0/Q== From: Miquel Raynal To: Rob Herring Cc: Frank Rowand , Thomas Petazzoni , devicetree@vger.kernel.org, , linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Thierry Reding , David Airlie , Daniel Vetter , Mikko Perttunen , Miquel Raynal Subject: [PATCH 1/5] of: module: Mutate of_device_modalias() into two helpers Date: Wed, 10 May 2023 17:47:59 +0200 Message-Id: <20230510154803.189096-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510154803.189096-1-miquel.raynal@bootlin.com> References: <20230510154803.189096-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765523948709218919?= X-GMAIL-MSGID: =?utf-8?q?1765523948709218919?= Move the content of the helper providing printable modaliases in module.c. Call this new function from an of_device.c inline helper. There is no functional changes. However, as a side effect, we fix the return value of the inline helper (in the !CONFIG_OF case) which should be a ssize_t instead of int. Signed-off-by: Miquel Raynal --- drivers/of/device.c | 25 ------------------------- drivers/of/module.c | 19 +++++++++++++++++++ include/linux/of.h | 8 ++++++++ include/linux/of_device.h | 13 ++++++++++--- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 0f00f1b80708..45ce83a8945f 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -246,31 +246,6 @@ const void *of_device_get_match_data(const struct device *dev) } EXPORT_SYMBOL(of_device_get_match_data); -/** - * of_device_modalias - Fill buffer with newline terminated modalias string - * @dev: Calling device - * @str: Modalias string - * @len: Size of @str - */ -ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len) -{ - ssize_t sl; - - if (!dev || !dev->of_node || dev->of_node_reused) - return -ENODEV; - - sl = of_modalias(dev->of_node, str, len - 2); - if (sl < 0) - return sl; - if (sl > len - 2) - return -ENOMEM; - - str[sl++] = '\n'; - str[sl] = 0; - return sl; -} -EXPORT_SYMBOL_GPL(of_device_modalias); - /** * of_device_uevent - Display OF related uevent information * @dev: Device to display the uevent information for diff --git a/drivers/of/module.c b/drivers/of/module.c index 0e8aa974f0f2..c05fb8ca575c 100644 --- a/drivers/of/module.c +++ b/drivers/of/module.c @@ -44,6 +44,25 @@ ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len) return tsize; } +ssize_t of_printable_modalias(const struct device_node *np, char *str, ssize_t len) +{ + ssize_t sl; + + if (!np) + return -ENODEV; + + sl = of_modalias(np, str, len - 2); + if (sl < 0) + return sl; + if (sl > len - 2) + return -ENOMEM; + + str[sl++] = '\n'; + str[sl] = 0; + return sl; +} +EXPORT_SYMBOL_GPL(of_printable_modalias); + int of_request_module(const struct device_node *np) { char *str; diff --git a/include/linux/of.h b/include/linux/of.h index 6ecde0515677..dcdd9396ac37 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -385,6 +385,8 @@ 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 ssize_t of_printable_modalias(const struct device_node *np, char *str, + ssize_t len); extern int of_request_module(const struct device_node *np); /* phandle iterator functions */ @@ -758,6 +760,12 @@ static inline ssize_t of_modalias(const struct device_node *np, char *str, return -ENODEV; } +static inline ssize_t of_printable_modalias(const struct device_node *np, + char *str, ssize_t len) +{ + return -ENODEV; +} + static inline int of_request_module(const struct device_node *np) { return -ENODEV; diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 2c7a3d4bc775..bca66f59814a 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -26,7 +26,14 @@ static inline int of_driver_match_device(struct device *dev, return of_match_device(drv->of_match_table, dev) != NULL; } -extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len); +static inline ssize_t of_device_modalias(struct device *dev, char *str, + ssize_t len) +{ + if (!dev || !dev->of_node || dev->of_node_reused) + return -ENODEV; + + return of_printable_modalias(dev->of_node, str, len); +} extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env); extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env); @@ -51,8 +58,8 @@ static inline int of_driver_match_device(struct device *dev, static inline void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env) { } -static inline int of_device_modalias(struct device *dev, - char *str, ssize_t len) +static inline ssize_t of_device_modalias(struct device *dev, + char *str, ssize_t len) { return -ENODEV; } From patchwork Wed May 10 15:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 92194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3738597vqo; Wed, 10 May 2023 09:06:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BOWNoa0E8Iq3k+/42/GDl5cBlLc//G8AajTF4FB2ctVuD4cJC2nmzZR5atuGkd8P3MOMf X-Received: by 2002:a05:6808:2b09:b0:394:1ffd:463e with SMTP id fe9-20020a0568082b0900b003941ffd463emr2167341oib.25.1683734809143; Wed, 10 May 2023 09:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683734809; cv=none; d=google.com; s=arc-20160816; b=jkoxluqPSN0qNGCudBGfcoWE4G3LUMjNpRVKkCA08zUqKidvllySOnDcKkq7hL3+f5 GaLJ9DEqEu7UCXCgJtT0expwRw9IwEfQatDE5P2azcrmDdLQRPoqbnt2Ll1RtIjPFv1C dr6sRAVzJ09Q13nG6mkQwUCUwYLXGjDUG+1r6MfjiiZX21JcOep8JKD6pEScqpQvj9LN RJXh9xIoev9Qw/ckvnCcQwaQTNuWTQKHbYwQZ1uKjW/+yvBT3CWYTAEqXkSppytmwGQJ jXbXRSQihRiNfd5sULD3xIFUDSTFuYrhYoVYn99EysOSyEEOLfCCZK1XlzSzh3Miai8S av9A== 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=F/KSDSRKpLHcB4gpgTZNIsinLN/YQM+hIOrBqkC1k88=; b=szCnaNVBO9of2tj9djshPSXx0RjMNxFfVNbiswvY+rRefTAUvzmtGq7yocsldjnlcw EAJQVALhHAeFG/Syco6pLXJHsEfj8VS1m2qW3taxVn4/3AUv0Jowpqzcyw/Yi4BxJn5r h9VjWxsXp++shZ3p7J1aPWO6sc2zu5pD0MWbK0FNClFdL3+ap3/Q4gx/SIKWURzRFp2e UcxzE1v4zHd4rV5JRLbYh+8Wv5Waio9KfMwaqx2DwN5BkWQjP44QJvaDjIlRBn6AtCoJ GMckfpBiOaBnNsTXCX37FK+tyJxG+FVyIg7xjH58gOjDR4Uc1xUoxsBksq7FBbzOtgPZ m6wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UyBOIGVD; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r128-20020acac186000000b0038e6978beb7si2986676oif.274.2023.05.10.09.06.14; Wed, 10 May 2023 09:06:49 -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=@bootlin.com header.s=gm1 header.b=UyBOIGVD; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237560AbjEJPsT (ORCPT + 99 others); Wed, 10 May 2023 11:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237320AbjEJPsJ (ORCPT ); Wed, 10 May 2023 11:48:09 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D5C10FA; Wed, 10 May 2023 08:48:07 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 90E59C0005; Wed, 10 May 2023 15:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683733686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F/KSDSRKpLHcB4gpgTZNIsinLN/YQM+hIOrBqkC1k88=; b=UyBOIGVDHTkQ8GTasBO0HB+J1Z++0S2Zw1KtqqxmwJ4aGo1ar2Fehj+YzqCd6nS9aiJGk/ QOiyr4fDBL+t9ntTKIlFiCOfk00S5AjWG/encJ5YI4PUdlSKCTOi15hO6HQjCB5SuTe7Lh HQsVgBhuEYVlvDsCJN2/yLuATuL7TI7gSsZo0nBDvUt0hcSkxvutbWZGDPoR8sYKECBzoi PhppTuKWj0NcjNng2XItbbpsvkn1N3dXJ367S0donGgt2cQYM3f25bYfyqKFgLGxyNgUY9 K9+1jyBXd2FOVnxVI2K6WYNswx6HUfUCQK8VyM62nc8x9N0nFQ9ABQ9+Y46jlw== From: Miquel Raynal To: Rob Herring Cc: Frank Rowand , Thomas Petazzoni , devicetree@vger.kernel.org, , linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Thierry Reding , David Airlie , Daniel Vetter , Mikko Perttunen , Miquel Raynal Subject: [PATCH 2/5] of: module: Mutate of_device_uevent() into two helpers Date: Wed, 10 May 2023 17:48:00 +0200 Message-Id: <20230510154803.189096-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510154803.189096-1-miquel.raynal@bootlin.com> References: <20230510154803.189096-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765523911613877159?= X-GMAIL-MSGID: =?utf-8?q?1765523911613877159?= Move the OF related logic inside of/module.c and use it from of_device.h with an inline helper so there is no visible change from the users point of view. Signed-off-by: Miquel Raynal --- drivers/of/device.c | 42 --------------------------------------- drivers/of/module.c | 41 ++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 6 ++++++ include/linux/of_device.h | 17 +++++++++++++--- 4 files changed, 61 insertions(+), 45 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 45ce83a8945f..5e538e1ed623 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -246,48 +246,6 @@ const void *of_device_get_match_data(const struct device *dev) } EXPORT_SYMBOL(of_device_get_match_data); -/** - * of_device_uevent - Display OF related uevent information - * @dev: Device to display the uevent information for - * @env: Kernel object's userspace event reference to fill up - */ -void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env) -{ - const char *compat, *type; - struct alias_prop *app; - struct property *p; - int seen = 0; - - if ((!dev) || (!dev->of_node)) - return; - - add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node); - add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); - type = of_node_get_device_type(dev->of_node); - if (type) - add_uevent_var(env, "OF_TYPE=%s", type); - - /* Since the compatible field can contain pretty much anything - * it's not really legal to split it out with commas. We split it - * up using a number of environment variables instead. */ - of_property_for_each_string(dev->of_node, "compatible", p, compat) { - add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat); - seen++; - } - add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen); - - seen = 0; - mutex_lock(&of_mutex); - list_for_each_entry(app, &aliases_lookup, link) { - if (dev->of_node == app->np) { - add_uevent_var(env, "OF_ALIAS_%d=%s", seen, - app->alias); - seen++; - } - } - mutex_unlock(&of_mutex); -} - int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env) { int sl; diff --git a/drivers/of/module.c b/drivers/of/module.c index c05fb8ca575c..c729675fdd04 100644 --- a/drivers/of/module.c +++ b/drivers/of/module.c @@ -8,6 +8,8 @@ #include #include +#include "of_private.h" + ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len) { const char *compat; @@ -91,3 +93,42 @@ int of_request_module(const struct device_node *np) return ret; } EXPORT_SYMBOL_GPL(of_request_module); + +int of_uevent(struct device_node *np, struct kobj_uevent_env *env) +{ + const char *compat, *type; + struct alias_prop *app; + struct property *p; + int seen = 0; + + if (!np) + return -ENODEV; + + add_uevent_var(env, "OF_NAME=%pOFn", np); + add_uevent_var(env, "OF_FULLNAME=%pOF", np); + type = of_node_get_device_type(np); + if (type) + add_uevent_var(env, "OF_TYPE=%s", type); + + /* Since the compatible field can contain pretty much anything + * it's not really legal to split it out with commas. We split it + * up using a number of environment variables instead. */ + of_property_for_each_string(np, "compatible", p, compat) { + add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat); + seen++; + } + add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen); + + seen = 0; + mutex_lock(&of_mutex); + list_for_each_entry(app, &aliases_lookup, link) { + if (np == app->np) { + add_uevent_var(env, "OF_ALIAS_%d=%s", seen, + app->alias); + seen++; + } + } + mutex_unlock(&of_mutex); + + return 0; +} diff --git a/include/linux/of.h b/include/linux/of.h index dcdd9396ac37..d99f33fc25d3 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -388,6 +388,7 @@ extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len) extern ssize_t of_printable_modalias(const struct device_node *np, char *str, ssize_t len); extern int of_request_module(const struct device_node *np); +extern int of_uevent(struct device_node *np, struct kobj_uevent_env *env); /* phandle iterator functions */ extern int of_phandle_iterator_init(struct of_phandle_iterator *it, @@ -771,6 +772,11 @@ static inline int of_request_module(const struct device_node *np) return -ENODEV; } +static inline int of_uevent(struct device_node *np, struct kobj_uevent_env *env) +{ + return -ENODEV; +} + static inline int of_phandle_iterator_init(struct of_phandle_iterator *it, const struct device_node *np, const char *list_name, diff --git a/include/linux/of_device.h b/include/linux/of_device.h index bca66f59814a..af5ee78e0c05 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -35,7 +35,15 @@ static inline ssize_t of_device_modalias(struct device *dev, char *str, return of_printable_modalias(dev->of_node, str, len); } -extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env); +static inline int of_device_uevent(const struct device *dev, + struct kobj_uevent_env *env) +{ + if (!dev || !dev->of_node) + return -ENODEV; + + return of_uevent(dev->of_node, env); +} + extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env); int of_dma_configure_id(struct device *dev, @@ -55,8 +63,11 @@ static inline int of_driver_match_device(struct device *dev, return 0; } -static inline void of_device_uevent(const struct device *dev, - struct kobj_uevent_env *env) { } +static inline int of_device_uevent(const struct device *dev, + struct kobj_uevent_env *env) +{ + return -ENODEV; +} static inline ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len) From patchwork Wed May 10 15:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 92196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3739094vqo; Wed, 10 May 2023 09:07:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HJZERhGwA2f84A7c9j2NmEbw85wvluCJo6o/WHXyx+WdihV4+kitjLc5WAyibZpSB791s X-Received: by 2002:a05:6870:956a:b0:187:8260:2f8 with SMTP id v42-20020a056870956a00b00187826002f8mr9758521oal.6.1683734840491; Wed, 10 May 2023 09:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683734840; cv=none; d=google.com; s=arc-20160816; b=ygh544P/HlakWnMLiCXDN/YhmfbqSCQMEqEKCqbFUKYkseiNrsBaM4UAddZGF2fjfW J2j9f5455FK4hJXMPgQcOjw56Cwm7vOb7m1z/fTMsD54NK8HBFEUlo8cry66aIxiE6xC TkFTqOUUbRC/px7WuoSdjbkA+MZksmSCtcHTw5o4mF4V7tO9sbovQoMyzPOuHBdU6cbt zoWbmR39HFYF25amNeOvi+7fG2f5Tq+7yrO1T2iEERdlVamzC62uZrXiu++UcnHklloi 3V02ZcIXhFgWZNQ2A8IwzzxsRgWweAb4XR9ZVvkvK4BP3vvFCGFIfafcZpTBCsP77Kxu yChQ== 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=eTzUAUn2/6zCa90roD3BEhvCRbYoR3aMy4PUneIBrPM=; b=KGkBAR24fRHCSobE82+Gm1xRMSOvkWA4ZP1FF3fzvs6Pibr60Bz3sk/6nUev09u2yY lhOU6LoOcuGQ5S5LTnsvFi/fwlWRJdvUSxnDyiuUVOa0eatK9DkZcMr+hKnjLLZwqD+u +H/L2QGIAmv6+t/o9CerayyNoKAgKNlqw5x6eXbcaJ+6rfE+DFJCbmC+O8p9ULRQT4Vc MV7fDQu3/3dPjth8MgbnUwRHEauC5q4I8CyoyMCqWaMwpMsFwJ1eLyW6nJMbhfQebX9+ LF6sRHy4AJDdf4rZ1+16HF00wDRMad9BLmZ+rUo6rVXRYP+ZRORE98O/P8AHh8zXm65A rBmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UkiDwJ6P; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a056870970d00b0018f57b99467si9675549oaq.288.2023.05.10.09.07.02; Wed, 10 May 2023 09:07:20 -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=@bootlin.com header.s=gm1 header.b=UkiDwJ6P; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237631AbjEJPsY (ORCPT + 99 others); Wed, 10 May 2023 11:48:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237365AbjEJPsL (ORCPT ); Wed, 10 May 2023 11:48:11 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 149DD1BCB; Wed, 10 May 2023 08:48:08 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id A716FC0004; Wed, 10 May 2023 15:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683733687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eTzUAUn2/6zCa90roD3BEhvCRbYoR3aMy4PUneIBrPM=; b=UkiDwJ6PmmRH+dllni1nZppCO1kMi1iL8f0YSzz6HMHb6cDJPNmwTh8WsvIlDrbl1Ewpml JhgPduur1oojt7UZEDpsmRFpFSpSvpaIWASDDMJ5Ve+FT7l/C3A+se09IfN+emu6+OUdLi mZyQQ9NdIIYgn+zM3RQqh2WdLt9pnConqmEEEgHJKM1WxXbbl02tV2LlWxw+lWD8ETYa4Y rJjaHH7kho1KvYF9c9N1qMAtbWb7RP4uHWKLD8DsyfQuKYcJIJms84KTwMLlvgIHAdKeMM KDYkX8tZWSOsfDnSEnL3JVMw6pwKGJelLceNIYpxYqFT9kMWwX3JbWfPl9m3aw== From: Miquel Raynal To: Rob Herring Cc: Frank Rowand , Thomas Petazzoni , devicetree@vger.kernel.org, , linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Thierry Reding , David Airlie , Daniel Vetter , Mikko Perttunen , Miquel Raynal Subject: [PATCH 3/5] of: module: Mutate of_device_uevent_modalias() into two helpers Date: Wed, 10 May 2023 17:48:01 +0200 Message-Id: <20230510154803.189096-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510154803.189096-1-miquel.raynal@bootlin.com> References: <20230510154803.189096-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765523944004030060?= X-GMAIL-MSGID: =?utf-8?q?1765523944004030060?= Let's move the logic of the former helper into module.c and use it from an inline helper located under of_device.c. This way there is no change for users while the logic gets moved to an OF-only file. Signed-off-by: Miquel Raynal --- drivers/of/device.c | 23 ----------------------- drivers/of/module.c | 21 +++++++++++++++++++++ include/linux/of.h | 7 +++++++ include/linux/of_device.h | 9 ++++++++- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 5e538e1ed623..7909eefc650e 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -245,26 +245,3 @@ const void *of_device_get_match_data(const struct device *dev) return match->data; } EXPORT_SYMBOL(of_device_get_match_data); - -int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env) -{ - int sl; - - if ((!dev) || (!dev->of_node) || dev->of_node_reused) - return -ENODEV; - - /* Devicetree modalias is tricky, we add it in 2 steps */ - if (add_uevent_var(env, "MODALIAS=")) - return -ENOMEM; - - sl = of_modalias(dev->of_node, &env->buf[env->buflen-1], - sizeof(env->buf) - env->buflen); - if (sl < 0) - return sl; - if (sl >= (sizeof(env->buf) - env->buflen)) - return -ENOMEM; - env->buflen += sl; - - return 0; -} -EXPORT_SYMBOL_GPL(of_device_uevent_modalias); diff --git a/drivers/of/module.c b/drivers/of/module.c index c729675fdd04..874f3fb8220f 100644 --- a/drivers/of/module.c +++ b/drivers/of/module.c @@ -132,3 +132,24 @@ int of_uevent(struct device_node *np, struct kobj_uevent_env *env) return 0; } + +int of_uevent_modalias(const struct device_node *np, struct kobj_uevent_env *env) +{ + int sl; + + if (!np) + return -ENODEV; + + /* Devicetree modalias is tricky, we add it in 2 steps */ + if (add_uevent_var(env, "MODALIAS=")) + return -ENOMEM; + + sl = of_modalias(np, &env->buf[env->buflen-1], + sizeof(env->buf) - env->buflen); + if (sl >= (sizeof(env->buf) - env->buflen)) + return -ENOMEM; + env->buflen += sl; + + return 0; +} +EXPORT_SYMBOL_GPL(of_uevent_modalias); diff --git a/include/linux/of.h b/include/linux/of.h index d99f33fc25d3..203bd2895d94 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -389,6 +389,7 @@ extern ssize_t of_printable_modalias(const struct device_node *np, char *str, ssize_t len); extern int of_request_module(const struct device_node *np); extern int of_uevent(struct device_node *np, struct kobj_uevent_env *env); +extern int of_uevent_modalias(const struct device_node *np, struct kobj_uevent_env *env); /* phandle iterator functions */ extern int of_phandle_iterator_init(struct of_phandle_iterator *it, @@ -777,6 +778,12 @@ static inline int of_uevent(struct device_node *np, struct kobj_uevent_env *env) return -ENODEV; } +static inline int of_uevent_modalias(const struct device_node *np, + struct kobj_uevent_env *env) +{ + return -ENODEV; +} + static inline int of_phandle_iterator_init(struct of_phandle_iterator *it, const struct device_node *np, const char *list_name, diff --git a/include/linux/of_device.h b/include/linux/of_device.h index af5ee78e0c05..5e428bcf3d63 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -44,7 +44,14 @@ static inline int of_device_uevent(const struct device *dev, return of_uevent(dev->of_node, env); } -extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env); +static inline int of_device_uevent_modalias(const struct device *dev, + struct kobj_uevent_env *env) +{ + if (!dev || !dev->of_node || dev->of_node_reused) + return -ENODEV; + + return of_uevent_modalias(dev->of_node, env); +} int of_dma_configure_id(struct device *dev, struct device_node *np, From patchwork Wed May 10 15:48:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 92192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3730661vqo; Wed, 10 May 2023 08:58:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73bQ4Mt+k/K3Rsa7/ewGYc2/JZqauMGcCgMwL4flZ7UC2N3O/2AipkGR2yfovpg9SeF3It X-Received: by 2002:a17:90a:4214:b0:250:6c4d:e406 with SMTP id o20-20020a17090a421400b002506c4de406mr12476367pjg.22.1683734285843; Wed, 10 May 2023 08:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683734285; cv=none; d=google.com; s=arc-20160816; b=kpO1L7mE8orYCXzmWmBVQCqsZsdYn9JoDxkaUbNGc10q2FdgxmYh2ZQqSkfCmQC93Z LZhcnd9fFciHU7o/84MAuW1kx1RYsk5B23/ue7E2pE/L6K1p9cwBpctbdNfBRYijueQO S9VRry2kdPfuiSNU7/eDJdxGdIiFVS02wDLKqZQUqqQ8AJqhMoc2Pq0v/7eRKRl8gJz5 jCYrcsMDznwXDgw2iQDuc3bhk9B0fVsDCpBtu0CqosJtRL/CC8fGjLY8p6RM4alF8mL8 wc6F2kBugUoJChyiZmLYHQ9bN4kYspiX6YjEzpyYRM1PQVfd2JAFrd20MwXibl9md7uV YBZw== 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=GiIl6qNilxI/2RMNtfGSfbFmkF8Ao7IWY//F7MAhvic=; b=dgco4dZrQ8XJlfQtP2cYXmtrBf8lXQBmqs96mcgxtgam+KgMk/rUovyPswwgbZ6Nei /R8ZK8gK0yZWrvnJbNO7R73TMJLU4iAG3Q6CLVvmBwCC5swpnKwiWyJ5gZ0Vs+8xKpor rDxA238ski6maFfhuPbMt0xUEHxBQLK2I1qL3w2cYy29RHT/pXuGS4+BCrl8gA/ITKZ/ Bf312dGsqZZRHeHe4D10dtZxUtFZj7oaHBIT+MS6hpKZvDi4bcXN3k2GoJ5NmioZQZVE 6SXnFqLV0SaT/2QmMfMtH1TCSk/zqOGpmQiiYZZySYrd2fNgf2zA9fJukGPPjcEmqZmj 1Mcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Pu/WyXGf"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a17090a9f0700b00247bd63c3c5si18094765pjp.37.2023.05.10.08.57.28; Wed, 10 May 2023 08:58:05 -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=@bootlin.com header.s=gm1 header.b="Pu/WyXGf"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237690AbjEJPs2 (ORCPT + 99 others); Wed, 10 May 2023 11:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237470AbjEJPsM (ORCPT ); Wed, 10 May 2023 11:48:12 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34AF3E7C; Wed, 10 May 2023 08:48:11 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id CA6E3C000B; Wed, 10 May 2023 15:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683733689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GiIl6qNilxI/2RMNtfGSfbFmkF8Ao7IWY//F7MAhvic=; b=Pu/WyXGfzdCJsrmdb5oy8iGLmhu5ui/4pT0SytexaZmI/s4yZRRNG5oiAo6Hsy7uTKPE6s VNX9AuNiDlfNYJULsgEMGfR/K+crTTQVolBSzasPXilC7nEweltsmAsq/CyriYhIBoK085 vfJf3I5J0xJ8sW2S7X7cI7KuHf/2ZNG0K2/IYu/l/XYg+GXjoXdrIqoUBDQuIoAL4Gy+39 6IbNTbR8nWI3YIbqwMOqDpbFzlo/RKt5eqiwGnJGmywyrWeY7xa42pfjiq9PHr2pIfZ4XV fxqZ5euP0ZvHd8VMEB3OLO3Tl1xy8/IF7N/IxM4xTl9VBxdTYgH3zeI/HHMG/A== From: Miquel Raynal To: Rob Herring Cc: Frank Rowand , Thomas Petazzoni , devicetree@vger.kernel.org, , linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Thierry Reding , David Airlie , Daniel Vetter , Mikko Perttunen , Miquel Raynal Subject: [PATCH 4/5] of: module: Export of_uevent() Date: Wed, 10 May 2023 17:48:02 +0200 Message-Id: <20230510154803.189096-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510154803.189096-1-miquel.raynal@bootlin.com> References: <20230510154803.189096-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765523362208888740?= X-GMAIL-MSGID: =?utf-8?q?1765523362208888740?= The content of of_uevent() is currently hardcoded in a driver that can be compiled as a module. Nothing prevents of_uevent() to be exported to modules, most of the other helpers in of_device.c actually are.The reason why this helper was not exported is because it has been so far only useful in drivers/base, which is built-in anyway. With the idea of getting rid of the hardcoded implementation of of_uevent() in other places in the kernel, let's export it to GPL modules (very much like its cousins in the same file). Signed-off-by: Miquel Raynal --- drivers/of/module.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/of/module.c b/drivers/of/module.c index 874f3fb8220f..8b402a716951 100644 --- a/drivers/of/module.c +++ b/drivers/of/module.c @@ -132,6 +132,7 @@ int of_uevent(struct device_node *np, struct kobj_uevent_env *env) return 0; } +EXPORT_SYMBOL_GPL(of_uevent); int of_uevent_modalias(const struct device_node *np, struct kobj_uevent_env *env) { From patchwork Wed May 10 15:48:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 92195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3738704vqo; Wed, 10 May 2023 09:06:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4n3e+WMWdHUN456Zc/C7CmdTkapH1/T7+st3sBYBOj075RZIihngHexuEUDo1zoV/zrPVI X-Received: by 2002:a9d:6b13:0:b0:6a6:3f1c:2d66 with SMTP id g19-20020a9d6b13000000b006a63f1c2d66mr3608912otp.12.1683734816821; Wed, 10 May 2023 09:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683734816; cv=none; d=google.com; s=arc-20160816; b=uvKNi5G+t0l5rBOm7iKdnKiqqs/ymBiMcIiiKyURRYGe4L4cokRfrz6C30Irbksb+J aEwSHq9c/45B9TY3qnepejtVNLE/KzD+VLO+HfbMSEVEQl9NmetIgbt+kMu4WvgaWFpu v0LU2bhBql/1eCByAFzjyrxF2IUdtz/iH0i2ylbvGXWC6AkKQLM6lPsI69ZGeFJvaU29 pD7bXzFhW4ptw3/lSgeBngLKytoK8VrYPb3DhpbSCAT4SDnbWQNAy77O4d7aWyfoMA22 tnPKS4wL1zxFYaAPizghiNTPDe+nAOWzsvkGlSMjTlVCxo+tcKDnVYg+HULCtUsOMDps A/XA== 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=o8C8MXrqjqKXj0eKsxGXL9GkrBq/7JcKAOeht6U8KtQ=; b=0+QBzcnlLYEr/XNfHcV6AJnxehyB0jEZ6Nc5rN7571rmJ+P6MaPnJvvy+OKnwFNa0o 3fVnHXcIBlOLguLcb+XJpsSwa/IjkfccQEsk0CDKoD6mD2gsgVsx86fXMVjpDInoZaqx SpQjdEMtInuC5XwUzhbvf/uzYsCr8un/NKqoB53sbuWW3VJ1MLHsQa0Aro49wxroNUgx DiBgyODOpmb4837Em9dmdzaNz+GcfUT1UqbXJ0diIw/WSt83B0McwM6OyzrvtHN9mjF6 S7LqRgu3J0XHOXUdTDhi7ECo3I2PHPTyxC14GDzZwr+Jd8Ie7GCObQQJnFyOf9dM8BjH lZDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jrmGFUr2; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx4-20020a056830600400b006a3e0da9a2asi8353877otb.151.2023.05.10.09.06.22; Wed, 10 May 2023 09:06:56 -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=@bootlin.com header.s=gm1 header.b=jrmGFUr2; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237702AbjEJPsb (ORCPT + 99 others); Wed, 10 May 2023 11:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237496AbjEJPsO (ORCPT ); Wed, 10 May 2023 11:48:14 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4367619B6; Wed, 10 May 2023 08:48:12 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 073A0C000C; Wed, 10 May 2023 15:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683733690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o8C8MXrqjqKXj0eKsxGXL9GkrBq/7JcKAOeht6U8KtQ=; b=jrmGFUr2y+aOVqpJ1iPloWve2lq8N4iHH6SoENv2W/wV94WrcuwK8jOqlG7rPvLt6gckhN gvzm94tlydwTS5IAluF6icZG/5auLBEKIUhgJgnsgZCsJseLP8iZ2duxFoPVJ4FFI8itRm Qqltvlr4+O7bdd/MMgublxvFBUvHaam1Dyc9gIvpT11ca+1kPdL3p56QFa2XGUC9GDbfWR LPr75aieSdqJVFFIkFxE8wtBPDxETpKU28oNQ/9FeOoRq+dpF9Zmn1XihIqsgVtb50GrRw xVSkPb4DRopl5PhnUFfgsGAZWDgZdxOS5uNNF0+QR1Ocw0KLQ5Oq3ITr6KVtvA== From: Miquel Raynal To: Rob Herring Cc: Frank Rowand , Thomas Petazzoni , devicetree@vger.kernel.org, , linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Thierry Reding , David Airlie , Daniel Vetter , Mikko Perttunen , Miquel Raynal Subject: [PATCH 5/5] gpu: host1x: Stop open-coding of_device_uevent() Date: Wed, 10 May 2023 17:48:03 +0200 Message-Id: <20230510154803.189096-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510154803.189096-1-miquel.raynal@bootlin.com> References: <20230510154803.189096-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765523919445479293?= X-GMAIL-MSGID: =?utf-8?q?1765523919445479293?= There is apparently no reasons to open-code of_device_uevent() besides: - The helper receives a struct device while we want to use the of_node member of the struct device *parent*. - of_device_uevent() could not be called by modules because of a missing EXPORT_SYMBOL*(). In practice, the former point is not very constraining, just calling of_device_uevent(dev->parent, ...) would have made the trick. The latter point is more an observation rather than a real blocking point because nothing prevented of_uevent() (called by the inline function of_device_uevent()) to be exported to modules. In practice, this helper is now exported, so nothing prevent us from using of_device_uevent() anymore. Let's use the core helper directly instead of open-coding it. Cc: Thierry Reding Cc: David Airlie Cc: Daniel Vetter Cc: Mikko Perttunen Cc: Rob Herring Cc: Frank Rowand Signed-off-by: Miquel Raynal --- This patch depends on the changes performed earlier in the series under the drivers/of/ folder. --- drivers/gpu/host1x/bus.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 4d16a3396c4a..6434a183fb72 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -338,34 +338,15 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv) return strcmp(dev_name(dev), drv->name) == 0; } +/* + * Note that this is really only needed for backwards compatibility + * with libdrm, which parses this information from sysfs and will + * fail if it can't find the OF_FULLNAME, specifically. + */ static int host1x_device_uevent(const struct device *dev, struct kobj_uevent_env *env) { - struct device_node *np = dev->parent->of_node; - unsigned int count = 0; - struct property *p; - const char *compat; - - /* - * This duplicates most of of_device_uevent(), but the latter cannot - * be called from modules and operates on dev->of_node, which is not - * available in this case. - * - * Note that this is really only needed for backwards compatibility - * with libdrm, which parses this information from sysfs and will - * fail if it can't find the OF_FULLNAME, specifically. - */ - add_uevent_var(env, "OF_NAME=%pOFn", np); - add_uevent_var(env, "OF_FULLNAME=%pOF", np); - - of_property_for_each_string(np, "compatible", p, compat) { - add_uevent_var(env, "OF_COMPATIBLE_%u=%s", count, compat); - count++; - } - - add_uevent_var(env, "OF_COMPATIBLE_N=%u", count); - - return 0; + return of_device_uevent((const struct device *)&dev->parent, env); } static int host1x_dma_configure(struct device *dev)