From patchwork Sat Feb 4 22:36:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13128890 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 D0804C61DA4 for ; Sat, 4 Feb 2023 22:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbjBDWhJ (ORCPT ); Sat, 4 Feb 2023 17:37:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjBDWhI (ORCPT ); Sat, 4 Feb 2023 17:37:08 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 793A876AB; Sat, 4 Feb 2023 14:37:07 -0800 (PST) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1675550225; bh=0XwHzWlQO9utV3c23HfF5d3lVc1tHK1hks1/3/+GhYo=; h=From:Date:Subject:To:Cc:From; b=STejYmVfI53D9/kq/WcaYju5UGgGXs1jDerfpfCF40EI9t084D2ECHECqGa7scSIC dGTa7tZ8MzOAygjvy3V57NHU5fQtDAIeWQZtrGHp/8maox9qGPsgINhU4zcvi2lhwr 8VTiK6sk75/FYJ0AyKgUk3uEUWcFC4a+hpFCFGk4= Date: Sat, 04 Feb 2023 22:36:58 +0000 Subject: [PATCH] driver core: make kobj_type structures constant MIME-Version: 1.0 Message-Id: <20230204-kobj_type-driver-core-v1-1-b9f809419f2c@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAAne3mMC/x2N0QrCMAwAf2Xk2UCt1Qd/RUSaNnPR0Y50DmXs3 xd8vIPjVmiswg2u3QrKizSpxeB46CANsTwZJRuDd/7kvAv4rvR6zL+JMassrJiqMl4oEOfgfDw TWEuxMZLGkgary2ccTU7KvXz/s9t923Y4idgTfAAAAA== To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, =?utf-8?q?Thom?= =?utf-8?q?as_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1675550218; l=3049; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=0XwHzWlQO9utV3c23HfF5d3lVc1tHK1hks1/3/+GhYo=; b=xFPR+hJqKZFs5DaJ7n/jPy5Kdyj0cLcKjN2d72v7FvIeoM5SMD0gRQe1mKcUus5/vflKq/N+N m6BwWG7M+3KCJJa/Cha9fxeEq8EP3KAi18o18k2u6r5+2Z3u57x1EK7 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type. Take advantage of this to constify the structure definitions to prevent modification at runtime. Signed-off-by: Thomas Weißschuh --- drivers/base/bus.c | 4 ++-- drivers/base/class.c | 2 +- drivers/base/core.c | 4 ++-- drivers/base/swnode.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) --- base-commit: 95078069c1e70d1b3b141132d18d0c563acedd0c change-id: 20230204-kobj_type-driver-core-6b4bed402a5b Best regards, diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 4ec6dbab73be..f9c05f4c7d1f 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -91,7 +91,7 @@ static void driver_release(struct kobject *kobj) kfree(drv_priv); } -static struct kobj_type driver_ktype = { +static const struct kobj_type driver_ktype = { .sysfs_ops = &driver_sysfs_ops, .release = driver_release, }; @@ -158,7 +158,7 @@ static void bus_release(struct kobject *kobj) bus->p = NULL; } -static struct kobj_type bus_ktype = { +static const struct kobj_type bus_ktype = { .sysfs_ops = &bus_sysfs_ops, .release = bus_release, }; diff --git a/drivers/base/class.c b/drivers/base/class.c index 86ec554cfe60..3a0e8cf8970c 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -75,7 +75,7 @@ static const struct sysfs_ops class_sysfs_ops = { .store = class_attr_store, }; -static struct kobj_type class_ktype = { +static const struct kobj_type class_ktype = { .sysfs_ops = &class_sysfs_ops, .release = class_release, .child_ns_type = class_child_ns_type, diff --git a/drivers/base/core.c b/drivers/base/core.c index a3e14143ec0c..dd17852f1c03 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2354,7 +2354,7 @@ static void device_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t dev->class->get_ownership(dev, uid, gid); } -static struct kobj_type device_ktype = { +static const struct kobj_type device_ktype = { .release = device_release, .sysfs_ops = &dev_sysfs_ops, .namespace = device_namespace, @@ -2992,7 +2992,7 @@ struct kobj_ns_type_operations *class_dir_child_ns_type(const struct kobject *ko return dir->class->ns_type; } -static struct kobj_type class_dir_ktype = { +static const struct kobj_type class_dir_ktype = { .release = class_dir_release, .sysfs_ops = &kobj_sysfs_ops, .child_ns_type = class_dir_child_ns_type diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 0a482212c7e8..81fb6d492c15 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -760,7 +760,7 @@ static void software_node_release(struct kobject *kobj) kfree(swnode); } -static struct kobj_type software_node_type = { +static const struct kobj_type software_node_type = { .release = software_node_release, .sysfs_ops = &kobj_sysfs_ops, };