Message ID | 20200108161012.1821385-3-stefanb@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add vTPM emulator support for ppc64 platform | expand |
On Wed, Jan 8, 2020 at 8:11 PM Stefan Berger <stefanb@linux.ibm.com> wrote: > > From: Stefan Berger <stefanb@linux.vnet.ibm.com> > > 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: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > hw/ppc/spapr_vio.c | 11 +++++++++-- > include/hw/ppc/spapr_vio.h | 1 + > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c > index 554de9930d..4b24b81797 100644 > --- a/hw/ppc/spapr_vio.c > +++ b/hw/ppc/spapr_vio.c > @@ -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; > } > diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h > index 72762ed16b..67f58b7f98 100644 > --- a/include/hw/ppc/spapr_vio.h > +++ b/include/hw/ppc/spapr_vio.h > @@ -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 { > -- > 2.24.1 > >
On Wed, Jan 08, 2020 at 11:10:08AM -0500, Stefan Berger wrote: > From: Stefan Berger <stefanb@linux.vnet.ibm.com> > > 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: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> > --- > hw/ppc/spapr_vio.c | 11 +++++++++-- > include/hw/ppc/spapr_vio.h | 1 + > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c > index 554de9930d..4b24b81797 100644 > --- a/hw/ppc/spapr_vio.c > +++ b/hw/ppc/spapr_vio.c > @@ -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; > } > diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h > index 72762ed16b..67f58b7f98 100644 > --- a/include/hw/ppc/spapr_vio.h > +++ b/include/hw/ppc/spapr_vio.h > @@ -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 {
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index 554de9930d..4b24b81797 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -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; } diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 72762ed16b..67f58b7f98 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -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 {