nvdimm: make get_memory_region() perform checks and initialization
commita4659a8ef424928f654707ca637ba133cbe22396
authorDavid Hildenbrand <david@redhat.com>
Tue, 19 Jun 2018 13:41:40 +0000 (19 15:41 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 28 Jun 2018 17:05:34 +0000 (28 19:05 +0200)
treee915cb060bf3075b50021a26bc3a2f398442281b
parenteb7fd4d0f64fcab2da9ae454a1f214174e881372
nvdimm: make get_memory_region() perform checks and initialization

We might get a call to get_memory_region() before the device has been
realized. We should return a consistent value, as the return value
will e.g. later on be used in the pre_plug handler.

To avoid duplicating too much code, factor the initialization and checks
out into a helper function.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180619134141.29478-12-david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/mem/nvdimm.c