Skip to content

Commit

Permalink
grlib-multi: set device id values in create_dev
Browse files Browse the repository at this point in the history
JIRA: RTOS-748
  • Loading branch information
lukileczo committed Feb 22, 2024
1 parent 5106fa2 commit ca1dc91
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions multi/grlib-multi/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ int adc_createDevs(oid_t *oid)
return -1;
}

oid->id = id_adc0 + i;
if (create_dev(oid, buf) < 0) {
return -1;
}
Expand Down
1 change: 1 addition & 0 deletions multi/grlib-multi/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ int gpio_createDevs(oid_t *oid)
return -1;
}

oid->id = id_gpio0 + i;
if (create_dev(oid, buf) < 0) {
return -1;
}
Expand Down
12 changes: 11 additions & 1 deletion multi/grlib-multi/grlib-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <sys/threads.h>
#include <posix/utils.h>

#include <phoenix/ioctl.h>

#if PSEUDODEV
#include <pseudodev.h>
#endif
Expand Down Expand Up @@ -97,6 +99,7 @@ static int multi_createDevs(void)
}

for (int i = 0; pseudo_devs[i] != NULL; i++) {
multi_common.multiOid.id = id_pseudoNull + i;
if (create_dev(&multi_common.multiOid, pseudo_devs[i]) < 0) {
LOG_ERROR("Failed to create %s device file", pseudo_devs[i]);
return -1;
Expand Down Expand Up @@ -238,7 +241,14 @@ static void multi_thread(void *arg)

static void uart_dispatchMsg(msg_t *msg)
{
id_t id = multi_getId(msg);
id_t id;

if (msg->type == mtDevCtl) {
id = ((ioctl_in_t *)msg->i.raw)->id;
}
else {
id = multi_getId(msg);
}

switch (id) {
case id_console:
Expand Down
1 change: 1 addition & 0 deletions multi/grlib-multi/spacewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ int spw_createDevs(oid_t *oid)
return -1;
}

oid->id = id_spw0 + i;
if (create_dev(oid, buf) < 0) {
return -1;
}
Expand Down
1 change: 1 addition & 0 deletions multi/grlib-multi/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ int uart_createDevs(oid_t *oid)
return -1;
}

oid->id = id_uart0 + i;
if (create_dev(oid, buf) < 0) {
return -1;
}
Expand Down

0 comments on commit ca1dc91

Please sign in to comment.