Skip to content

Commit

Permalink
Bluetooth: hci_sysfs: make bt_class a static const structure
Browse files Browse the repository at this point in the history
Now that the driver core allows for struct class to be in read-only
memory, move the bt_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at load time.

Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
ivanorlov2206 authored and kuba-moo committed Jun 29, 2023
1 parent 14f0dce commit d40d6f5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>

static struct class *bt_class;
static const struct class bt_class = {
.name = "bluetooth",
};

static void bt_link_release(struct device *dev)
{
Expand Down Expand Up @@ -36,7 +38,7 @@ void hci_conn_init_sysfs(struct hci_conn *conn)
BT_DBG("conn %p", conn);

conn->dev.type = &bt_link;
conn->dev.class = bt_class;
conn->dev.class = &bt_class;
conn->dev.parent = &hdev->dev;

device_initialize(&conn->dev);
Expand Down Expand Up @@ -104,20 +106,18 @@ void hci_init_sysfs(struct hci_dev *hdev)
struct device *dev = &hdev->dev;

dev->type = &bt_host;
dev->class = bt_class;
dev->class = &bt_class;

__module_get(THIS_MODULE);
device_initialize(dev);
}

int __init bt_sysfs_init(void)
{
bt_class = class_create("bluetooth");

return PTR_ERR_OR_ZERO(bt_class);
return class_register(&bt_class);
}

void bt_sysfs_cleanup(void)
{
class_destroy(bt_class);
class_unregister(&bt_class);
}

0 comments on commit d40d6f5

Please sign in to comment.