Skip to content
Snippets Groups Projects
Commit 864674fa authored by Stefan Berger's avatar Stefan Berger Committed by David Gibson
Browse files

spapr: Implement get_dt_compatible() callback


For devices that cannot be statically initialized, implement a
get_dt_compatible() callback that allows us to ask the device for
the 'compatible' value.

Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Message-Id: <20200121152935.649898-3-stefanb@linux.ibm.com>
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent 3688d73b
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,7 @@ static int vio_make_devnode(SpaprVioDevice *dev,
SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
int vdevice_off, node_off, ret;
char *dt_name;
const char *dt_compatible;
vdevice_off = fdt_path_offset(fdt, "/vdevice");
if (vdevice_off < 0) {
......@@ -113,9 +114,15 @@ static int vio_make_devnode(SpaprVioDevice *dev,
}
}
if (pc->dt_compatible) {
if (pc->get_dt_compatible) {
dt_compatible = pc->get_dt_compatible(dev);
} else {
dt_compatible = pc->dt_compatible;
}
if (dt_compatible) {
ret = fdt_setprop_string(fdt, node_off, "compatible",
pc->dt_compatible);
dt_compatible);
if (ret < 0) {
return ret;
}
......
......@@ -58,6 +58,7 @@ typedef struct SpaprVioDeviceClass {
void (*realize)(SpaprVioDevice *dev, Error **errp);
void (*reset)(SpaprVioDevice *dev);
int (*devnode)(SpaprVioDevice *dev, void *fdt, int node_off);
const char *(*get_dt_compatible)(SpaprVioDevice *dev);
} SpaprVioDeviceClass;
struct SpaprVioDevice {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment