| 319 | } |
| 320 | |
| 321 | static int |
| 322 | device_setup(struct rte_platform_device *pdev) |
| 323 | { |
| 324 | struct vfio_device_info dev_info = { .argsz = sizeof(dev_info), }; |
| 325 | const char *name = pdev->name; |
| 326 | int ret; |
| 327 | |
| 328 | ret = rte_vfio_setup_device(PLATFORM_BUS_DEVICES_PATH, name, &pdev->dev_fd, &dev_info); |
| 329 | if (ret) { |
| 330 | PLATFORM_LOG(ERR, "failed to setup %s\n", name); |
| 331 | return -ENODEV; |
| 332 | } |
| 333 | |
| 334 | /* This is an extra check to confirm that platform device was initialized |
| 335 | * by a kernel vfio-platform driver. On kernels that predate vfio-platform |
| 336 | * driver this flag obviously does not exist. In such scenarios this |
| 337 | * check needs to be removed otherwise compilation fails. |
| 338 | * |
| 339 | * Now, on such old kernels code will never reach here because |
| 340 | * there is another check much earlier which verifies whether |
| 341 | * device has been bound to vfio-platform driver. |
| 342 | */ |
| 343 | #ifdef VFIO_DEVICE_FLAGS_PLATFORM |
| 344 | if (!(dev_info.flags & VFIO_DEVICE_FLAGS_PLATFORM)) { |
| 345 | PLATFORM_LOG(ERR, "device not backed by vfio-platform\n"); |
| 346 | ret = -ENOTSUP; |
| 347 | goto out; |
| 348 | } |
| 349 | #endif |
| 350 | |
| 351 | ret = device_map_resources(pdev, dev_info.num_regions); |
| 352 | if (ret) { |
| 353 | PLATFORM_LOG(ERR, "failed to setup platform resources\n"); |
| 354 | goto out; |
| 355 | } |
| 356 | |
| 357 | return 0; |
| 358 | out: |
| 359 | device_cleanup(pdev); |
| 360 | |
| 361 | return ret; |
| 362 | } |
| 363 | |
| 364 | static int |
| 365 | driver_call_probe(struct rte_platform_driver *pdrv, struct rte_platform_device *pdev) |
no test coverage detected