From patchwork Mon Nov 21 09:46:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 23626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1482919wrr; Mon, 21 Nov 2022 01:50:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf7z9jgWaOhbUxDbNF1QeVpH+5VfnunyxrO06Zh5T7uQbzvuk5qgG/j/pwkyEZVgujUHQUq2 X-Received: by 2002:a17:907:9116:b0:78a:16ad:8250 with SMTP id p22-20020a170907911600b0078a16ad8250mr3181166ejq.747.1669024224272; Mon, 21 Nov 2022 01:50:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669024224; cv=none; d=google.com; s=arc-20160816; b=jdfq6Upgye4BszidfzbHbqdtRgjQ7/V7FadpMR82V+ubH/Id6oDeiTDKNsQdQxLCc1 m/pBpEJEkR3LT5MzZYB8k6B+AUtkB9J8SIqc9bPJuGSlDPwDWEUaPX2u50MNYQHEiB1x xsNb8TZTQLAqcYN76uOeWi/MpBNPoQ5btSNFaSIGoZDdH9jq8g40Szd5OU2R7AdNxUSR AmBc8P6skQn1r3PuciYkKLgdLLbcm/pVUUQgQ+4Z3gNMeYcr5btc6G0nkGLQjjbC1c/h Su7+JqzwZuAjtoKm6iaJOsLvPhZ4mJePhORWlXDxAJ68OihgyGXmpGUAv3VGoOL3XiX5 PoXA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=KWhEY3OVdsTKn3ba1ByFpJIgLv5erUT5MkOGm9JjXQc=; b=B/fd3ntV7m1FrXb6YbwniaMDeKWYoc166VT5dRuXFqYQXkACbvpjLZuwYqY+SV/Nxq SSJMkkdRtQknB4qABL5f7oUgrHN/VBbYUzhvWf1E/JWtPRYhfXjAgQIKsibEjJ74i2Ug g93RDMt/Y2K9A/AMgxl7bQZv/1pY+U0ywGPg3TezOzTPaFl565Jt2OSJT49lq6TOG50d IOCNnvGfJhbBvEq48iGPjoBgff+E5ZMjHQDlREA7hTOcfkBYhFe5GfRKihYfgkZGBIV6 c/V53+Rj3o53difMQEQA9zBP2F+hAUeCTpMkyYJdMgCV7q5vdzqzl5FbmCV+IaGl3iOF r08w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kRtjkGLc; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs37-20020a1709072d2500b007881b45441asi9364839ejc.721.2022.11.21.01.50.00; Mon, 21 Nov 2022 01:50:24 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=kRtjkGLc; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbiKUJr3 (ORCPT + 99 others); Mon, 21 Nov 2022 04:47:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230419AbiKUJrH (ORCPT ); Mon, 21 Nov 2022 04:47:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D320697362; Mon, 21 Nov 2022 01:47:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 924D6B80DB8; Mon, 21 Nov 2022 09:47:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D55D0C433D6; Mon, 21 Nov 2022 09:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669024023; bh=HIQ2aiXqHffXudy5bIIYyTtVPp45N10Zp+on4Ytbzt0=; h=From:To:Cc:Subject:Date:From; b=kRtjkGLcpaTdluA3MPqMp/OBRucZ44PHfZF34mfgf17QHkP/8YR46Hx5a1OmHu3Qw g0wIN1z30f2VFu1U77SsQhX9sJ2xbc06dCKwkdmPZpStPUOS68E68yqUjdgcz/w2cT pe6PY7zlJEOK+AXvuPmP0FqRNQkYwoLnGxO2KQIQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Trond Myklebust , Anna Schumaker , Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Chuck Lever , Jeff Layton , linux-nfs@vger.kernel.org, bridge@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [PATCH 1/5] kobject: make kobject_get_ownership() take a constant kobject * Date: Mon, 21 Nov 2022 10:46:45 +0100 Message-Id: <20221121094649.1556002-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9144; i=gregkh@linuxfoundation.org; h=from:subject; bh=HIQ2aiXqHffXudy5bIIYyTtVPp45N10Zp+on4Ytbzt0=; b=owGbwMvMwCRo6H6F97bub03G02pJDMnVnuw5ldPS6tKre1+vkzhzoFdmhsH6vHieSzff35Fs1svn eKzSEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABNJMGCY73nXbtrMz9Mbph3mjDrW6H 6W8biNIcOCpR4Jy/NfcTjI9PU2vu+58azV6uJDAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1750098745309561816?= X-GMAIL-MSGID: =?utf-8?q?1750098745309561816?= The call, kobject_get_ownership(), does not modify the kobject passed into it, so make it const. This propagates down into the kobj_type function callbacks so make the kobject passed into them also const, ensuring that nothing in the kobject is being changed here. This helps make it more obvious what calls and callbacks do, and do not, modify structures passed to them. Cc: "Rafael J. Wysocki" Cc: Trond Myklebust Cc: Anna Schumaker Cc: Roopa Prabhu Cc: Nikolay Aleksandrov Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Chuck Lever Cc: Jeff Layton Cc: linux-nfs@vger.kernel.org Cc: bridge@lists.linux-foundation.org Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Acked-by: Nikolay Aleksandrov Acked-by: Rafael J. Wysocki Acked-by: Jakub Kicinski --- drivers/base/class.c | 2 +- drivers/base/core.c | 8 ++++---- fs/nfs/sysfs.c | 4 ++-- include/linux/kobject.h | 8 ++++---- lib/kobject.c | 4 ++-- net/bridge/br_if.c | 2 +- net/core/net-sysfs.c | 8 ++++---- net/sunrpc/sysfs.c | 8 ++++---- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/base/class.c b/drivers/base/class.c index 8ceafb7d0203..86ec554cfe60 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -62,7 +62,7 @@ static void class_release(struct kobject *kobj) kfree(cp); } -static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject *kobj) +static const struct kobj_ns_type_operations *class_child_ns_type(const struct kobject *kobj) { struct subsys_private *cp = to_subsys_private(kobj); struct class *class = cp->class; diff --git a/drivers/base/core.c b/drivers/base/core.c index ab01828fe6c1..a79b99ecf4d8 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2335,7 +2335,7 @@ static void device_release(struct kobject *kobj) kfree(p); } -static const void *device_namespace(struct kobject *kobj) +static const void *device_namespace(const struct kobject *kobj) { const struct device *dev = kobj_to_dev(kobj); const void *ns = NULL; @@ -2346,7 +2346,7 @@ static const void *device_namespace(struct kobject *kobj) return ns; } -static void device_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid) +static void device_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid) { const struct device *dev = kobj_to_dev(kobj); @@ -2986,9 +2986,9 @@ static void class_dir_release(struct kobject *kobj) } static const -struct kobj_ns_type_operations *class_dir_child_ns_type(struct kobject *kobj) +struct kobj_ns_type_operations *class_dir_child_ns_type(const struct kobject *kobj) { - struct class_dir *dir = to_class_dir(kobj); + const struct class_dir *dir = to_class_dir(kobj); return dir->class->ns_type; } diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c index a6f740366963..67a87800b3a9 100644 --- a/fs/nfs/sysfs.c +++ b/fs/nfs/sysfs.c @@ -26,7 +26,7 @@ static void nfs_netns_object_release(struct kobject *kobj) } static const struct kobj_ns_type_operations *nfs_netns_object_child_ns_type( - struct kobject *kobj) + const struct kobject *kobj) { return &net_ns_type_operations; } @@ -130,7 +130,7 @@ static void nfs_netns_client_release(struct kobject *kobj) kfree(c); } -static const void *nfs_netns_client_namespace(struct kobject *kobj) +static const void *nfs_netns_client_namespace(const struct kobject *kobj) { return container_of(kobj, struct nfs_netns_client, kobject)->net; } diff --git a/include/linux/kobject.h b/include/linux/kobject.h index fc40fc81aeb1..d978dbceb50d 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -113,7 +113,7 @@ extern struct kobject * __must_check kobject_get_unless_zero( extern void kobject_put(struct kobject *kobj); extern const void *kobject_namespace(struct kobject *kobj); -extern void kobject_get_ownership(struct kobject *kobj, +extern void kobject_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid); extern char *kobject_get_path(const struct kobject *kobj, gfp_t flag); @@ -121,9 +121,9 @@ struct kobj_type { void (*release)(struct kobject *kobj); const struct sysfs_ops *sysfs_ops; const struct attribute_group **default_groups; - const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj); - const void *(*namespace)(struct kobject *kobj); - void (*get_ownership)(struct kobject *kobj, kuid_t *uid, kgid_t *gid); + const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobject *kobj); + const void *(*namespace)(const struct kobject *kobj); + void (*get_ownership)(const struct kobject *kobj, kuid_t *uid, kgid_t *gid); }; struct kobj_uevent_env { diff --git a/lib/kobject.c b/lib/kobject.c index ba1017cd67d1..26e744a46d24 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -45,7 +45,7 @@ const void *kobject_namespace(struct kobject *kobj) * representation of given kobject. Normally used to adjust ownership of * objects in a container. */ -void kobject_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid) +void kobject_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid) { *uid = GLOBAL_ROOT_UID; *gid = GLOBAL_ROOT_GID; @@ -907,7 +907,7 @@ static void kset_release(struct kobject *kobj) kfree(kset); } -static void kset_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid) +static void kset_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid) { if (kobj->parent) kobject_get_ownership(kobj->parent, uid, gid); diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 228fd5b20f10..ad13b48e3e08 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -262,7 +262,7 @@ static void release_nbp(struct kobject *kobj) kfree(p); } -static void brport_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid) +static void brport_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid) { struct net_bridge_port *p = kobj_to_brport(kobj); diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index a8c5a7cd9701..9cfc80b8ed25 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1020,7 +1020,7 @@ static void rx_queue_release(struct kobject *kobj) netdev_put(queue->dev, &queue->dev_tracker); } -static const void *rx_queue_namespace(struct kobject *kobj) +static const void *rx_queue_namespace(const struct kobject *kobj) { struct netdev_rx_queue *queue = to_rx_queue(kobj); struct device *dev = &queue->dev->dev; @@ -1032,7 +1032,7 @@ static const void *rx_queue_namespace(struct kobject *kobj) return ns; } -static void rx_queue_get_ownership(struct kobject *kobj, +static void rx_queue_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid) { const struct net *net = rx_queue_namespace(kobj); @@ -1623,7 +1623,7 @@ static void netdev_queue_release(struct kobject *kobj) netdev_put(queue->dev, &queue->dev_tracker); } -static const void *netdev_queue_namespace(struct kobject *kobj) +static const void *netdev_queue_namespace(const struct kobject *kobj) { struct netdev_queue *queue = to_netdev_queue(kobj); struct device *dev = &queue->dev->dev; @@ -1635,7 +1635,7 @@ static const void *netdev_queue_namespace(struct kobject *kobj) return ns; } -static void netdev_queue_get_ownership(struct kobject *kobj, +static void netdev_queue_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid) { const struct net *net = netdev_queue_namespace(kobj); diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index c1f559892ae8..1e05a2d723f4 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -31,7 +31,7 @@ static void rpc_sysfs_object_release(struct kobject *kobj) } static const struct kobj_ns_type_operations * -rpc_sysfs_object_child_ns_type(struct kobject *kobj) +rpc_sysfs_object_child_ns_type(const struct kobject *kobj) { return &net_ns_type_operations; } @@ -381,17 +381,17 @@ static void rpc_sysfs_xprt_release(struct kobject *kobj) kfree(xprt); } -static const void *rpc_sysfs_client_namespace(struct kobject *kobj) +static const void *rpc_sysfs_client_namespace(const struct kobject *kobj) { return container_of(kobj, struct rpc_sysfs_client, kobject)->net; } -static const void *rpc_sysfs_xprt_switch_namespace(struct kobject *kobj) +static const void *rpc_sysfs_xprt_switch_namespace(const struct kobject *kobj) { return container_of(kobj, struct rpc_sysfs_xprt_switch, kobject)->net; } -static const void *rpc_sysfs_xprt_namespace(struct kobject *kobj) +static const void *rpc_sysfs_xprt_namespace(const struct kobject *kobj) { return container_of(kobj, struct rpc_sysfs_xprt, kobject)->xprt->xprt_net; From patchwork Mon Nov 21 09:46:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 23625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1482801wrr; Mon, 21 Nov 2022 01:50:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf53Bqb+8+rNa8dvih9zE9k2SSWHQqWTfqIVoIZz7XCqu8r761h/8ugbmj/ZhKjj2351RV9z X-Received: by 2002:a05:6402:3785:b0:461:e598:e0bb with SMTP id et5-20020a056402378500b00461e598e0bbmr15702702edb.21.1669024205802; Mon, 21 Nov 2022 01:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669024205; cv=none; d=google.com; s=arc-20160816; b=uOI5ts8Dd1nsHio5itzNsDFb1UV3DzwifjvodzofxTbaKpPTHbvGlLj7R/Rk4ru6tj HZ0ERjzUnqshf8Q8hklZ8I/BDAvG5cRHlKahuSY9bnnayW/CyxdV64AFq2+rk+Q8OOyg nXnAs9v8e8ibXvPB5aVX5BaiWJSvdjwTdRLzxHsD2N6mnrUXvkjS3ib+JpZCVaDpUa6G ONt4q2albAw0Qb1SD3dTHS9Hl1A1X5n/pfaFGVABAsQgZbBYIiL1wMk24nWHs68r/FQo UB+1cfxPnMOx99dzIegPKveV6E/0TGDyFbKuGNzq8Cs0tmGQZhvQ8+UrIZcB6Nytbf1J EfpQ== 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=Zyri+SBuvgKDYuFX7dN7KbRKRyv5O0A4/sXcofl/3vg=; b=csmLJODU0zWLHX7GI/T1T/EZm/VRXyPVeZc/jqWB6MeCAxjRS3vsng2ujyMctrUf8R 8he8KCnP9AHFyIxKiVGv5ZrP+N9gq8g3bjwGEDcTrljFhApqg/zw42hyovYGQ5twA71E Qk5Gk2w0f1kVlH74NP/dtm8nWk+rJthwIt0a5l3GvjwZqC2mDCbDYF03JeViWi7AVmNL YgNR29tXtAJ1kFIsx1kk0qJF7JktYutHkC4+NncxHJX+sepR/wgxc+3n1WmomAiyNpaH C6xeOdNH9SGPyWeC5RzQLoEQ2QkLwGcPA5OmyY33FF/H6ohzZC7CCi7qDMayRQRCbJQi IQqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PbmKzyJA; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xj10-20020a170906db0a00b007ae286f26b1si9700147ejb.620.2022.11.21.01.49.41; Mon, 21 Nov 2022 01:50:05 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=PbmKzyJA; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230464AbiKUJrS (ORCPT + 99 others); Mon, 21 Nov 2022 04:47:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbiKUJq7 (ORCPT ); Mon, 21 Nov 2022 04:46:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E35C97EF7 for ; Mon, 21 Nov 2022 01:46:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D6C18B80DA1 for ; Mon, 21 Nov 2022 09:46:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD76DC43470; Mon, 21 Nov 2022 09:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669024015; bh=6RxV4EYuvPy7DNNaTcdLjKBIoSdpfXyaOictufStsKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbmKzyJAiZMH7k7Ui8IWm/NFM8pw2iSgk6LI0XsRucF7hljmIqkn4GSUwdETomb0l Wg6XScVHiv7Fb+QE71vFie6vBY8Bu7iJ7yMEfLfuT+N3x4th6qIYkxSP3DVzJfF+K/ KO21tfF5x4P2mFlkLtCOoqmjRv0LoP5RfZjrOCQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH 2/5] kobject: make kobject_namespace take a const * Date: Mon, 21 Nov 2022 10:46:46 +0100 Message-Id: <20221121094649.1556002-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121094649.1556002-1-gregkh@linuxfoundation.org> References: <20221121094649.1556002-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3049; i=gregkh@linuxfoundation.org; h=from:subject; bh=6RxV4EYuvPy7DNNaTcdLjKBIoSdpfXyaOictufStsKc=; b=owGbwMvMwCRo6H6F97bub03G02pJDMnVnhynp5UXFyktfsL8qoJxXdzrC3ydl/peF1YZXV7z6NK/ MO78jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIzwmGBceilz0Q+lb9eNX7TT8sO/ KWLlWsXcEwv8jo8vRHv4vdjby+31SYtl3PaP7nnQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1750098725356219791?= X-GMAIL-MSGID: =?utf-8?q?1750098725356219791?= kobject_namespace() should take a const *kobject as it does not modify the kobject passed to it. Change that, and the functions kobj_child_ns_ops() and kobj_ns_ops() needed to also be changed to const *. Cc: "Rafael J. Wysocki" Signed-off-by: Greg Kroah-Hartman Acked-by: Rafael J. Wysocki --- include/linux/kobject.h | 2 +- include/linux/kobject_ns.h | 4 ++-- lib/kobject.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index d978dbceb50d..5a2d58e10bf5 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -112,7 +112,7 @@ extern struct kobject * __must_check kobject_get_unless_zero( struct kobject *kobj); extern void kobject_put(struct kobject *kobj); -extern const void *kobject_namespace(struct kobject *kobj); +extern const void *kobject_namespace(const struct kobject *kobj); extern void kobject_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid); extern char *kobject_get_path(const struct kobject *kobj, gfp_t flag); diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h index 2b5b64256cf4..be707748e7ce 100644 --- a/include/linux/kobject_ns.h +++ b/include/linux/kobject_ns.h @@ -47,8 +47,8 @@ struct kobj_ns_type_operations { int kobj_ns_type_register(const struct kobj_ns_type_operations *ops); int kobj_ns_type_registered(enum kobj_ns_type type); -const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent); -const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj); +const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *parent); +const struct kobj_ns_type_operations *kobj_ns_ops(const struct kobject *kobj); bool kobj_ns_current_may_mount(enum kobj_ns_type type); void *kobj_ns_grab_current(enum kobj_ns_type type); diff --git a/lib/kobject.c b/lib/kobject.c index 26e744a46d24..6e0bf03f4f36 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -25,7 +25,7 @@ * and thus @kobj should have a namespace tag associated with it. Returns * %NULL otherwise. */ -const void *kobject_namespace(struct kobject *kobj) +const void *kobject_namespace(const struct kobject *kobj) { const struct kobj_ns_type_operations *ns_ops = kobj_ns_ops(kobj); @@ -1039,7 +1039,7 @@ int kobj_ns_type_registered(enum kobj_ns_type type) return registered; } -const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent) +const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *parent) { const struct kobj_ns_type_operations *ops = NULL; @@ -1049,7 +1049,7 @@ const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent) return ops; } -const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj) +const struct kobj_ns_type_operations *kobj_ns_ops(const struct kobject *kobj) { return kobj_child_ns_ops(kobj->parent); } From patchwork Mon Nov 21 09:46:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 23629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1483048wrr; Mon, 21 Nov 2022 01:50:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7iXFeM38dEz8ZueyF0noN74y3y7KOjroQqYadh1ggObD+NwRZBOj2aBItH3pwZg4vfKtLA X-Received: by 2002:a17:906:144e:b0:78d:cd72:8e3e with SMTP id q14-20020a170906144e00b0078dcd728e3emr14234904ejc.212.1669024246644; Mon, 21 Nov 2022 01:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669024246; cv=none; d=google.com; s=arc-20160816; b=Wync4QGMCxG5NHhofEgjFlT1QVOG5yuk0RnE1avM3WmChSh+itVTS7a2tx4a1nZwp+ hjOZXok+5ay7hfebxastQ8lKIJP4D0TCUtT+zmt33BaLHT9hq1N8elvwZFClO137w3V+ h+y+RWpHGn043egIiV6Nc7n9LmLS6nVWEHlYXvdCFBU7GBckEuNfmo+8aRN9HRrUxRAu Tq40ygqRAVyc84U7DypiagpiFeloYyw14DKqMuJqOO6KPK/NJq4gt8fZT1GCV8dQkVjQ S8rTFwiW8Z1qMN6hosSknKgvrhUMsmLmaRFbjqjo/2YvS+tPuIQM76KdZjBrAvZgzrJE B6qQ== 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=x2h5auDptMInuho0OJz+VskZjEY5+yrM1aMumDPmSUw=; b=dkjgTpKPVk6kRzLAgmD92yY+O2WMg2gpQf7Y9adP9vVWdLR8/2Z9s/vK47mAOn/Nm8 fwz1+rlHe3UweKTulYdosTx1UwYWSIn0BcMNyn23HYPkFaKAotgZsCL+5faRi5QUhePy stghJ9o16CToDRwrp1hF8+ilhJAlzlZ8e6HoR/iGJvjdri3CLxdyGD+thostdPH2CYW4 e+o2PcUv1LASf582TlZQ3HU7UkZXfVh40/4JR+82L6v22G502LoHVyeoqMjuHAt9nYsV fWqGwhjbqegiQzWRTais7YCoIkeOv7QLx2+726Zei55++y1HPKGkZPyivUX6HmJfetdG UvVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="LP5Bcu/o"; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ft31-20020a170907801f00b007b299051a9fsi6997438ejc.192.2022.11.21.01.50.21; Mon, 21 Nov 2022 01:50:46 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b="LP5Bcu/o"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230342AbiKUJrU (ORCPT + 99 others); Mon, 21 Nov 2022 04:47:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbiKUJrB (ORCPT ); Mon, 21 Nov 2022 04:47:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 857EDE08D; Mon, 21 Nov 2022 01:47:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24AB960F93; Mon, 21 Nov 2022 09:47:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32F77C433D6; Mon, 21 Nov 2022 09:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669024019; bh=VQZYBH1bhf90ko3Gyb0TeinDWhHpYreu0f9unIS25Zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LP5Bcu/o6ov0sKBaLpR4FOMpj0KiyS6oh9p0I60JpynrFARptBhfmho4EJPJ4/m8m 8P/d6EM/AqaaQLCXJhqPIcFWHodFvsubWuvWx28DPgaLvAZqckMNaKwqG6/tHpp2k2 NhwnVwWHQ5eSkDwvMZ+zEr7bgrLiNVmVBz09kxJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 3/5] kobject: kset_uevent_ops: make filter() callback take a const * Date: Mon, 21 Nov 2022 10:46:47 +0100 Message-Id: <20221121094649.1556002-3-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121094649.1556002-1-gregkh@linuxfoundation.org> References: <20221121094649.1556002-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3268; i=gregkh@linuxfoundation.org; h=from:subject; bh=VQZYBH1bhf90ko3Gyb0TeinDWhHpYreu0f9unIS25Zw=; b=owGbwMvMwCRo6H6F97bub03G02pJDMnVnpyPX3yeVMM/57Desw3BLcVtK7dElz68+Jj/h3hLmCLD i9stHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjAR2ViGBcs28T5zS33/Xe98772MPX fXBXVIsjIsaPjXGMjtXphX9MSuufH7/2k3/JI6AQ== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1750098768078560653?= X-GMAIL-MSGID: =?utf-8?q?1750098768078560653?= The filter() callback in struct kset_uevent_ops does not modify the kobject passed into it, so make the pointer const to enforce this restriction. When doing so, fix up all existing filter() callbacks to have the correct signature to preserve the build. Cc: "Rafael J. Wysocki" Cc: Sumit Semwal Cc: "Christian König" Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linaro-mm-sig@lists.linaro.org Signed-off-by: Greg Kroah-Hartman Acked-by: Christian König for the changes to Acked-by: Rafael J. Wysocki --- drivers/base/bus.c | 2 +- drivers/base/core.c | 4 ++-- drivers/dma-buf/dma-buf-sysfs-stats.c | 2 +- include/linux/kobject.h | 2 +- kernel/params.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 7ca47e5b3c1f..4ec6dbab73be 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -163,7 +163,7 @@ static struct kobj_type bus_ktype = { .release = bus_release, }; -static int bus_uevent_filter(struct kobject *kobj) +static int bus_uevent_filter(const struct kobject *kobj) { const struct kobj_type *ktype = get_ktype(kobj); diff --git a/drivers/base/core.c b/drivers/base/core.c index a79b99ecf4d8..005a2b092f3e 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2362,12 +2362,12 @@ static struct kobj_type device_ktype = { }; -static int dev_uevent_filter(struct kobject *kobj) +static int dev_uevent_filter(const struct kobject *kobj) { const struct kobj_type *ktype = get_ktype(kobj); if (ktype == &device_ktype) { - struct device *dev = kobj_to_dev(kobj); + const struct device *dev = kobj_to_dev(kobj); if (dev->bus) return 1; if (dev->class) diff --git a/drivers/dma-buf/dma-buf-sysfs-stats.c b/drivers/dma-buf/dma-buf-sysfs-stats.c index 2bba0babcb62..f69d68122b9b 100644 --- a/drivers/dma-buf/dma-buf-sysfs-stats.c +++ b/drivers/dma-buf/dma-buf-sysfs-stats.c @@ -132,7 +132,7 @@ void dma_buf_stats_teardown(struct dma_buf *dmabuf) /* Statistics files do not need to send uevents. */ -static int dmabuf_sysfs_uevent_filter(struct kobject *kobj) +static int dmabuf_sysfs_uevent_filter(const struct kobject *kobj) { return 0; } diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 5a2d58e10bf5..640f59d4b3de 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -135,7 +135,7 @@ struct kobj_uevent_env { }; struct kset_uevent_ops { - int (* const filter)(struct kobject *kobj); + int (* const filter)(const struct kobject *kobj); const char *(* const name)(struct kobject *kobj); int (* const uevent)(struct kobject *kobj, struct kobj_uevent_env *env); }; diff --git a/kernel/params.c b/kernel/params.c index 5b92310425c5..d2237209ceda 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -926,7 +926,7 @@ static const struct sysfs_ops module_sysfs_ops = { .store = module_attr_store, }; -static int uevent_filter(struct kobject *kobj) +static int uevent_filter(const struct kobject *kobj) { const struct kobj_type *ktype = get_ktype(kobj); From patchwork Mon Nov 21 09:46:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 23627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1482926wrr; Mon, 21 Nov 2022 01:50:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf50NYhe4dNMbkoRbQ5NZUbbjr4qEDCoXi7wPBJlctGIhy0PYvwQKg7NzPxbPAVNRB7jz9JA X-Received: by 2002:a17:906:590e:b0:78d:5176:c4d2 with SMTP id h14-20020a170906590e00b0078d5176c4d2mr14431976ejq.532.1669024226307; Mon, 21 Nov 2022 01:50:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669024226; cv=none; d=google.com; s=arc-20160816; b=LcTojpjqh11Xt1avzddyA428rrqvdP2EauSzi9XSbmEQPUMSRbeF2d1Lt4Qw0Gnaon DXemceTHtqFOQF3GNmPnEULKx35cZit5ucYaV03lwYLX7GDdLqhUBnAR+RATkCvggqub 89j+TeawU+Cfge9R3heQ/XMJD7kErMSI/wVP8sSapiDLXKSIhlCNKLq5/ASYD3J6UA99 jlQPLZFjuJ8FwCnUFQMAZYsnwq0R211VkUVuiMOsy2PqJ0AMS8BPiudspNDWokt1ilH4 folWTS4t+YLnM8MuB8EV8nio21vFvH6/9ibpsdh+DESCVR9e70LfTjahVitVe0gTt6hM m5iQ== 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=59mqMC1Yis4H0oIPFd89eTz3Uheg0MbofbZety0FoWc=; b=BSIx1UDrxaBHnrn7YhNbgSabj7A7jwHQNUL1/Du7Vp2U2CZvrLpjG69zpBgIRaLfVK 13+Ab5TFQqNX/dJ/7DQOlJany/RQi+rkNi0Z+UfnGtEPjuWW1Am0ggYEB/nd+GcGz/Jw wPUF8UNWi78hEXxeqpSKaxrhTkNbEEz2CnzQAq3Q4uiXRddgN5dVOEmI1jMKG56++gkx E0Wcv8I+vLbgjn2GmIC03Ffl4qNHIDfHakyrTkY9p5lt9AUW4OioS1SLcPOYHXk4Vd4N S4HHOxFoqY2LiKaESqE1kEe2qAkmHe583oTNubU2HomJHfqw1SY9PDIE4R9tspYwKowQ bOBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L3y5fI3H; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a170906824a00b007add0c2ee2csi6803069ejx.924.2022.11.21.01.50.02; Mon, 21 Nov 2022 01:50:26 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=L3y5fI3H; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbiKUJrd (ORCPT + 99 others); Mon, 21 Nov 2022 04:47:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbiKUJrL (ORCPT ); Mon, 21 Nov 2022 04:47:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33093976E6 for ; Mon, 21 Nov 2022 01:47:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BD7F260F97 for ; Mon, 21 Nov 2022 09:47:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A61B8C433D6; Mon, 21 Nov 2022 09:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669024030; bh=30OSs2VXvnYKk84voU7aoJfLuphQsYAap/NSihdjk6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3y5fI3HnODyL+wLsSIb1i7+MEnGVHlZsmhr4OiTey5mwe991Zn2n6KsDGJpNhogK ccA172BTVUlOwweBc3fXn0xkd+aAaGVKT1FVLzApScVizIl/oDByDUiTuCd15BDLLV 4rnYELby7QxByD+UfjHIOkOOMJ7lM3EMCifnW0zw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH 4/5] kobject: kset_uevent_ops: make name() callback take a const * Date: Mon, 21 Nov 2022 10:46:48 +0100 Message-Id: <20221121094649.1556002-4-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121094649.1556002-1-gregkh@linuxfoundation.org> References: <20221121094649.1556002-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1521; i=gregkh@linuxfoundation.org; h=from:subject; bh=30OSs2VXvnYKk84voU7aoJfLuphQsYAap/NSihdjk6E=; b=owGbwMvMwCRo6H6F97bub03G02pJDMnVnpyXPxi/MRZvuzabt/V++LtVr9ZMt9tssfz+pA9rtxTZ aGdO7IhlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJXPRjmJ/LO7uTIyTy7IJ9HIuu7j dgKRF5V8awoMnUbPsVsU/9i1oDz6fdWG+SO3mBOQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1750098746750483259?= X-GMAIL-MSGID: =?utf-8?q?1750098746750483259?= The name() callback in struct kset_uevent_ops does not modify the kobject passed into it, so make the pointer const to enforce this restriction. When doing so, fix up the single existing name() callback to have the correct signature to preserve the build. Cc: "Rafael J. Wysocki" Signed-off-by: Greg Kroah-Hartman Acked-by: Rafael J. Wysocki --- drivers/base/core.c | 4 ++-- include/linux/kobject.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 005a2b092f3e..a3e14143ec0c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2376,9 +2376,9 @@ static int dev_uevent_filter(const struct kobject *kobj) return 0; } -static const char *dev_uevent_name(struct kobject *kobj) +static const char *dev_uevent_name(const struct kobject *kobj) { - struct device *dev = kobj_to_dev(kobj); + const struct device *dev = kobj_to_dev(kobj); if (dev->bus) return dev->bus->name; diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 640f59d4b3de..58a5b75612e3 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -136,7 +136,7 @@ struct kobj_uevent_env { struct kset_uevent_ops { int (* const filter)(const struct kobject *kobj); - const char *(* const name)(struct kobject *kobj); + const char *(* const name)(const struct kobject *kobj); int (* const uevent)(struct kobject *kobj, struct kobj_uevent_env *env); }; From patchwork Mon Nov 21 09:46:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 23628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1482953wrr; Mon, 21 Nov 2022 01:50:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5id42+vw6uOPaMMVMr7+OY0YUkOzbisXZ9UQNUk8THZj7FkVJn/kiBQpxPLx7AMPclLDb4 X-Received: by 2002:a05:6402:538e:b0:468:ea55:ab40 with SMTP id ew14-20020a056402538e00b00468ea55ab40mr14794396edb.323.1669024230805; Mon, 21 Nov 2022 01:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669024230; cv=none; d=google.com; s=arc-20160816; b=DCH6JFXQMTP7ZZ13iHev1LUmOfPx4YPk125fDLYgGLHevoxe1S/qTA/WjASsvrGZRj iKSIRgxA0mTp6fOinqavuB7agD4YT4+ojwysioG+yd22gqqVKqTTSOd80MO8DDLYUaWD Rr650TpcEOOJZUtog1EeZhDAUr5LcqDCKcTj9tPj4Fg9qxG3AEI62pbGoaCv9gfKmpBv NUTw5EC8Hmq9R8NzXCmakPvyCGdIz2CS1JcDpiZmTZrAJXed7doKFjnlk2NnSL3lar4z hSZmAgblXfFEjJN5Tw7IDZgNYOtEU0wRUL9zwz4XVB79FsLTx2m2JaiNqIXIjMOCcKeG QNog== 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=q0PxbRzzi2THihFMiNHDO3mIpPMwUp66OUKrOwuVhyw=; b=WOXdbWu80YlctGrhPKZBVQHlr4OhlwCKMcZrdgMQaWU4ahNzZuS6PGn/pPk0JEmCEd 4p6Zmd5rhsbOgVK6D7/lyjsKe9Z+kWRedQgAbeExxpaHtfezkdzaoY9Vkmkrd0Ay+T7F t9shczk9ul3V5AS2hrPEIFQC39ZC5AXDFeXBair44Tqmi/UcEWaWxe5hUyHzJtY9c8Qf Sy6v0+nPcFKBY3LTUudG3Vn9HFmjjmfCi0jJn1zSytyUXgy7klqa8ddgmgVuNgY7/N4X Z7UARQh7Z//HvsbEMVVdpO/9TTGP3xyQTDEVtPwmlW51oONnjkIcNs4dfopRpP1pBEN3 CUDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IsXkM6S0; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji22-20020a170907981600b007adf16570c3si4669983ejc.17.2022.11.21.01.50.05; Mon, 21 Nov 2022 01:50:30 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=IsXkM6S0; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbiKUJrh (ORCPT + 99 others); Mon, 21 Nov 2022 04:47:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230433AbiKUJrQ (ORCPT ); Mon, 21 Nov 2022 04:47:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0304976ED; Mon, 21 Nov 2022 01:47:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6042F60FA5; Mon, 21 Nov 2022 09:47:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EA49C433C1; Mon, 21 Nov 2022 09:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669024033; bh=gmfaWGBSorIYw4Zwv5/28r4h97AtvcQ5z5+f8XvcvKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IsXkM6S0Q5gHIt2WC6JfP9kkxoBLjduIwsWgNBO0HsHmrrISN3lUCKmLbWiPkPLOy rJay10xnOPbXzmUlOFsA5FYTt7IfxffQgYSjJPJ2eCRB7KOhuevM42OjseGKo8EtjN UjjwP5VXWOBHM6w2bNjrZ36JTuMxJbE6X4dGO9u4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Rob Herring , Frank Rowand , devicetree@vger.kernel.org Subject: [PATCH 5/5] driver core: pass a const * into of_device_uevent() Date: Mon, 21 Nov 2022 10:46:49 +0100 Message-Id: <20221121094649.1556002-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121094649.1556002-1-gregkh@linuxfoundation.org> References: <20221121094649.1556002-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2328; i=gregkh@linuxfoundation.org; h=from:subject; bh=gmfaWGBSorIYw4Zwv5/28r4h97AtvcQ5z5+f8XvcvKs=; b=owGbwMvMwCRo6H6F97bub03G02pJDMnVnpx5T7Ju3t5s9dnoy+EDZYYtHicKhRtu9wXwN18qPOXX z1jeEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABOZvpphwZKtfN5/Q9rbAlzYmwLnSX YdtXt+lWEOF2vo6utq0m8Lbm5r3poysetq8mRLAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1750098751540599163?= X-GMAIL-MSGID: =?utf-8?q?1750098751540599163?= of_device_uevent() does not modify the struct device * passed into it, so make it a const * to enforce this. Also the documentation for the function was really wrong so fix that up at the same time. Cc: Rob Herring Cc: Frank Rowand Cc: devicetree@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/of/device.c | 6 +++--- include/linux/of_device.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 8cefe5a7d04e..c674a13c3055 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -332,10 +332,10 @@ EXPORT_SYMBOL_GPL(of_device_modalias); /** * of_device_uevent - Display OF related uevent information - * @dev: Device to apply DMA configuration - * @env: Kernel object's userspace event reference + * @dev: Device to display the uevent information for + * @env: Kernel object's userspace event reference to fill up */ -void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) +void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env) { const char *compat, *type; struct alias_prop *app; diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 1a803e4335d3..ab7d557d541d 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -35,7 +35,7 @@ extern const void *of_device_get_match_data(const struct device *dev); extern ssize_t of_device_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 void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env); extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env); static inline struct device_node *of_cpu_device_node_get(int cpu) @@ -64,7 +64,7 @@ static inline int of_driver_match_device(struct device *dev, return 0; } -static inline void of_device_uevent(struct device *dev, +static inline void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env) { } static inline const void *of_device_get_match_data(const struct device *dev)