On Fri, 18 Oct 2019 at 16:07, Damien Hedde <damien.he...@greensocs.com> wrote: > > Split gpfsel_set() in 2 so that the sdbus reparenting is done > in a dedicated function. > > Signed-off-by: Damien Hedde <damien.he...@greensocs.com> > --- > Cc: Peter Maydell <peter.mayd...@linaro.org> > Cc: Andrew Baumann <andrew.baum...@microsoft.com> > Cc: Philippe Mathieu-Daudé <phi...@redhat.com> > Cc: qemu-...@nongnu.org > --- > hw/gpio/bcm2835_gpio.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/hw/gpio/bcm2835_gpio.c b/hw/gpio/bcm2835_gpio.c > index 91ce3d10cc..81fe07132f 100644 > --- a/hw/gpio/bcm2835_gpio.c > +++ b/hw/gpio/bcm2835_gpio.c > @@ -75,7 +75,10 @@ static void gpfsel_set(BCM2835GpioState *s, uint8_t reg, > uint32_t value) > s->fsel[index] = fsel; > } > } > +} > > +static void gpfsel_update_sdbus(BCM2835GpioState *s) > +{ > /* SD controller selection (48-53) */ > if (s->sd_fsel != 0 > && (s->fsel[48] == 0) /* SD_CLK_R */ > @@ -86,6 +89,7 @@ static void gpfsel_set(BCM2835GpioState *s, uint8_t reg, > uint32_t value) > && (s->fsel[53] == 0) /* SD_DATA3_R */ > ) { > /* SDHCI controller selected */ > + sdbus_reparent_card(&s->sdbus, s->sdbus_sdhci); > sdbus_reparent_card(s->sdbus_sdhost, s->sdbus_sdhci); > s->sd_fsel = 0;> } else if (s->sd_fsel != 4 > @@ -97,6 +101,7 @@ static void gpfsel_set(BCM2835GpioState *s, uint8_t reg, > uint32_t value) > && (s->fsel[53] == 4) /* SD_DATA3_R */ > ) { > /* SDHost controller selected */ > + sdbus_reparent_card(&s->sdbus, s->sdbus_sdhost); > sdbus_reparent_card(s->sdbus_sdhci, s->sdbus_sdhost);
The commit message says it's just splitting the function in two, but these two hunks are adding extra calls to sdbus_reparent_card(). Why do we need to call it twice ? > s->sd_fsel = 4; > } thanks -- PMM