This is an automated email from the ASF dual-hosted git repository. andk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit d1ab7d697dc665d58d105374f05b8d6e2b3793b3 Author: Andrzej Kaczmarek <andrzej.kaczma...@codecoup.pl> AuthorDate: Wed Dec 5 19:18:10 2018 +0100 hw/bus: Fix bus device initialization This makes flow in bus device initialization more consistent and is as follows for all buses: 1. specialized bus device init function configures hardware and leaves it disabled 2. at the end of above init function, generic bus device init function is called which enables bus device Note: for now we don't really disable bus device during its lifetime, this may be likely used once some power saving is implemented. --- hw/bus/drivers/i2c_hal/src/i2c_hal.c | 4 ++-- hw/bus/drivers/spi_hal/src/spi_hal.c | 5 +---- hw/bus/src/bus.c | 4 ++++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/bus/drivers/i2c_hal/src/i2c_hal.c b/hw/bus/drivers/i2c_hal/src/i2c_hal.c index 782a207..3e2f675 100644 --- a/hw/bus/drivers/i2c_hal/src/i2c_hal.c +++ b/hw/bus/drivers/i2c_hal/src/i2c_hal.c @@ -207,10 +207,10 @@ bus_i2c_hal_dev_init_func(struct os_dev *odev, void *arg) return SYS_EINVAL; } + dev->cfg = *cfg; + rc = bus_dev_init_func(odev, (void*)&bus_i2c_hal_ops); assert(rc == 0); - dev->cfg = *cfg; - return 0; } diff --git a/hw/bus/drivers/spi_hal/src/spi_hal.c b/hw/bus/drivers/spi_hal/src/spi_hal.c index 7dbd489..c1d8ea6 100644 --- a/hw/bus/drivers/spi_hal/src/spi_hal.c +++ b/hw/bus/drivers/spi_hal/src/spi_hal.c @@ -207,12 +207,9 @@ bus_spi_hal_dev_init_func(struct os_dev *odev, void *arg) BUS_DEBUG_POISON_DEV(dev); - rc = bus_dev_init_func(odev, (void*)&bus_spi_ops); - assert(rc == 0); - dev->cfg = *cfg; - rc = hal_spi_enable(dev->cfg.spi_num); + rc = bus_dev_init_func(odev, (void*)&bus_spi_ops); assert(rc == 0); return 0; diff --git a/hw/bus/src/bus.c b/hw/bus/src/bus.c index 107e1bf..93f7153 100644 --- a/hw/bus/src/bus.c +++ b/hw/bus/src/bus.c @@ -142,6 +142,10 @@ bus_dev_init_func(struct os_dev *odev, void *arg) stats_name); #endif + if (bdev->dops->enable) { + bdev->dops->enable(bdev); + } + return 0; }