Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/src/linux_pci.c
Show First 20 Lines • Show All 403 Lines • ▼ Show 20 Lines | linux_pci_attach_device(device_t dev, struct pci_driver *pdrv, | ||||
lkpifill_pci_dev(dev, pdev); | lkpifill_pci_dev(dev, pdev); | ||||
if (isdrm) | if (isdrm) | ||||
PCI_GET_ID(device_get_parent(parent), parent, PCI_ID_RID, &rid); | PCI_GET_ID(device_get_parent(parent), parent, PCI_ID_RID, &rid); | ||||
else | else | ||||
PCI_GET_ID(parent, dev, PCI_ID_RID, &rid); | PCI_GET_ID(parent, dev, PCI_ID_RID, &rid); | ||||
pdev->devfn = rid; | pdev->devfn = rid; | ||||
pdev->pdrv = pdrv; | pdev->pdrv = pdrv; | ||||
rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 0); | rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 0, false); | ||||
if (rle != NULL) | if (rle != NULL) | ||||
pdev->dev.irq = rle->start; | pdev->dev.irq = rle->start; | ||||
else | else | ||||
pdev->dev.irq = LINUX_IRQ_INVALID; | pdev->dev.irq = LINUX_IRQ_INVALID; | ||||
pdev->irq = pdev->dev.irq; | pdev->irq = pdev->dev.irq; | ||||
error = linux_pdev_dma_init(pdev); | error = linux_pdev_dma_init(pdev); | ||||
if (error) | if (error) | ||||
goto out_dma_init; | goto out_dma_init; | ||||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | linux_pci_register_driver(struct pci_driver *pdrv) | ||||
dc = devclass_find("pci"); | dc = devclass_find("pci"); | ||||
if (dc == NULL) | if (dc == NULL) | ||||
return (-ENXIO); | return (-ENXIO); | ||||
pdrv->isdrm = false; | pdrv->isdrm = false; | ||||
return (_linux_pci_register_driver(pdrv, dc)); | return (_linux_pci_register_driver(pdrv, dc)); | ||||
} | } | ||||
struct resource_list_entry * | |||||
linux_pci_reserve_bar(struct pci_dev *pdev, struct resource_list *rl, | |||||
int type, int rid) | |||||
{ | |||||
device_t dev; | |||||
struct resource *res; | |||||
KASSERT(type == SYS_RES_IOPORT || type == SYS_RES_MEMORY, | |||||
("trying to reserve non-BAR type %d", type)); | |||||
dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ? | |||||
hselasky: Maybe put ()'s around "pdev->pdrv != NULL && pdev->pdrv->isdrm". | |||||
Done Inline ActionsRealise I didn't reply to this, but this is the exact style used elsewhere when checking isdrm jrtc27: Realise I didn't reply to this, but this is the exact style used elsewhere when checking isdrm | |||||
device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev; | |||||
res = pci_reserve_map(device_get_parent(dev), dev, type, &rid, 0, ~0, | |||||
1, 1, 0); | |||||
if (res == NULL) | |||||
return (NULL); | |||||
return (resource_list_find(rl, type, rid)); | |||||
} | |||||
unsigned long | unsigned long | ||||
pci_resource_start(struct pci_dev *pdev, int bar) | pci_resource_start(struct pci_dev *pdev, int bar) | ||||
{ | { | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
rman_res_t newstart; | rman_res_t newstart; | ||||
device_t dev; | device_t dev; | ||||
if ((rle = linux_pci_get_bar(pdev, bar)) == NULL) | if ((rle = linux_pci_get_bar(pdev, bar, true)) == NULL) | ||||
return (0); | return (0); | ||||
dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ? | dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ? | ||||
device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev; | device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev; | ||||
if (BUS_TRANSLATE_RESOURCE(dev, rle->type, rle->start, &newstart)) { | if (BUS_TRANSLATE_RESOURCE(dev, rle->type, rle->start, &newstart)) { | ||||
device_printf(pdev->dev.bsddev, "translate of %#jx failed\n", | device_printf(pdev->dev.bsddev, "translate of %#jx failed\n", | ||||
(uintmax_t)rle->start); | (uintmax_t)rle->start); | ||||
return (0); | return (0); | ||||
} | } | ||||
return (newstart); | return (newstart); | ||||
} | } | ||||
unsigned long | unsigned long | ||||
pci_resource_len(struct pci_dev *pdev, int bar) | pci_resource_len(struct pci_dev *pdev, int bar) | ||||
{ | { | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
if ((rle = linux_pci_get_bar(pdev, bar)) == NULL) | if ((rle = linux_pci_get_bar(pdev, bar, true)) == NULL) | ||||
return (0); | return (0); | ||||
return (rle->count); | return (rle->count); | ||||
} | } | ||||
int | int | ||||
linux_pci_register_drm_driver(struct pci_driver *pdrv) | linux_pci_register_drm_driver(struct pci_driver *pdrv) | ||||
{ | { | ||||
devclass_t dc; | devclass_t dc; | ||||
▲ Show 20 Lines • Show All 550 Lines • Show Last 20 Lines |
Maybe put ()'s around "pdev->pdrv != NULL && pdev->pdrv->isdrm".