From 06b833d57089f4085805978dc750f1ef02d89d6f Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 3 Apr 2023 09:40:59 +0100 Subject: [PATCH] block: virt-storage: tegra: Fix build for Linux v5.14 For Linux v5.14, the function device_add_disk() has a void return type and compilation now fails with ... nvidia-oot/drivers/block/tegra_virt_storage/tegra_hv_vblk.c:1162:8: error: invalid use of void expression 1162 | (void)!device_add_disk(vblkdev->device, vblkdev->gd, NULL); | ^ Fix the build for kernels prior to v5.15 by not attempting to access the return value. Finally, for kernels v5.15 and newer, do not ignore the return value and report an error if device_add_disk() fails. Bug 4052299 Change-Id: I975f30bc67661eacf74634b5edb70e5ad5fc1a8d Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2881453 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- drivers/block/tegra_virt_storage/tegra_hv_vblk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c index 4067f7cc..614d3bff 100644 --- a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c +++ b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c @@ -1159,7 +1159,14 @@ static void setup_device(struct vblk_dev *vblkdev) } set_capacity(vblkdev->gd, (vblkdev->size / SECTOR_SIZE)); - (void)!device_add_disk(vblkdev->device, vblkdev->gd, NULL); +#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE + if (device_add_disk(vblkdev->device, vblkdev->gd, NULL)) { + dev_err(vblkdev->device, "Error adding disk!\n"); + return; + } +#else + device_add_disk(vblkdev->device, vblkdev->gd, NULL); +#endif if (device_create_file(disk_to_dev(vblkdev->gd), &dev_attr_phys_dev_ro)) {