Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions samples/subsys/greybus/net/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
#include <stdio.h>
#include <zephyr.h>

struct device;
extern int greybus_service_init(struct device *bus);

void main(void)
{
int r = greybus_service_init(NULL);
if (r < 0) {
printf("gb_service_deferred_init() failed: %d\n", r);
}
}
7 changes: 0 additions & 7 deletions samples/subsys/greybus/uart/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
#include <stdio.h>
#include <zephyr.h>

struct device;
extern int greybus_service_init(struct device *bus);

void main(void)
{
int r = greybus_service_init(NULL);
if (r < 0) {
printf("gb_service_deferred_init() failed: %d\n", r);
}
}
1 change: 0 additions & 1 deletion subsys/greybus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ zephyr_library_sources(

platform/manifest.c
platform/platform.c
platform/deferred-init.c

platform/service.c

Expand Down
35 changes: 35 additions & 0 deletions subsys/greybus/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,41 @@ config GREYBUS_VIBRATOR
help
Select this for Greybus Vibrator support.

config GREYBUS_SERVICE_INIT_PRIORITY
int "default Greybus Service Init Priority"
default 85
range 0 99
help
Greybus service init priority to ensure device initialization order.

config GREYBUS_STRING_INIT_PRIORITY
int "default Greybus String Init Priority"
default 86
range 0 99
help
Greybus string init priority to ensure device initialization order.

config GREYBUS_INTERFACE_INIT_PRIORITY
int "default Greybus Interface Init Priority"
default 87
range 0 99
help
Greybus interface init priority to ensure device initialization order.

config GREYBUS_BUNDLE_INIT_PRIORITY
int "default Greybus Bundle Init Priority"
default 88
range 0 99
help
Greybus bundle init priority to ensure device initialization order.

config GREYBUS_CPORT_INIT_PRIORITY
int "default Greybus Cport Init Priority"
default 89
range 0 99
help
Greybus cport init priority to ensure device initialization order.

module = GREYBUS
module-str = gb
source "subsys/logging/Kconfig.template.log_config"
Expand Down
9 changes: 2 additions & 7 deletions subsys/greybus/platform/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ static int greybus_bundle_init(const struct device *dev) {
return 0;
}

extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
static int defer_greybus_bundle_init(const struct device *dev) {
return gb_service_defer_init(dev, &greybus_bundle_init);
}

#define DEFINE_GREYBUS_BUNDLE(_num) \
\
static const struct greybus_bundle_config \
Expand All @@ -48,10 +43,10 @@ static int defer_greybus_bundle_init(const struct device *dev) {
}; \
\
DEVICE_DT_INST_DEFINE(_num, \
defer_greybus_bundle_init, \
greybus_bundle_init, \
NULL, NULL, \
&greybus_bundle_config_##_num, \
POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
CONFIG_GREYBUS_BUNDLE_INIT_PRIORITY, NULL);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_BUNDLE);
2 changes: 1 addition & 1 deletion subsys/greybus/platform/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int greybus_init(const struct device *bus) {
DEVICE_DT_INST_DEFINE(_num, \
greybus_init, NULL, NULL, \
&greybus_config_##_num, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
CONFIG_GREYBUS_SERVICE_INIT_PRIORITY, \
NULL);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS);
9 changes: 2 additions & 7 deletions subsys/greybus/platform/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ static int greybus_control_init(const struct device *dev) {
return 0;
}

extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
static int defer_greybus_control_init(const struct device *dev) {
return gb_service_defer_init(dev, &greybus_control_init);
}

#define DEFINE_GREYBUS_CONTROL(_num) \
\
BUILD_ASSERT(DT_PROP(DT_PARENT(DT_DRV_INST(_num)), bundle_class) \
Expand All @@ -54,9 +49,9 @@ static int defer_greybus_control_init(const struct device *dev) {
}; \
\
DEVICE_DT_INST_DEFINE(_num, \
defer_greybus_control_init, \
greybus_control_init, \
NULL, NULL, \
&greybus_control_config_##_num, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
CONFIG_GREYBUS_CPORT_INIT_PRIORITY, NULL);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_CONTROL);
88 changes: 0 additions & 88 deletions subsys/greybus/platform/deferred-init.c

This file was deleted.

9 changes: 2 additions & 7 deletions subsys/greybus/platform/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ static int greybus_gpio_control_init(const struct device *dev) {
return 0;
}

extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
static int defer_greybus_gpio_control_init(const struct device *dev) {
return gb_service_defer_init(dev, &greybus_gpio_control_init);
}

#define DEFINE_GREYBUS_GPIO_CONTROL(_num) \
\
BUILD_ASSERT(DT_PROP(DT_PARENT(DT_DRV_INST(_num)), bundle_class) \
Expand All @@ -152,9 +147,9 @@ static int defer_greybus_gpio_control_init(const struct device *dev) {
greybus_gpio_control_data_##_num; \
\
DEVICE_DT_INST_DEFINE(_num, \
defer_greybus_gpio_control_init, NULL, \
greybus_gpio_control_init, NULL, \
&greybus_gpio_control_data_##_num, \
&greybus_gpio_control_config_##_num, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
CONFIG_GREYBUS_CPORT_INIT_PRIORITY, NULL);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_GPIO_CONTROL);
9 changes: 2 additions & 7 deletions subsys/greybus/platform/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ static int greybus_i2c_control_init(const struct device *dev) {
return 0;
}

extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
static int defer_greybus_i2c_control_init(const struct device *dev) {
return gb_service_defer_init(dev, &greybus_i2c_control_init);
}

#define DEFINE_GREYBUS_I2C_CONTROL(_num) \
\
BUILD_ASSERT(DT_PROP(DT_PARENT(DT_DRV_INST(_num)), bundle_class) \
Expand All @@ -89,9 +84,9 @@ static int defer_greybus_i2c_control_init(const struct device *dev) {
greybus_i2c_control_data_##_num; \
\
DEVICE_INIT(i2c_i2c_control_##_num, "GBI2C_" #_num, \
defer_greybus_i2c_control_init, \
greybus_i2c_control_init, \
&greybus_i2c_control_data_##_num, \
&greybus_i2c_control_config_##_num, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
CONFIG_GREYBUS_CPORT_INIT_PRIORITY);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_I2C_CONTROL);
10 changes: 2 additions & 8 deletions subsys/greybus/platform/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ static int greybus_interface_init(const struct device *dev) {
return 0;
}

extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
static int defer_greybus_interface_init(const struct device *dev) {
return gb_service_defer_init(dev, &greybus_interface_init);
}


#define DEFINE_GREYBUS_INTERFACE(_num) \
\
static const struct greybus_interface_config \
Expand All @@ -55,9 +49,9 @@ static int defer_greybus_interface_init(const struct device *dev) {
}; \
\
DEVICE_DT_INST_DEFINE(_num, \
defer_greybus_interface_init, \
greybus_interface_init, \
NULL, NULL, \
&greybus_interface_config_##_num, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
CONFIG_GREYBUS_INTERFACE_INIT_PRIORITY, NULL);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_INTERFACE);
20 changes: 10 additions & 10 deletions subsys/greybus/platform/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ gb_transport_get_backend(void)
return xport;
}

int greybus_service_init(const struct device *bus)
static int greybus_service_init(const struct device *bus)
{
int r;
int r;
uint8_t *mnfb;
size_t mnfb_size;
unsigned int *cports = NULL;
unsigned int *cports = NULL;

LOG_DBG("Greybus initializing..");

r = gb_service_deferred_init();
if (r < 0) {
LOG_ERR("gb_service_deferred_init() failed: %d", r);
goto out;
if (xport != NULL) {
LOG_ERR("service already initialized");
return -EALREADY;
}

LOG_DBG("Greybus initializing..");

bus = device_get_binding(GREYBUS_BUS_NAME);
if (NULL == bus) {
r = -ENODEV;
LOG_ERR("failed to get " GREYBUS_BUS_NAME " device");
goto out;
}
Expand Down Expand Up @@ -114,4 +114,4 @@ int greybus_service_init(const struct device *bus)
return r;
}

//SYS_INIT(greybus_service_init, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY);
SYS_INIT(greybus_service_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
9 changes: 2 additions & 7 deletions subsys/greybus/platform/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ static int greybus_spi_control_init(const struct device *dev) {
return 0;
}

extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
static int defer_greybus_spi_control_init(const struct device *dev) {
return gb_service_defer_init(dev, &greybus_spi_control_init);
}

static int gb_plat_api_controller_config_response(const struct device *dev, struct gb_spi_master_config_response *rsp)
{
if (dev == NULL || NULL == rsp) {
Expand Down Expand Up @@ -323,10 +318,10 @@ static const struct gb_platform_spi_api gb_platform_spi_api = {
greybus_spi_control_data_##_num; \
\
DEVICE_DT_INST_DEFINE(_num, \
defer_greybus_spi_control_init, \
greybus_spi_control_init, \
NULL, &greybus_spi_control_data_##_num, \
&greybus_spi_control_config_##_num, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
CONFIG_GREYBUS_CPORT_INIT_PRIORITY, \
&gb_platform_spi_api);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_SPI_CONTROL);
9 changes: 2 additions & 7 deletions subsys/greybus/platform/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ static int greybus_string_init(const struct device *dev) {
return 0;
}

extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
static int defer_greybus_string_init(const struct device *dev) {
return gb_service_defer_init(dev, &greybus_string_init);
}

#define DEFINE_GREYBUS_STRING(_num) \
\
static const struct greybus_string_config \
Expand All @@ -45,8 +40,8 @@ static int defer_greybus_string_init(const struct device *dev) {
}; \
\
DEVICE_DT_INST_DEFINE(_num, \
defer_greybus_string_init, NULL, NULL, \
greybus_string_init, NULL, NULL, \
&greybus_string_config_##_num, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
CONFIG_GREYBUS_STRING_INIT_PRIORITY, NULL);

DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_STRING);
3 changes: 0 additions & 3 deletions tests/subsys/greybus/gpio/src/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ void test_greybus_setup(void) {

*port = htons(PORT);

extern int greybus_service_init(const struct device *);
greybus_service_init(NULL);

gpio_dev = (struct device *)device_get_binding(GPIO_DEV_NAME);
zassert_not_equal(gpio_dev, NULL, "failed to get device binding for " GPIO_DEV_NAME);

Expand Down