Re: [PATCH v2 11/33] ibmvfc: add wrapper to get vhost associated with a channel struct

From: Dave Marquardt

Date: Wed Jul 29 2026 - 12:07:37 EST


Tyrel Datwyler <tyreld@xxxxxxxxxxxxx> writes:

> +static inline struct ibmvfc_host *ibmvfc_channels_to_vhost(struct ibmvfc_channels *channels)
> +{
> + if (channels->protocol == IBMVFC_PROTO_SCSI)
> + return container_of(channels, struct ibmvfc_host, scsi_scrqs);
> + else if (channels->protocol == IBMVFC_PROTO_NVME)
> + return container_of(channels, struct ibmvfc_host, nvme_scrqs);
> +
> + return NULL;
> +}

Nothing wrong with this, but in looking at the definition of
container_of(), I see this:

* WARNING: any const qualifier of @ptr is lost.
* Do not use container_of() in new code.

And there's now container_of_const(), where I see this:

* Always prefer container_of_const() instead of container_of() in new code.

-Dave