Re: [PATCH v6 01/25] virt: coco: change tsm_register() to use a const struct
From: Jonathan Cameron
Date: Wed Nov 11 2026 - 21:47:02 EST
On Tue, 10 Nov 2026 14:18:08 +1000
alistair23@xxxxxxxxx wrote:
> From: Alistair Francis <alistair.francis@xxxxxxx>
>
> The tsm_register() function takes a struct pci_tsm_ops *ops argument.
> This eventually is stored in struct tsm_dev as a const, so we should
> just change the tsm_register() register function argument to be a const.
>
> Signed-off-by: Alistair Francis <alistair.francis@xxxxxxx>
An ops structure that is just function pointers definitely wants to
be const (and it would be a less than ideal design if it mixed
other things with those function pointers!).
Makes sense as a stand alone change. Maybe one that can be picked
up sooner than the rest?
Reviewed-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>
> ---
> drivers/crypto/ccp/sev-dev-tsm.c | 2 +-
> drivers/virt/coco/tsm-core.c | 4 ++--
> include/linux/tsm.h | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev-tsm.c b/drivers/crypto/ccp/sev-dev-tsm.c
> index 46f2539d2d5ab..48df8c579c74d 100644
> --- a/drivers/crypto/ccp/sev-dev-tsm.c
> +++ b/drivers/crypto/ccp/sev-dev-tsm.c
> @@ -339,7 +339,7 @@ static void dsm_disconnect(struct pci_dev *pdev)
> streams_teardown(dev_data->ide);
> }
>
> -static struct pci_tsm_ops sev_tsm_ops = {
> +static const struct pci_tsm_ops sev_tsm_ops = {
> .probe = dsm_probe,
> .remove = dsm_remove,
> .connect = dsm_connect,
> diff --git a/drivers/virt/coco/tsm-core.c b/drivers/virt/coco/tsm-core.c
> index e784993353d8f..6b735ac2a814e 100644
> --- a/drivers/virt/coco/tsm-core.c
> +++ b/drivers/virt/coco/tsm-core.c
> @@ -57,7 +57,7 @@ static struct tsm_dev *alloc_tsm_dev(struct device *parent)
> }
>
> static struct tsm_dev *tsm_register_pci_or_reset(struct tsm_dev *tsm_dev,
> - struct pci_tsm_ops *pci_ops)
> + const struct pci_tsm_ops *pci_ops)
> {
> int rc;
>
> @@ -78,7 +78,7 @@ static struct tsm_dev *tsm_register_pci_or_reset(struct tsm_dev *tsm_dev,
> return tsm_dev;
> }
>
> -struct tsm_dev *tsm_register(struct device *parent, struct pci_tsm_ops *pci_ops)
> +struct tsm_dev *tsm_register(struct device *parent, const struct pci_tsm_ops *pci_ops)
> {
> struct tsm_dev *tsm_dev __free(put_tsm_dev) = alloc_tsm_dev(parent);
> struct device *dev;
> diff --git a/include/linux/tsm.h b/include/linux/tsm.h
> index 381c53244c835..6ac12de8c4d36 100644
> --- a/include/linux/tsm.h
> +++ b/include/linux/tsm.h
> @@ -120,7 +120,7 @@ DEFINE_FREE(put_tsm_dev, struct tsm_dev *,
>
> int tsm_report_register(const struct tsm_report_ops *ops, void *priv);
> int tsm_report_unregister(const struct tsm_report_ops *ops);
> -struct tsm_dev *tsm_register(struct device *parent, struct pci_tsm_ops *ops);
> +struct tsm_dev *tsm_register(struct device *parent, const struct pci_tsm_ops *ops);
> void tsm_unregister(struct tsm_dev *tsm_dev);
> struct tsm_dev *find_tsm_dev(int id);
> #endif /* __TSM_H */