Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: cxlflash: Fix function pointer cast warnings

Calling a function through an incompatible pointer type causes breaks kcfi,
so clang warns about the assignments:

drivers/scsi/cxlflash/main.c:3498:3: error: cast from 'int (*)(struct cxlflash_cfg *, struct ht_cxlflash_lun_provision *)' to 'hioctl' (aka 'int (*)(struct cxlflash_cfg *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
3498 | (hioctl)cxlflash_lun_provision },
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/cxlflash/main.c:3500:3: error: cast from 'int (*)(struct cxlflash_cfg *, struct ht_cxlflash_afu_debug *)' to 'hioctl' (aka 'int (*)(struct cxlflash_cfg *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
3500 | (hioctl)cxlflash_afu_debug },
| ^~~~~~~~~~~~~~~~~~~~~~~~~~

Address these by changing the functions to have the correct type and
replace the function pointer cast with a cast of its argument.

Link: https://lore.kernel.org/lkml/20240326145140.3257163-6-arnd@kernel.org/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240404161524.3473857-1-arnd@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Arnd Bergmann and committed by
Martin K. Petersen
28fc2bd2 33507b39

+38 -46
+3 -3
drivers/scsi/cxlflash/lunmgt.c
··· 216 216 /** 217 217 * cxlflash_manage_lun() - handles LUN management activities 218 218 * @sdev: SCSI device associated with LUN. 219 - * @manage: Manage ioctl data structure. 219 + * @arg: Manage ioctl data structure. 220 220 * 221 221 * This routine is used to notify the driver about a LUN's WWID and associate 222 222 * SCSI devices (sdev) with a global LUN instance. Additionally it serves to ··· 224 224 * 225 225 * Return: 0 on success, -errno on failure 226 226 */ 227 - int cxlflash_manage_lun(struct scsi_device *sdev, 228 - struct dk_cxlflash_manage_lun *manage) 227 + int cxlflash_manage_lun(struct scsi_device *sdev, void *arg) 229 228 { 229 + struct dk_cxlflash_manage_lun *manage = arg; 230 230 struct cxlflash_cfg *cfg = shost_priv(sdev->host); 231 231 struct device *dev = &cfg->dev->dev; 232 232 struct llun_info *lli = NULL;
+8 -10
drivers/scsi/cxlflash/main.c
··· 3280 3280 /** 3281 3281 * cxlflash_lun_provision() - host LUN provisioning handler 3282 3282 * @cfg: Internal structure associated with the host. 3283 - * @lunprov: Kernel copy of userspace ioctl data structure. 3283 + * @arg: Kernel copy of userspace ioctl data structure. 3284 3284 * 3285 3285 * Return: 0 on success, -errno on failure 3286 3286 */ 3287 - static int cxlflash_lun_provision(struct cxlflash_cfg *cfg, 3288 - struct ht_cxlflash_lun_provision *lunprov) 3287 + static int cxlflash_lun_provision(struct cxlflash_cfg *cfg, void *arg) 3289 3288 { 3289 + struct ht_cxlflash_lun_provision *lunprov = arg; 3290 3290 struct afu *afu = cfg->afu; 3291 3291 struct device *dev = &cfg->dev->dev; 3292 3292 struct sisl_ioarcb rcb; ··· 3371 3371 /** 3372 3372 * cxlflash_afu_debug() - host AFU debug handler 3373 3373 * @cfg: Internal structure associated with the host. 3374 - * @afu_dbg: Kernel copy of userspace ioctl data structure. 3374 + * @arg: Kernel copy of userspace ioctl data structure. 3375 3375 * 3376 3376 * For debug requests requiring a data buffer, always provide an aligned 3377 3377 * (cache line) buffer to the AFU to appease any alignment requirements. 3378 3378 * 3379 3379 * Return: 0 on success, -errno on failure 3380 3380 */ 3381 - static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, 3382 - struct ht_cxlflash_afu_debug *afu_dbg) 3381 + static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, void *arg) 3383 3382 { 3383 + struct ht_cxlflash_afu_debug *afu_dbg = arg; 3384 3384 struct afu *afu = cfg->afu; 3385 3385 struct device *dev = &cfg->dev->dev; 3386 3386 struct sisl_ioarcb rcb; ··· 3494 3494 size_t size; 3495 3495 hioctl ioctl; 3496 3496 } ioctl_tbl[] = { /* NOTE: order matters here */ 3497 - { sizeof(struct ht_cxlflash_lun_provision), 3498 - (hioctl)cxlflash_lun_provision }, 3499 - { sizeof(struct ht_cxlflash_afu_debug), 3500 - (hioctl)cxlflash_afu_debug }, 3497 + { sizeof(struct ht_cxlflash_lun_provision), cxlflash_lun_provision }, 3498 + { sizeof(struct ht_cxlflash_afu_debug), cxlflash_afu_debug }, 3501 3499 }; 3502 3500 3503 3501 /* Hold read semaphore so we can drain if needed */
+19 -21
drivers/scsi/cxlflash/superpipe.c
··· 729 729 return rc; 730 730 } 731 731 732 - int cxlflash_disk_release(struct scsi_device *sdev, 733 - struct dk_cxlflash_release *release) 732 + int cxlflash_disk_release(struct scsi_device *sdev, void *release) 734 733 { 735 734 return _cxlflash_disk_release(sdev, NULL, release); 736 735 } ··· 954 955 return rc; 955 956 } 956 957 957 - static int cxlflash_disk_detach(struct scsi_device *sdev, 958 - struct dk_cxlflash_detach *detach) 958 + static int cxlflash_disk_detach(struct scsi_device *sdev, void *detach) 959 959 { 960 960 return _cxlflash_disk_detach(sdev, NULL, detach); 961 961 } ··· 1303 1305 /** 1304 1306 * cxlflash_disk_attach() - attach a LUN to a context 1305 1307 * @sdev: SCSI device associated with LUN. 1306 - * @attach: Attach ioctl data structure. 1308 + * @arg: Attach ioctl data structure. 1307 1309 * 1308 1310 * Creates a context and attaches LUN to it. A LUN can only be attached 1309 1311 * one time to a context (subsequent attaches for the same context/LUN pair ··· 1312 1314 * 1313 1315 * Return: 0 on success, -errno on failure 1314 1316 */ 1315 - static int cxlflash_disk_attach(struct scsi_device *sdev, 1316 - struct dk_cxlflash_attach *attach) 1317 + static int cxlflash_disk_attach(struct scsi_device *sdev, void *arg) 1317 1318 { 1319 + struct dk_cxlflash_attach *attach = arg; 1318 1320 struct cxlflash_cfg *cfg = shost_priv(sdev->host); 1319 1321 struct device *dev = &cfg->dev->dev; 1320 1322 struct afu *afu = cfg->afu; ··· 1619 1621 /** 1620 1622 * cxlflash_afu_recover() - initiates AFU recovery 1621 1623 * @sdev: SCSI device associated with LUN. 1622 - * @recover: Recover ioctl data structure. 1624 + * @arg: Recover ioctl data structure. 1623 1625 * 1624 1626 * Only a single recovery is allowed at a time to avoid exhausting CXL 1625 1627 * resources (leading to recovery failure) in the event that we're up ··· 1646 1648 * 1647 1649 * Return: 0 on success, -errno on failure 1648 1650 */ 1649 - static int cxlflash_afu_recover(struct scsi_device *sdev, 1650 - struct dk_cxlflash_recover_afu *recover) 1651 + static int cxlflash_afu_recover(struct scsi_device *sdev, void *arg) 1651 1652 { 1653 + struct dk_cxlflash_recover_afu *recover = arg; 1652 1654 struct cxlflash_cfg *cfg = shost_priv(sdev->host); 1653 1655 struct device *dev = &cfg->dev->dev; 1654 1656 struct llun_info *lli = sdev->hostdata; ··· 1827 1829 /** 1828 1830 * cxlflash_disk_verify() - verifies a LUN is the same and handle size changes 1829 1831 * @sdev: SCSI device associated with LUN. 1830 - * @verify: Verify ioctl data structure. 1832 + * @arg: Verify ioctl data structure. 1831 1833 * 1832 1834 * Return: 0 on success, -errno on failure 1833 1835 */ 1834 - static int cxlflash_disk_verify(struct scsi_device *sdev, 1835 - struct dk_cxlflash_verify *verify) 1836 + static int cxlflash_disk_verify(struct scsi_device *sdev, void *arg) 1836 1837 { 1838 + struct dk_cxlflash_verify *verify = arg; 1837 1839 int rc = 0; 1838 1840 struct ctx_info *ctxi = NULL; 1839 1841 struct cxlflash_cfg *cfg = shost_priv(sdev->host); ··· 2109 2111 size_t size; 2110 2112 sioctl ioctl; 2111 2113 } ioctl_tbl[] = { /* NOTE: order matters here */ 2112 - {sizeof(struct dk_cxlflash_attach), (sioctl)cxlflash_disk_attach}, 2114 + {sizeof(struct dk_cxlflash_attach), cxlflash_disk_attach}, 2113 2115 {sizeof(struct dk_cxlflash_udirect), cxlflash_disk_direct_open}, 2114 - {sizeof(struct dk_cxlflash_release), (sioctl)cxlflash_disk_release}, 2115 - {sizeof(struct dk_cxlflash_detach), (sioctl)cxlflash_disk_detach}, 2116 - {sizeof(struct dk_cxlflash_verify), (sioctl)cxlflash_disk_verify}, 2117 - {sizeof(struct dk_cxlflash_recover_afu), (sioctl)cxlflash_afu_recover}, 2118 - {sizeof(struct dk_cxlflash_manage_lun), (sioctl)cxlflash_manage_lun}, 2116 + {sizeof(struct dk_cxlflash_release), cxlflash_disk_release}, 2117 + {sizeof(struct dk_cxlflash_detach), cxlflash_disk_detach}, 2118 + {sizeof(struct dk_cxlflash_verify), cxlflash_disk_verify}, 2119 + {sizeof(struct dk_cxlflash_recover_afu), cxlflash_afu_recover}, 2120 + {sizeof(struct dk_cxlflash_manage_lun), cxlflash_manage_lun}, 2119 2121 {sizeof(struct dk_cxlflash_uvirtual), cxlflash_disk_virtual_open}, 2120 - {sizeof(struct dk_cxlflash_resize), (sioctl)cxlflash_vlun_resize}, 2121 - {sizeof(struct dk_cxlflash_clone), (sioctl)cxlflash_disk_clone}, 2122 + {sizeof(struct dk_cxlflash_resize), cxlflash_vlun_resize}, 2123 + {sizeof(struct dk_cxlflash_clone), cxlflash_disk_clone}, 2122 2124 }; 2123 2125 2124 2126 /* Hold read semaphore so we can drain if needed */
+4 -7
drivers/scsi/cxlflash/superpipe.h
··· 114 114 struct page *err_page; /* One page of all 0xF for error notification */ 115 115 }; 116 116 117 - int cxlflash_vlun_resize(struct scsi_device *sdev, 118 - struct dk_cxlflash_resize *resize); 117 + int cxlflash_vlun_resize(struct scsi_device *sdev, void *resize); 119 118 int _cxlflash_vlun_resize(struct scsi_device *sdev, struct ctx_info *ctxi, 120 119 struct dk_cxlflash_resize *resize); 121 120 122 121 int cxlflash_disk_release(struct scsi_device *sdev, 123 - struct dk_cxlflash_release *release); 122 + void *release); 124 123 int _cxlflash_disk_release(struct scsi_device *sdev, struct ctx_info *ctxi, 125 124 struct dk_cxlflash_release *release); 126 125 127 - int cxlflash_disk_clone(struct scsi_device *sdev, 128 - struct dk_cxlflash_clone *clone); 126 + int cxlflash_disk_clone(struct scsi_device *sdev, void *arg); 129 127 130 128 int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg); 131 129 ··· 143 145 144 146 void cxlflash_ba_terminate(struct ba_lun *ba_lun); 145 147 146 - int cxlflash_manage_lun(struct scsi_device *sdev, 147 - struct dk_cxlflash_manage_lun *manage); 148 + int cxlflash_manage_lun(struct scsi_device *sdev, void *manage); 148 149 149 150 int check_state(struct cxlflash_cfg *cfg); 150 151
+4 -5
drivers/scsi/cxlflash/vlun.c
··· 819 819 return rc; 820 820 } 821 821 822 - int cxlflash_vlun_resize(struct scsi_device *sdev, 823 - struct dk_cxlflash_resize *resize) 822 + int cxlflash_vlun_resize(struct scsi_device *sdev, void *resize) 824 823 { 825 824 return _cxlflash_vlun_resize(sdev, NULL, resize); 826 825 } ··· 1177 1178 /** 1178 1179 * cxlflash_disk_clone() - clone a context by making snapshot of another 1179 1180 * @sdev: SCSI device associated with LUN owning virtual LUN. 1180 - * @clone: Clone ioctl data structure. 1181 + * @arg: Clone ioctl data structure. 1181 1182 * 1182 1183 * This routine effectively performs cxlflash_disk_open operation for each 1183 1184 * in-use virtual resource in the source context. Note that the destination ··· 1186 1187 * 1187 1188 * Return: 0 on success, -errno on failure 1188 1189 */ 1189 - int cxlflash_disk_clone(struct scsi_device *sdev, 1190 - struct dk_cxlflash_clone *clone) 1190 + int cxlflash_disk_clone(struct scsi_device *sdev, void *arg) 1191 1191 { 1192 + struct dk_cxlflash_clone *clone = arg; 1192 1193 struct cxlflash_cfg *cfg = shost_priv(sdev->host); 1193 1194 struct device *dev = &cfg->dev->dev; 1194 1195 struct llun_info *lli = sdev->hostdata;