Re: [PATCH v4 07/24] coco/tdx-host: Implement firmware upload sysfs ABI for TDX Module updates

From: Xu Yilun

Date: Thu Feb 26 2026 - 23:56:30 EST


> +static void seamldr_init(struct device *dev)
> +{
> + const struct tdx_sys_info *tdx_sysinfo = tdx_get_sysinfo();
> + int ret;
> +
> + if (WARN_ON_ONCE(!tdx_sysinfo))
> + return;
> +
> + if (!tdx_supports_runtime_update(tdx_sysinfo)) {
> + pr_info("Current TDX Module cannot be updated. Consider BIOS updates\n");
> + return;
> + }
> +
> + tdx_fwl = firmware_upload_register(THIS_MODULE, dev, "tdx_module",
> + &tdx_fw_ops, NULL);
> + ret = PTR_ERR_OR_ZERO(tdx_fwl);
> + if (ret)
> + pr_err("failed to register module uploader %d\n", ret);
> +}
> +
> +static void seamldr_deinit(void)
> +{
> + if (tdx_fwl)
> + firmware_upload_unregister(tdx_fwl);
> +}

You could use devm_add_action_or_reset() in seamldr_init():

1. to delete tdx_host_remove().
2. to delete the global tdx_fwl;

> +
> +static int tdx_host_probe(struct faux_device *fdev)
> +{
> + /*
> + * P-SEAMLDR capabilities are optional. Don't fail the entire
> + * device probe if initialization fails.
> + */
> + seamldr_init(&fdev->dev);
> +
> + return 0;
> +}
> +
> +static void tdx_host_remove(struct faux_device *fdev)
> +{
> + seamldr_deinit();
> +}