From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH v2 01/16] driver: bus: embed bus driver node into bus
Date: Fri, 6 Jun 2025 07:57:33 +0200 [thread overview]
Message-ID: <20250606055748.1990383-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250606055748.1990383-1-a.fatoum@barebox.org>
Instead of keeping the bus device in a separate allocation, fold it into
the bus struct itself.
The benefit is that this would allow us to arrive at the bus from the
device and thus be able to chain them using device classes.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
commands/devinfo.c | 2 +-
common/tlv/bus.c | 4 ++--
drivers/amba/bus.c | 2 +-
drivers/base/bus.c | 7 +++----
drivers/base/driver.c | 2 +-
drivers/bus/acpi.c | 12 ++++++------
drivers/efi/efi-device.c | 14 +++++++-------
include/driver.h | 2 +-
8 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/commands/devinfo.c b/commands/devinfo.c
index b1918787a3b6..3c791e4464ac 100644
--- a/commands/devinfo.c
+++ b/commands/devinfo.c
@@ -84,7 +84,7 @@ static int do_devinfo(int argc, char *argv[])
devinfo(dev);
- if (dev->parent && (!dev->bus || dev->bus->dev != dev->parent))
+ if (dev->parent && (!dev->bus || &dev->bus->dev != dev->parent))
printf("Parent: %s\n", dev_name(dev->parent));
first = true;
diff --git a/common/tlv/bus.c b/common/tlv/bus.c
index ab0f4f8b82aa..62d7b7504576 100644
--- a/common/tlv/bus.c
+++ b/common/tlv/bus.c
@@ -29,7 +29,7 @@ struct tlv_device *tlv_register_device(struct tlv_header *header,
devinfo_add(dev, tlv_devinfo);
dev->platform_data = header;
tlvdev->magic = be32_to_cpu(header->magic);
- dev->parent = parent ?: tlv_bus.dev;
+ dev->parent = parent ?: &tlv_bus.dev;
dev->id = DEVICE_ID_SINGLE;
if (parent)
@@ -122,7 +122,7 @@ static int tlv_bus_register(void)
if (ret)
return ret;
- devinfo_add(tlv_bus.dev, tlv_bus_info);
+ devinfo_add(&tlv_bus.dev, tlv_bus_info);
return 0;
}
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 8d6525cca967..4e10dd72368f 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -143,7 +143,7 @@ int amba_device_add(struct amba_device *dev)
cid = amba_device_get_cid(tmp, size);
if (IS_ENABLED(CONFIG_ARM_AMBA_DABT_MASK) && data_abort_unmask()) {
- dev_err(amba_bustype.dev,
+ dev_err(&amba_bustype.dev,
"data abort during MMIO read of PID/CID for %pOF\n",
dev->dev.of_node);
ret = -EFAULT;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 58fcd2e032da..6a4e654b3cea 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -30,11 +30,10 @@ int bus_register(struct bus_type *bus)
if (get_bus_by_name(bus->name))
return -EEXIST;
- bus->dev = xzalloc(sizeof(*bus->dev));
- dev_set_name(bus->dev, bus->name);
- bus->dev->id = DEVICE_ID_SINGLE;
+ dev_set_name(&bus->dev, bus->name);
+ bus->dev.id = DEVICE_ID_SINGLE;
- ret = register_device(bus->dev);
+ ret = register_device(&bus->dev);
if (ret)
return ret;
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 2192ba9812cb..21bf88a74e50 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -269,7 +269,7 @@ int register_device(struct device *new_device)
if (new_device->bus) {
if (!new_device->parent)
- new_device->parent = new_device->bus->dev;
+ new_device->parent = &new_device->bus->dev;
list_add_tail(&new_device->bus_list, &new_device->bus->device_list);
diff --git a/drivers/bus/acpi.c b/drivers/bus/acpi.c
index 92325c16e234..f586b605d0d4 100644
--- a/drivers/bus/acpi.c
+++ b/drivers/bus/acpi.c
@@ -138,7 +138,7 @@ static struct device *acpi_add_device(struct bus_type *bus,
dev = xzalloc(sizeof(*dev));
dev->bus = bus;
- dev->parent = bus->dev;
+ dev->parent = &bus->dev;
dev->id = DEVICE_ID_DYNAMIC;
devinfo_add(dev, acpi_devinfo);
@@ -149,7 +149,7 @@ static struct device *acpi_add_device(struct bus_type *bus,
static int acpi_register_devices(struct bus_type *bus)
{
- struct efi_config_table *table = bus->dev->priv;
+ struct efi_config_table *table = bus->dev.priv;
struct acpi_rsdp *rsdp;
struct acpi_rsdt *root;
size_t entry_count;
@@ -165,7 +165,7 @@ static int acpi_register_devices(struct bus_type *bus)
* 5.2.5.2 Finding the RSDP on UEFI Enabled Systems
*/
if (memcmp("RSD PTR ", rsdp->signature, sizeof(rsdp->signature))) {
- dev_dbg(bus->dev, "unexpected signature at start of config table: '%.8s'\n",
+ dev_dbg(&bus->dev, "unexpected signature at start of config table: '%.8s'\n",
rsdp->signature);
return -ENODEV;
}
@@ -183,12 +183,12 @@ static int acpi_register_devices(struct bus_type *bus)
}
if (acpi_sigcmp(sig, root->sdt.signature)) {
- dev_err(bus->dev, "Expected %s, but found '%.4s'.\n",
+ dev_err(&bus->dev, "Expected %s, but found '%.4s'.\n",
sig, root->sdt.signature);
return -EIO;
}
- dev_info(bus->dev, "Found %s (OEM: %.8s) with %zu entries\n",
+ dev_info(&bus->dev, "Found %s (OEM: %.8s) with %zu entries\n",
sig, root->sdt.oem_id, entry_count);
for (i = 0; i < entry_count; i++) {
@@ -232,7 +232,7 @@ static int efi_acpi_probe(void)
if (!table)
return 0;
- acpi_bus.dev->priv = table;
+ acpi_bus.dev.priv = table;
return acpi_register_devices(&acpi_bus);
}
postcore_efi_initcall(efi_acpi_probe);
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index d5eda66cd55a..46328d12bcdf 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -418,17 +418,17 @@ static int efi_init_devices(void)
bus_register(&efi_bus);
- dev_add_param_fixed(efi_bus.dev, "fw_vendor", fw_vendor);
+ dev_add_param_fixed(&efi_bus.dev, "fw_vendor", fw_vendor);
free(fw_vendor);
- dev_add_param_uint32_fixed(efi_bus.dev, "major", sys_major, "%u");
- dev_add_param_uint32_fixed(efi_bus.dev, "minor", sys_minor, "%u");
- dev_add_param_uint32_fixed(efi_bus.dev, "fw_revision", efi_sys_table->fw_revision, "%u");
- dev_add_param_bool_fixed(efi_bus.dev, "secure_boot", secure_boot);
- dev_add_param_bool_fixed(efi_bus.dev, "secure_mode",
+ dev_add_param_uint32_fixed(&efi_bus.dev, "major", sys_major, "%u");
+ dev_add_param_uint32_fixed(&efi_bus.dev, "minor", sys_minor, "%u");
+ dev_add_param_uint32_fixed(&efi_bus.dev, "fw_revision", efi_sys_table->fw_revision, "%u");
+ dev_add_param_bool_fixed(&efi_bus.dev, "secure_boot", secure_boot);
+ dev_add_param_bool_fixed(&efi_bus.dev, "secure_mode",
secure_boot & setup_mode);
- devinfo_add(efi_bus.dev, efi_businfo);
+ devinfo_add(&efi_bus.dev, efi_businfo);
efi_register_devices();
diff --git a/include/driver.h b/include/driver.h
index e9a919f9bbb5..c6b7b37aa00f 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -358,7 +358,7 @@ struct bus_type {
int (*probe)(struct device *dev);
void (*remove)(struct device *dev);
- struct device *dev;
+ struct device dev;
struct list_head list;
struct list_head device_list;
--
2.39.5
next prev parent reply other threads:[~2025-06-06 5:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 5:57 [PATCH v2 00/16] ARM: stm32mp: add MIPI DSI support Ahmad Fatoum
2025-06-06 5:57 ` Ahmad Fatoum [this message]
2025-06-06 5:57 ` [PATCH v2 02/16] driver: switch busses to device class Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 03/16] driver: factor out bus definitions into separate header Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 04/16] driver: bus: add helpers for finding devices in busses Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 05/16] drive: bus: make use of new bus_find_device helper Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 06/16] of: implement of_alias_from_compatible Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 07/16] video: vpl: fix potential read of uninitialized variable Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 08/16] video: vpl: factor out vpl_for_each Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 09/16] video: vpl: handle missing struct vpl::ioctl gracefully Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 10/16] video: vpl: add vpl_bridge abstraction Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 11/16] video: factor out drm_mode_vrefresh Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 12/16] video: add base MIPI DSI support Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 13/16] video: add Designware MIPI-DSI support Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 14/16] video: add STM32 MIPI DSI video driver Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 15/16] video: add support for Orise Technology otm8009a panel Ahmad Fatoum
2025-06-06 5:57 ` [PATCH v2 16/16] ARM: stm32mp: dk2: enable MIPI-DSI display by default Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250606055748.1990383-2-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox