Commit 9b70cd54 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/pci: switch to instanced constructor

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent 0a7bff10
......@@ -60,7 +60,6 @@ struct nvkm_device {
struct notifier_block nb;
} acpi;
struct nvkm_pci *pci;
struct nvkm_pmu *pmu;
struct nvkm_therm *therm;
struct nvkm_timer *timer;
......@@ -129,7 +128,6 @@ struct nvkm_device_chip {
#include <core/layout.h>
#undef NVKM_LAYOUT_INST
#undef NVKM_LAYOUT_ONCE
int (*pci )(struct nvkm_device *, int idx, struct nvkm_pci **);
int (*pmu )(struct nvkm_device *, int idx, struct nvkm_pmu **);
int (*therm )(struct nvkm_device *, int idx, struct nvkm_therm **);
int (*timer )(struct nvkm_device *, int idx, struct nvkm_timer **);
......
/* SPDX-License-Identifier: MIT */
NVKM_LAYOUT_ONCE(NVKM_SUBDEV_PCI , struct nvkm_pci , pci)
NVKM_LAYOUT_ONCE(NVKM_SUBDEV_VBIOS , struct nvkm_bios , bios)
NVKM_LAYOUT_ONCE(NVKM_SUBDEV_DEVINIT , struct nvkm_devinit , devinit)
NVKM_LAYOUT_ONCE(NVKM_SUBDEV_IBUS , struct nvkm_subdev , ibus)
......
......@@ -39,17 +39,17 @@ void nvkm_pci_wr32(struct nvkm_pci *, u16 addr, u32 data);
u32 nvkm_pci_mask(struct nvkm_pci *, u16 addr, u32 mask, u32 value);
void nvkm_pci_rom_shadow(struct nvkm_pci *, bool shadow);
int nv04_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int nv40_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int nv46_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int g84_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int g92_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int gf106_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int gp100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int nv04_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int nv40_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int nv46_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int nv4c_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int g84_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int g92_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int g94_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int gf100_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int gf106_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int gk104_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
int gp100_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_pci **);
/* pcie functions */
int nvkm_pcie_set_link(struct nvkm_pci *, enum nvkm_pcie_speed, u8 width);
......
......@@ -33,7 +33,6 @@ nvkm_subdev_type[NVKM_SUBDEV_NR] = {
#include <core/layout.h>
#undef NVKM_LAYOUT_ONCE
#undef NVKM_LAYOUT_INST
[NVKM_SUBDEV_PCI ] = "pci",
[NVKM_SUBDEV_PMU ] = "pmu",
[NVKM_SUBDEV_THERM ] = "therm",
[NVKM_SUBDEV_TIMER ] = "tmr",
......
......@@ -183,13 +183,13 @@ nvkm_pci_func = {
int
nvkm_pci_new_(const struct nvkm_pci_func *func, struct nvkm_device *device,
int index, struct nvkm_pci **ppci)
enum nvkm_subdev_type type, int inst, struct nvkm_pci **ppci)
{
struct nvkm_pci *pci;
if (!(pci = *ppci = kzalloc(sizeof(**ppci), GFP_KERNEL)))
return -ENOMEM;
nvkm_subdev_ctor(&nvkm_pci_func, device, index, &pci->subdev);
nvkm_subdev_ctor(&nvkm_pci_func, device, type, inst, &pci->subdev);
pci->func = func;
pci->pdev = device->func->pci(device)->pdev;
pci->irq = -1;
......
......@@ -150,7 +150,8 @@ g84_pci_func = {
};
int
g84_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
g84_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&g84_pci_func, device, index, ppci);
return nvkm_pci_new_(&g84_pci_func, device, type, inst, ppci);
}
......@@ -51,7 +51,8 @@ g92_pci_func = {
};
int
g92_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
g92_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&g92_pci_func, device, index, ppci);
return nvkm_pci_new_(&g92_pci_func, device, type, inst, ppci);
}
......@@ -43,7 +43,8 @@ g94_pci_func = {
};
int
g94_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
g94_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&g94_pci_func, device, index, ppci);
return nvkm_pci_new_(&g94_pci_func, device, type, inst, ppci);
}
......@@ -96,7 +96,8 @@ gf100_pci_func = {
};
int
gf100_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
gf100_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&gf100_pci_func, device, index, ppci);
return nvkm_pci_new_(&gf100_pci_func, device, type, inst, ppci);
}
......@@ -43,7 +43,8 @@ gf106_pci_func = {
};
int
gf106_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
gf106_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&gf106_pci_func, device, index, ppci);
return nvkm_pci_new_(&gf106_pci_func, device, type, inst, ppci);
}
......@@ -222,7 +222,8 @@ gk104_pci_func = {
};
int
gk104_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
gk104_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&gk104_pci_func, device, index, ppci);
return nvkm_pci_new_(&gk104_pci_func, device, type, inst, ppci);
}
......@@ -38,7 +38,8 @@ gp100_pci_func = {
};
int
gp100_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
gp100_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&gp100_pci_func, device, index, ppci);
return nvkm_pci_new_(&gp100_pci_func, device, type, inst, ppci);
}
......@@ -52,7 +52,8 @@ nv04_pci_func = {
};
int
nv04_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
nv04_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&nv04_pci_func, device, index, ppci);
return nvkm_pci_new_(&nv04_pci_func, device, type, inst, ppci);
}
......@@ -59,7 +59,8 @@ nv40_pci_func = {
};
int
nv40_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
nv40_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&nv40_pci_func, device, index, ppci);
return nvkm_pci_new_(&nv40_pci_func, device, type, inst, ppci);
}
......@@ -45,7 +45,8 @@ nv46_pci_func = {
};
int
nv46_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
nv46_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&nv46_pci_func, device, index, ppci);
return nvkm_pci_new_(&nv46_pci_func, device, type, inst, ppci);
}
......@@ -31,7 +31,8 @@ nv4c_pci_func = {
};
int
nv4c_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
nv4c_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_pci **ppci)
{
return nvkm_pci_new_(&nv4c_pci_func, device, index, ppci);
return nvkm_pci_new_(&nv4c_pci_func, device, type, inst, ppci);
}
......@@ -4,8 +4,8 @@
#define nvkm_pci(p) container_of((p), struct nvkm_pci, subdev)
#include <subdev/pci.h>
int nvkm_pci_new_(const struct nvkm_pci_func *, struct nvkm_device *,
int index, struct nvkm_pci **);
int nvkm_pci_new_(const struct nvkm_pci_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
struct nvkm_pci **);
struct nvkm_pci_func {
void (*init)(struct nvkm_pci *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment