Skip to content

Commit f29eb5d

Browse files
committed
compliance: align source files to clang-format rules
Refs: #3 Signed-off-by: Natalia Pluta <pluta.natalia.m@gmail.com>
1 parent d5244a2 commit f29eb5d

5 files changed

Lines changed: 36 additions & 52 deletions

File tree

app/src/main.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int main(void)
2121
int ret;
2222
unsigned int period_ms = BLINK_PERIOD_MS_MAX;
2323
const struct device *sensor, *blink;
24-
struct sensor_value last_val = { 0 }, val;
24+
struct sensor_value last_val = {0}, val;
2525

2626
printk("Zephyr Fire Detection System %s\n", APP_VERSION_STRING);
2727

@@ -65,8 +65,7 @@ int main(void)
6565
period_ms -= BLINK_PERIOD_MS_STEP;
6666
}
6767

68-
printk("Proximity detected, setting LED period to %u ms\n",
69-
period_ms);
68+
printk("Proximity detected, setting LED period to %u ms\n", period_ms);
7069
blink_set_period_ms(blink, period_ms);
7170
}
7271

@@ -77,4 +76,3 @@ int main(void)
7776

7877
return 0;
7978
}
80-

drivers/blink/gpio_led.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ static void blink_gpio_led_on_timer_expire(struct k_timer *timer)
3737
}
3838
}
3939

40-
static int blink_gpio_led_set_period_ms(const struct device *dev,
41-
unsigned int period_ms)
40+
static int blink_gpio_led_set_period_ms(const struct device *dev, unsigned int period_ms)
4241
{
4342
const struct blink_gpio_led_config *config = dev->config;
4443
struct blink_gpio_led_data *data = dev->data;
@@ -78,24 +77,21 @@ static int blink_gpio_led_init(const struct device *dev)
7877
k_timer_user_data_set(&data->timer, (void *)dev);
7978

8079
if (config->period_ms > 0) {
81-
k_timer_start(&data->timer, K_MSEC(config->period_ms),
82-
K_MSEC(config->period_ms));
80+
k_timer_start(&data->timer, K_MSEC(config->period_ms), K_MSEC(config->period_ms));
8381
}
8482

8583
return 0;
8684
}
8785

88-
#define BLINK_GPIO_LED_DEFINE(inst) \
89-
static struct blink_gpio_led_data data##inst; \
90-
\
91-
static const struct blink_gpio_led_config config##inst = { \
92-
.led = GPIO_DT_SPEC_INST_GET(inst, led_gpios), \
93-
.period_ms = DT_INST_PROP_OR(inst, blink_period_ms, 0U), \
94-
}; \
95-
\
96-
DEVICE_DT_INST_DEFINE(inst, blink_gpio_led_init, NULL, &data##inst, \
97-
&config##inst, POST_KERNEL, \
98-
CONFIG_BLINK_INIT_PRIORITY, \
99-
&blink_gpio_led_api);
86+
#define BLINK_GPIO_LED_DEFINE(inst) \
87+
static struct blink_gpio_led_data data##inst; \
88+
\
89+
static const struct blink_gpio_led_config config##inst = { \
90+
.led = GPIO_DT_SPEC_INST_GET(inst, led_gpios), \
91+
.period_ms = DT_INST_PROP_OR(inst, blink_period_ms, 0U), \
92+
}; \
93+
\
94+
DEVICE_DT_INST_DEFINE(inst, blink_gpio_led_init, NULL, &data##inst, &config##inst, \
95+
POST_KERNEL, CONFIG_BLINK_INIT_PRIORITY, &blink_gpio_led_api);
10096

10197
DT_INST_FOREACH_STATUS_OKAY(BLINK_GPIO_LED_DEFINE)

drivers/sensor/example_sensor/example_sensor.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ struct example_sensor_config {
2020
struct gpio_dt_spec input;
2121
};
2222

23-
static int example_sensor_sample_fetch(const struct device *dev,
24-
enum sensor_channel chan)
23+
static int example_sensor_sample_fetch(const struct device *dev, enum sensor_channel chan)
2524
{
2625
const struct example_sensor_config *config = dev->config;
2726
struct example_sensor_data *data = dev->data;
@@ -31,9 +30,8 @@ static int example_sensor_sample_fetch(const struct device *dev,
3130
return 0;
3231
}
3332

34-
static int example_sensor_channel_get(const struct device *dev,
35-
enum sensor_channel chan,
36-
struct sensor_value *val)
33+
static int example_sensor_channel_get(const struct device *dev, enum sensor_channel chan,
34+
struct sensor_value *val)
3735
{
3836
struct example_sensor_data *data = dev->data;
3937

@@ -71,16 +69,15 @@ static int example_sensor_init(const struct device *dev)
7169
return 0;
7270
}
7371

74-
#define EXAMPLE_SENSOR_INIT(i) \
75-
static struct example_sensor_data example_sensor_data_##i; \
76-
\
77-
static const struct example_sensor_config example_sensor_config_##i = {\
78-
.input = GPIO_DT_SPEC_INST_GET(i, input_gpios), \
79-
}; \
80-
\
81-
DEVICE_DT_INST_DEFINE(i, example_sensor_init, NULL, \
82-
&example_sensor_data_##i, \
83-
&example_sensor_config_##i, POST_KERNEL, \
72+
#define EXAMPLE_SENSOR_INIT(i) \
73+
static struct example_sensor_data example_sensor_data_##i; \
74+
\
75+
static const struct example_sensor_config example_sensor_config_##i = { \
76+
.input = GPIO_DT_SPEC_INST_GET(i, input_gpios), \
77+
}; \
78+
\
79+
DEVICE_DT_INST_DEFINE(i, example_sensor_init, NULL, &example_sensor_data_##i, \
80+
&example_sensor_config_##i, POST_KERNEL, \
8481
CONFIG_SENSOR_INIT_PRIORITY, &example_sensor_api);
8582

8683
DT_INST_FOREACH_STATUS_OKAY(EXAMPLE_SENSOR_INIT)

include/app/drivers/blink.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ __subsystem struct blink_driver_api {
7676
* @retval -EINVAL if @p period_ms can not be set.
7777
* @retval -errno Other negative errno code on failure.
7878
*/
79-
__syscall int blink_set_period_ms(const struct device *dev,
80-
unsigned int period_ms);
79+
__syscall int blink_set_period_ms(const struct device *dev, unsigned int period_ms);
8180

82-
static inline int z_impl_blink_set_period_ms(const struct device *dev,
83-
unsigned int period_ms)
81+
static inline int z_impl_blink_set_period_ms(const struct device *dev, unsigned int period_ms)
8482
{
8583
__ASSERT_NO_MSG(DEVICE_API_IS(blink, dev));
8684

tests/lib/custom/src/main.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,18 @@
2020
ZTEST(custom_lib, test_get_value)
2121
{
2222
/* Verify standard behavior */
23-
zassert_equal(custom_get_value(INT_MIN), INT_MIN,
24-
"get_value failed input of INT_MIN");
23+
zassert_equal(custom_get_value(INT_MIN), INT_MIN, "get_value failed input of INT_MIN");
2524
zassert_equal(custom_get_value(INT_MIN + 1), INT_MIN + 1,
26-
"get_value failed input of INT_MIN + 1");
27-
zassert_equal(custom_get_value(-1), -1,
28-
"get_value failed input of -1");
29-
zassert_equal(custom_get_value(1), 1,
30-
"get_value failed input of 1");
25+
"get_value failed input of INT_MIN + 1");
26+
zassert_equal(custom_get_value(-1), -1, "get_value failed input of -1");
27+
zassert_equal(custom_get_value(1), 1, "get_value failed input of 1");
3128
zassert_equal(custom_get_value(INT_MAX - 1), INT_MAX - 1,
32-
"get_value failed input of INT_MAX - 1");
33-
zassert_equal(custom_get_value(INT_MAX), INT_MAX,
34-
"get_value failed input of INT_MAX");
29+
"get_value failed input of INT_MAX - 1");
30+
zassert_equal(custom_get_value(INT_MAX), INT_MAX, "get_value failed input of INT_MAX");
3531

3632
/* Verify override behavior */
37-
zassert_equal(custom_get_value(0),
38-
CONFIG_CUSTOM_GET_VALUE_DEFAULT,
39-
"get_value failed input of 0");
33+
zassert_equal(custom_get_value(0), CONFIG_CUSTOM_GET_VALUE_DEFAULT,
34+
"get_value failed input of 0");
4035
}
4136

4237
ZTEST_SUITE(custom_lib, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)