[PATCH] virtio: Staticize and constify driver ops
Tom Rini
trini at konsulko.com
Tue May 19 00:50:21 CEST 2026
On Sun, May 10, 2026 at 07:17:53PM +0200, Marek Vasut wrote:
> Set the ops structure as static const. The structure is not accessible
> from outside of this driver and is not going to be modified at runtime.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> ---
> Cc: "Christian Pötzsch" <christian.poetzsch at kernkonzept.com>
> Cc: Adam Lackorzynski <adam at l4re.org>
> Cc: Bin Meng <bmeng.cn at gmail.com>
> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: u-boot at lists.denx.de
> ---
> drivers/virtio/virtio-uclass.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
> index c36e9e9b3a7..6e4a3d7a7c1 100644
> --- a/drivers/virtio/virtio-uclass.c
> +++ b/drivers/virtio/virtio-uclass.c
> @@ -400,7 +400,7 @@ UCLASS_DRIVER(virtio) = {
> .per_device_auto = sizeof(struct virtio_dev_priv),
> };
>
> -struct bootdev_ops virtio_bootdev_ops = {
> +static const struct bootdev_ops virtio_bootdev_ops = {
> };
>
> static const struct udevice_id virtio_bootdev_ids[] = {
So, this shows off a problem that needs to be handled differently. In
boot/bootdev-uclass.c we can't have ops be null. And moving this to
static const leads to size growth due to the compiler no longer being
able to play some game that it used to do. I'll post a patch shortly
that reworks the function in boot/bootdev-uclass.c and then drops these
empty structs.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260518/1bae3a5e/attachment.sig>
More information about the U-Boot
mailing list