Skip to content

Commit 5389e0f

Browse files
subsys: greybus: remove deferred init
Fixes #12 Changes as per discussion in https://github.com/cfriedt/zephyr/pull/5 Currently priorities are assigned in the following manner: CONFIG_GREYBUS_SERVICE_PRIORITY N-5 CONFIG_GREYBUS_STRING_PRIORITY N-4 CONFIG_GREYBUS_INTERFACE_PRIORITY N-3 CONFIG_GREYBUS_BUNDLE_PRIORITY N-2 CONFIG_GREYBUS_CPORT_PRIORITY N-1 where N = CONFIG_APPLICATION_INIT_PRIORITY Tested GPIO, I2C and SPI on CC1352R SensorTag Signed-off-by: Vaishnav M A <[email protected]>
1 parent 081d7ed commit 5389e0f

File tree

15 files changed

+57
-165
lines changed

15 files changed

+57
-165
lines changed

samples/subsys/greybus/net/src/main.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
#include <stdio.h>
88
#include <zephyr.h>
99

10-
struct device;
11-
extern int greybus_service_init(struct device *bus);
12-
1310
void main(void)
1411
{
15-
int r = greybus_service_init(NULL);
16-
if (r < 0) {
17-
printf("gb_service_deferred_init() failed: %d\n", r);
18-
}
1912
}

samples/subsys/greybus/uart/src/main.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
#include <stdio.h>
88
#include <zephyr.h>
99

10-
struct device;
11-
extern int greybus_service_init(struct device *bus);
12-
1310
void main(void)
1411
{
15-
int r = greybus_service_init(NULL);
16-
if (r < 0) {
17-
printf("gb_service_deferred_init() failed: %d\n", r);
18-
}
1912
}

subsys/greybus/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ zephyr_library_sources(
1313

1414
platform/manifest.c
1515
platform/platform.c
16-
platform/deferred-init.c
1716

1817
platform/service.c
1918

subsys/greybus/Kconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,41 @@ config GREYBUS_VIBRATOR
161161
help
162162
Select this for Greybus Vibrator support.
163163

164+
config GREYBUS_SERVICE_INIT_PRIORITY
165+
int "default Greybus Service Init Priority"
166+
default 85
167+
range 0 99
168+
help
169+
Greybus service init priority to ensure device initialization order.
170+
171+
config GREYBUS_STRING_INIT_PRIORITY
172+
int "default Greybus String Init Priority"
173+
default 86
174+
range 0 99
175+
help
176+
Greybus string init priority to ensure device initialization order.
177+
178+
config GREYBUS_INTERFACE_INIT_PRIORITY
179+
int "default Greybus Interface Init Priority"
180+
default 87
181+
range 0 99
182+
help
183+
Greybus interface init priority to ensure device initialization order.
184+
185+
config GREYBUS_BUNDLE_INIT_PRIORITY
186+
int "default Greybus Bundle Init Priority"
187+
default 88
188+
range 0 99
189+
help
190+
Greybus bundle init priority to ensure device initialization order.
191+
192+
config GREYBUS_CPORT_INIT_PRIORITY
193+
int "default Greybus Cport Init Priority"
194+
default 89
195+
range 0 99
196+
help
197+
Greybus cport init priority to ensure device initialization order.
198+
164199
module = GREYBUS
165200
module-str = gb
166201
source "subsys/logging/Kconfig.template.log_config"

subsys/greybus/platform/bundle.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ static int greybus_bundle_init(const struct device *dev) {
3232
return 0;
3333
}
3434

35-
extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
36-
static int defer_greybus_bundle_init(const struct device *dev) {
37-
return gb_service_defer_init(dev, &greybus_bundle_init);
38-
}
39-
4035
#define DEFINE_GREYBUS_BUNDLE(_num) \
4136
\
4237
static const struct greybus_bundle_config \
@@ -48,10 +43,10 @@ static int defer_greybus_bundle_init(const struct device *dev) {
4843
}; \
4944
\
5045
DEVICE_DT_INST_DEFINE(_num, \
51-
defer_greybus_bundle_init, \
46+
greybus_bundle_init, \
5247
NULL, NULL, \
5348
&greybus_bundle_config_##_num, \
5449
POST_KERNEL, \
55-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
50+
CONFIG_GREYBUS_BUNDLE_INIT_PRIORITY, NULL);
5651

5752
DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_BUNDLE);

subsys/greybus/platform/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int greybus_init(const struct device *bus) {
3838
DEVICE_DT_INST_DEFINE(_num, \
3939
greybus_init, NULL, NULL, \
4040
&greybus_config_##_num, POST_KERNEL, \
41-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
41+
CONFIG_GREYBUS_SERVICE_INIT_PRIORITY, \
4242
NULL);
4343

4444
DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS);

subsys/greybus/platform/control.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ static int greybus_control_init(const struct device *dev) {
3232
return 0;
3333
}
3434

35-
extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
36-
static int defer_greybus_control_init(const struct device *dev) {
37-
return gb_service_defer_init(dev, &greybus_control_init);
38-
}
39-
4035
#define DEFINE_GREYBUS_CONTROL(_num) \
4136
\
4237
BUILD_ASSERT(DT_PROP(DT_PARENT(DT_DRV_INST(_num)), bundle_class) \
@@ -54,9 +49,9 @@ static int defer_greybus_control_init(const struct device *dev) {
5449
}; \
5550
\
5651
DEVICE_DT_INST_DEFINE(_num, \
57-
defer_greybus_control_init, \
52+
greybus_control_init, \
5853
NULL, NULL, \
5954
&greybus_control_config_##_num, POST_KERNEL, \
60-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
55+
CONFIG_GREYBUS_CPORT_INIT_PRIORITY, NULL);
6156

6257
DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_CONTROL);

subsys/greybus/platform/deferred-init.c

Lines changed: 0 additions & 88 deletions
This file was deleted.

subsys/greybus/platform/gpio.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ static int greybus_gpio_control_init(const struct device *dev) {
124124
return 0;
125125
}
126126

127-
extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
128-
static int defer_greybus_gpio_control_init(const struct device *dev) {
129-
return gb_service_defer_init(dev, &greybus_gpio_control_init);
130-
}
131-
132127
#define DEFINE_GREYBUS_GPIO_CONTROL(_num) \
133128
\
134129
BUILD_ASSERT(DT_PROP(DT_PARENT(DT_DRV_INST(_num)), bundle_class) \
@@ -152,9 +147,9 @@ static int defer_greybus_gpio_control_init(const struct device *dev) {
152147
greybus_gpio_control_data_##_num; \
153148
\
154149
DEVICE_DT_INST_DEFINE(_num, \
155-
defer_greybus_gpio_control_init, NULL, \
150+
greybus_gpio_control_init, NULL, \
156151
&greybus_gpio_control_data_##_num, \
157152
&greybus_gpio_control_config_##_num, POST_KERNEL, \
158-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
153+
CONFIG_GREYBUS_CPORT_INIT_PRIORITY, NULL);
159154

160155
DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_GPIO_CONTROL);

subsys/greybus/platform/i2c.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ static int greybus_i2c_control_init(const struct device *dev) {
6161
return 0;
6262
}
6363

64-
extern int gb_service_defer_init(const struct device *, int (*init)(const struct device *));
65-
static int defer_greybus_i2c_control_init(const struct device *dev) {
66-
return gb_service_defer_init(dev, &greybus_i2c_control_init);
67-
}
68-
6964
#define DEFINE_GREYBUS_I2C_CONTROL(_num) \
7065
\
7166
BUILD_ASSERT(DT_PROP(DT_PARENT(DT_DRV_INST(_num)), bundle_class) \
@@ -89,9 +84,9 @@ static int defer_greybus_i2c_control_init(const struct device *dev) {
8984
greybus_i2c_control_data_##_num; \
9085
\
9186
DEVICE_INIT(i2c_i2c_control_##_num, "GBI2C_" #_num, \
92-
defer_greybus_i2c_control_init, \
87+
greybus_i2c_control_init, \
9388
&greybus_i2c_control_data_##_num, \
9489
&greybus_i2c_control_config_##_num, POST_KERNEL, \
95-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
90+
CONFIG_GREYBUS_CPORT_INIT_PRIORITY);
9691

9792
DT_INST_FOREACH_STATUS_OKAY(DEFINE_GREYBUS_I2C_CONTROL);

0 commit comments

Comments
 (0)