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

Dave Marquardt <[email protected]> Wed, 29 Jul 2026 10:31:01 -0500
Newsgroups org.ozlabs.lists.linuxppc-dev,org.kernel.vger.linux-kernel,org.kernel.vger.linux-scsi
Message-ID <[email protected]>
Tyrel Datwyler <[email protected]> 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