From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 01/16] driver: bus: embed bus driver node into bus
Date: Thu, 5 Jun 2025 23:07:11 +0200 [thread overview]
Message-ID: <20250605210726.1916656-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250605210726.1916656-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 +-
include/driver.h | 2 +-
6 files changed, 9 insertions(+), 10 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/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-05 21:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 21:07 [PATCH 00/16] ARM: stm32mp: add MIPI DSI support Ahmad Fatoum
2025-06-05 21:07 ` Ahmad Fatoum [this message]
2025-06-05 21:07 ` [PATCH 02/16] driver: switch busses to device class Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 03/16] driver: factor out bus definitions into separate header Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 04/16] driver: bus: add helpers for finding devices in busses Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 05/16] drive: bus: make use of new bus_find_device helper Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 06/16] of: implement of_alias_from_compatible Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 07/16] video: vpl: fix potential read of uninitialized variable Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 08/16] video: vpl: factor out vpl_for_each Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 09/16] video: vpl: handle missing struct vpl::ioctl gracefully Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 10/16] video: vpl: add vpl_bridge abstraction Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 11/16] video: factor out drm_mode_vrefresh Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 12/16] video: add base MIPI DSI support Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 13/16] video: add Designware MIPI-DSI support Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 14/16] video: add STM32 MIPI DSI video driver Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 15/16] video: add support for Orise Technology otm8009a panel Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 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=20250605210726.1916656-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