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

Configure Feed

Select the types of activity you want to include in your feed.

hisi_acc_vfio_pci: extract public functions for container_of

In the current driver, vdev is obtained from struct
hisi_acc_vf_core_device through the container_of function.
This method is used in many places in the driver. In order to
reduce this repetitive operation, It was extracted into
a public function.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Link: https://lore.kernel.org/r/20241112073322.54550-2-liulongfang@huawei.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

authored by

Longfang Liu and committed by
Alex Williamson
ece8a2c7 9283b739

+11 -10
+11 -10
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
··· 630 630 } 631 631 } 632 632 633 + static struct hisi_acc_vf_core_device *hisi_acc_get_vf_dev(struct vfio_device *vdev) 634 + { 635 + return container_of(vdev, struct hisi_acc_vf_core_device, 636 + core_device.vdev); 637 + } 638 + 633 639 static void hisi_acc_vf_reset(struct hisi_acc_vf_core_device *hisi_acc_vdev) 634 640 { 635 641 hisi_acc_vdev->vf_qm_state = QM_NOT_READY; ··· 1037 1031 hisi_acc_vfio_pci_set_device_state(struct vfio_device *vdev, 1038 1032 enum vfio_device_mig_state new_state) 1039 1033 { 1040 - struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(vdev, 1041 - struct hisi_acc_vf_core_device, core_device.vdev); 1034 + struct hisi_acc_vf_core_device *hisi_acc_vdev = hisi_acc_get_vf_dev(vdev); 1042 1035 enum vfio_device_mig_state next_state; 1043 1036 struct file *res = NULL; 1044 1037 int ret; ··· 1078 1073 hisi_acc_vfio_pci_get_device_state(struct vfio_device *vdev, 1079 1074 enum vfio_device_mig_state *curr_state) 1080 1075 { 1081 - struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(vdev, 1082 - struct hisi_acc_vf_core_device, core_device.vdev); 1076 + struct hisi_acc_vf_core_device *hisi_acc_vdev = hisi_acc_get_vf_dev(vdev); 1083 1077 1084 1078 mutex_lock(&hisi_acc_vdev->state_mutex); 1085 1079 *curr_state = hisi_acc_vdev->mig_state; ··· 1282 1278 1283 1279 static int hisi_acc_vfio_pci_open_device(struct vfio_device *core_vdev) 1284 1280 { 1285 - struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(core_vdev, 1286 - struct hisi_acc_vf_core_device, core_device.vdev); 1281 + struct hisi_acc_vf_core_device *hisi_acc_vdev = hisi_acc_get_vf_dev(core_vdev); 1287 1282 struct vfio_pci_core_device *vdev = &hisi_acc_vdev->core_device; 1288 1283 int ret; 1289 1284 ··· 1305 1302 1306 1303 static void hisi_acc_vfio_pci_close_device(struct vfio_device *core_vdev) 1307 1304 { 1308 - struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(core_vdev, 1309 - struct hisi_acc_vf_core_device, core_device.vdev); 1305 + struct hisi_acc_vf_core_device *hisi_acc_vdev = hisi_acc_get_vf_dev(core_vdev); 1310 1306 struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm; 1311 1307 1312 1308 iounmap(vf_qm->io_base); ··· 1320 1318 1321 1319 static int hisi_acc_vfio_pci_migrn_init_dev(struct vfio_device *core_vdev) 1322 1320 { 1323 - struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(core_vdev, 1324 - struct hisi_acc_vf_core_device, core_device.vdev); 1321 + struct hisi_acc_vf_core_device *hisi_acc_vdev = hisi_acc_get_vf_dev(core_vdev); 1325 1322 struct pci_dev *pdev = to_pci_dev(core_vdev->dev); 1326 1323 struct hisi_qm *pf_qm = hisi_acc_get_pf_qm(pdev); 1327 1324