Danilo Krummrich
2025-Oct-27 09:56 UTC
[PATCH v6 4/5] rust: Move register and bitfield macros out of Nova
On Mon Oct 27, 2025 at 10:06 AM CET, Beata Michalska wrote:> It's more theoretical at this point, but there are drivers that do rely on > information from either DT or ACPI tables for the base address and size of the > MMIO region: anything that uses devm_platform_ioremap_resource() or > devm_platform_ioremap_resource_byname() I guess.Don't get confused, those are two different things: The size of the MMIO region (or a PCI BAR) and the const SIZE generic in Io<SIZE> are two different things. The former is the actual size of an MMIO region, whereas the latter is the minimum size requested by a driver for proper operation. For instance, let's assume your driver requests ten contiguous 32-bit registers starting at offset zero of an MMIO region. In this case you can call req.iomap_sized<0x28>(), because you know that your driver is not able to properly work without an MMIO region with at least a width of 0x28 bytes. The actual size of the MMIO region returned by req.iomap_sized<0x28>() may indeed be smaller or larger than that, depending on what is defined in the DT, ACPI or PCI BAR. If smaller than the const SIZE generic, the call to req.iomap_sized<0x28>() will fail, otherwise it will be successful. The actual size of the MMIO region is not influenced by the const SIZE generic.