Skip to content

devices: make device name field optional #49352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions boards/arm/nrf9160dk_nrf52840/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static int reset_pin_configure(void)
gpio_dt_flags_t flags = GET_FLAGS(reset_input, gpios, 0);

if (!device_is_ready(gpio)) {
LOG_ERR("%s is not ready", gpio->name);
LOG_ERR("%s is not ready", device_name_get(gpio));
return -ENODEV;
}

Expand Down Expand Up @@ -168,7 +168,7 @@ static int init(const struct device *dev)
gpio_flags_t flags = cfg->flags;

if (!device_is_ready(cfg->gpio)) {
LOG_ERR("%s is not ready", cfg->gpio->name);
LOG_ERR("%s is not ready", device_name_get(cfg->gpio));
return -ENODEV;
}

Expand Down
4 changes: 2 additions & 2 deletions boards/arm/pinetime_devkit0/key_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ static int pinetime_key_out_init(const struct device *arg)

if (!device_is_ready(key_out.port)) {
LOG_ERR("key out gpio device %s is not ready",
key_out.port->name);
device_name_get(key_out.port));
return -ENODEV;
}

ret = gpio_pin_configure_dt(&key_out, GPIO_OUTPUT_ACTIVE);
if (ret != 0) {
LOG_ERR("failed to configure %s pin %d (err %d)",
key_out.port->name, key_out.pin, ret);
device_name_get(key_out.port), key_out.pin, ret);
return ret;
}

Expand Down
9 changes: 9 additions & 0 deletions doc/develop/optimizations/footprint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ the running application and to provide means for debugging and error handling:
:kconfig:option:`CONFIG_DEBUG`
This option can be disabled for production builds

Others
******

:kconfig:option:`CONFIG_DEVICE_STORE_NAME`
When this option is disabled, devices will not have a unique human readable
name (:c:member:`device.name`). If you set this option to ``n``, you will no
longer be able to use :c:func:`device_get_binding`, because it looks up
devices by name. Use :c:macro:`DEVICE_DT_GET` or another related macro
instead.

MPU/MMU Support
***************
Expand Down
2 changes: 1 addition & 1 deletion doc/kernel/services/threads/workqueue.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ unchanged and the associated error message will not be printed.
{
struct device_info *the_device =
CONTAINER_OF(item, struct device_info, work);
printk("Got error on device %s\n", the_device->name);
printk("Got error on device %s\n", device_name_get(the_device));
}

/* initialize name info for a device */
Expand Down
6 changes: 3 additions & 3 deletions doc/services/smf/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -422,22 +422,22 @@ Code::

if (!device_is_ready(button.port)) {
printk("Error: button device %s is not ready\n",
button.port->name);
device_name_get(button.port));
return;
}

ret = gpio_pin_configure_dt(&button, GPIO_INPUT);
if (ret != 0) {
printk("Error %d: failed to configure %s pin %d\n",
ret, button.port->name, button.pin);
ret, device_name_get(button.port), button.pin);
return;
}

ret = gpio_pin_interrupt_configure_dt(&button,
GPIO_INT_EDGE_TO_ACTIVE);
if (ret != 0) {
printk("Error %d: failed to configure interrupt on %s pin %d\n",
ret, button.port->name, button.pin);
ret, device_name_get(button.port), button.pin);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/adc/adc_ads1119.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static int ads1119_init(const struct device *dev)

rc = ads1119_read_reg(dev, ADS1119_REG_STATUS, &status);
if (rc) {
LOG_ERR("Could not get %s status", dev->name);
LOG_ERR("Could not get %s status", device_name_get(dev));
return rc;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/adc/adc_ads1x1x.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ static int ads1x1x_init(const struct device *dev)
k_sem_init(&data->acq_sem, 0, 1);

if (!device_is_ready(config->bus.bus)) {
LOG_ERR("I2C bus %s not ready", config->bus.bus->name);
LOG_ERR("I2C bus %s not ready", device_name_get(config->bus.bus));
return -ENODEV;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/adc/adc_lmp90xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ static int lmp90xxx_init(const struct device *dev)
data->ura = LMP90XXX_INVALID_URA;

if (!spi_is_ready(&config->bus)) {
LOG_ERR("SPI bus %s not ready", config->bus.bus->name);
LOG_ERR("SPI bus %s not ready", device_name_get(config->bus.bus));
return -ENODEV;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/adc/adc_nrfx_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static int init_adc(const struct device *dev)

if (result != NRFX_SUCCESS) {
LOG_ERR("Failed to initialize device: %s",
dev->name);
device_name_get(dev));
return -EBUSY;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/adc/adc_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static struct adc_hdl {
static struct adc_hdl *get_adc(const char *device_label)
{
for (int i = 0; i < ARRAY_SIZE(adc_list); i++) {
if (!strcmp(device_label, adc_list[i].dev->name)) {
if (!strcmp(device_label, device_name_get(adc_list[i].dev))) {
return &adc_list[i];
}
}
Expand Down Expand Up @@ -347,7 +347,7 @@ static int cmd_adc_print(const struct shell *shell, size_t argc, char **argv)
"Acquisition Time: %u\n"
"Channel ID: %u\n"
"Resolution: %u",
adc->dev->name,
device_name_get(adc->dev),
chosen_gain,
chosen_reference,
adc->channel_config.acquisition_time,
Expand Down Expand Up @@ -408,7 +408,7 @@ static void cmd_adc_dev_get(size_t idx, struct shell_static_entry *entry)
{
/* -1 because the last element in the list is a "list terminator" */
if (idx < ARRAY_SIZE(adc_list) - 1) {
entry->syntax = adc_list[idx].dev->name;
entry->syntax = device_name_get(adc_list[idx].dev);
entry->handler = NULL;
entry->subcmd = &sub_adc_cmds;
entry->help = "Select subcommand for ADC property label.\n";
Expand Down
2 changes: 1 addition & 1 deletion drivers/adc/adc_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ static void adc_stm32_isr(const struct device *dev)

adc_context_on_sampling_done(&data->ctx, dev);

LOG_DBG("%s ISR triggered.", dev->name);
LOG_DBG("%s ISR triggered.", device_name_get(dev));
}

static int adc_stm32_read(const struct device *dev,
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/can_loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static int can_loopback_send(const struct device *dev,
int ret;

LOG_DBG("Sending %d bytes on %s. Id: 0x%x, ID type: %s %s",
frame->dlc, dev->name, frame->id,
frame->dlc, device_name_get(dev), frame->id,
frame->id_type == CAN_STANDARD_IDENTIFIER ?
"standard" : "extended",
frame->rtr == CAN_DATAFRAME ? "" : ", RTR frame");
Expand Down Expand Up @@ -429,7 +429,7 @@ static int can_loopback_init(const struct device *dev)
return -1;
}

LOG_INF("Init of %s done", dev->name);
LOG_INF("Init of %s done", device_name_get(dev));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/can/can_mcp2515.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ static int mcp2515_init(const struct device *dev)
}

if (!spi_is_ready(&dev_cfg->bus)) {
LOG_ERR("SPI bus %s not ready", dev_cfg->bus.bus->name);
LOG_ERR("SPI bus %s not ready", device_name_get(dev_cfg->bus.bus));
return -ENODEV;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/can/can_native_posix_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static int can_npl_send(const struct device *dev, const struct can_frame *frame,
int ret = -EIO;

LOG_DBG("Sending %d bytes on %s. Id: 0x%x, ID type: %s %s",
frame->dlc, dev->name, frame->id,
frame->dlc, device_name_get(dev), frame->id,
frame->id_type == CAN_STANDARD_IDENTIFIER ?
"standard" : "extended",
frame->rtr == CAN_DATAFRAME ? "" : ", RTR frame");
Expand Down Expand Up @@ -469,7 +469,7 @@ static int can_npl_init(const struct device *dev)
CONFIG_CAN_NATIVE_POSIX_LINUX_RX_THREAD_PRIORITY,
0, K_NO_WAIT);

LOG_DBG("Init of %s done", dev->name);
LOG_DBG("Init of %s done", device_name_get(dev));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/can/can_rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
"Id: 0x%x, "
"ID type: %s, "
"Remote Frame: %s"
, frame->dlc, dev->name
, frame->dlc, device_name_get(dev)
, frame->id
, frame->id_type == CAN_STANDARD_IDENTIFIER ?
"standard" : "extended"
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/can_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ static void cmd_can_device_name(size_t idx, struct shell_static_entry *entry)
{
const struct device *dev = shell_device_lookup(idx, NULL);

entry->syntax = (dev != NULL) ? dev->name : NULL;
entry->syntax = (dev != NULL) ? device_name_get(dev) : NULL;
entry->handler = NULL;
entry->help = NULL;
entry->subcmd = NULL;
Expand Down Expand Up @@ -828,7 +828,7 @@ static void cmd_can_device_name_mode(size_t idx, struct shell_static_entry *entr
{
const struct device *dev = shell_device_lookup(idx, NULL);

entry->syntax = (dev != NULL) ? dev->name : NULL;
entry->syntax = (dev != NULL) ? device_name_get(dev) : NULL;
entry->handler = NULL;
entry->help = NULL;
entry->subcmd = &dsub_can_mode;
Expand Down
2 changes: 1 addition & 1 deletion drivers/can/can_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ static int can_stm32_send(const struct device *dev, const struct can_frame *fram
"Id: 0x%x, "
"ID type: %s, "
"Remote Frame: %s"
, frame->dlc, dev->name
, frame->dlc, device_name_get(dev)
, frame->id
, frame->id_type == CAN_STANDARD_IDENTIFIER ?
"standard" : "extended"
Expand Down
2 changes: 1 addition & 1 deletion drivers/console/ipm_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static int ipm_console_init(const struct device *dev)

ipm_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
if (!device_is_ready(ipm_dev)) {
LOG_ERR("%s is not ready", ipm_dev->name);
LOG_ERR("%s is not ready", device_name_get(ipm_dev));
return -ENODEV;
}

Expand Down
22 changes: 11 additions & 11 deletions drivers/console/uart_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static int uart_mux_consume_ringbuf(struct uart_mux *uart_mux)
char tmp[sizeof("RECV muxed ") + 10];

snprintk(tmp, sizeof(tmp), "RECV muxed %s",
uart_mux->uart->name);
device_name_get(uart_mux->uart));
LOG_HEXDUMP_DBG(data, len, tmp);
}

Expand Down Expand Up @@ -216,7 +216,7 @@ static void uart_mux_tx_work(struct k_work *work)
sizeof(CONFIG_UART_MUX_DEVICE_NAME)];

snprintk(tmp, sizeof(tmp), "SEND %s",
dev_data->dev->name);
device_name_get(dev_data->dev));
LOG_HEXDUMP_DBG(data, len, tmp);
}

Expand All @@ -241,7 +241,7 @@ static int uart_mux_init(const struct device *dev)
k_work_init(&dev_data->cb_work, uart_mux_cb_work);

LOG_DBG("Device %s dev %p dev_data %p cfg %p created",
dev->name, dev, dev_data, dev->config);
device_name_get(dev), dev, dev_data, dev->config);

return 0;
}
Expand Down Expand Up @@ -324,7 +324,7 @@ static void dlci_created_cb(struct gsm_dlci *dlci, bool connected,
dev_data->status = UART_MUX_DISCONNECTED;
}

LOG_DBG("%s %s", dev_data->dev->name,
LOG_DBG("%s %s", device_name_get(dev_data->dev),
dev_data->status == UART_MUX_CONNECTED ? "connected" :
"disconnected");

Expand Down Expand Up @@ -370,7 +370,7 @@ static int init_real_uart(const struct device *mux, const struct device *uart,
real_uart->mux = gsm_mux_create(mux);

LOG_DBG("Initializing UART %s and GSM mux %p",
real_uart->uart->name, (void *)real_uart->mux);
device_name_get(real_uart->uart), (void *)real_uart->mux);

if (!real_uart->mux) {
real_uart->uart = NULL;
Expand Down Expand Up @@ -410,7 +410,7 @@ static int attach(const struct device *mux_uart, const struct device *uart,
}

LOG_DBG("Attach DLCI %d (%s) to %s", dlci_address,
mux_uart->name, uart->name);
device_name_get(mux_uart), device_name_get(uart));

SYS_SLIST_FOR_EACH_NODE_SAFE(&uart_mux_data_devlist, sn, sns) {
struct uart_mux_dev_data *dev_data =
Expand Down Expand Up @@ -557,7 +557,7 @@ static int uart_mux_fifo_read(const struct device *dev, uint8_t *rx_data,
}

LOG_DBG("%s size %d rx_ringbuf space %u",
dev->name, size,
device_name_get(dev), size,
ring_buf_space_get(dev_data->rx_ringbuf));

len = ring_buf_get(dev_data->rx_ringbuf, rx_data, size);
Expand Down Expand Up @@ -801,7 +801,7 @@ int uart_mux_send(const struct device *uart, const uint8_t *buf, size_t size)
char tmp[sizeof("SEND muxed ") + 10];

snprintk(tmp, sizeof(tmp), "SEND muxed %s",
dev_data->real_uart->uart->name);
device_name_get(dev_data->real_uart->uart));
LOG_HEXDUMP_DBG(buf, size, tmp);
}

Expand All @@ -823,15 +823,15 @@ int uart_mux_recv(const struct device *mux, struct gsm_dlci *dlci,
struct uart_mux_dev_data *dev_data = mux->data;
size_t wrote = 0;

LOG_DBG("%s: dlci %p data %p len %zd", mux->name, (void *)dlci,
data, len);
LOG_DBG("%s: dlci %p data %p len %zd", device_name_get(mux),
(void *)dlci, data, len);

if (IS_ENABLED(CONFIG_UART_MUX_VERBOSE_DEBUG)) {
char tmp[sizeof("RECV _x") +
sizeof(CONFIG_UART_MUX_DEVICE_NAME)];

snprintk(tmp, sizeof(tmp), "RECV %s",
dev_data->dev->name);
device_name_get(dev_data->dev));
LOG_HEXDUMP_DBG(data, len, tmp);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/counter/counter_gecko_rtcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ static int counter_gecko_init(const struct device *dev)
/* Configure & enable module interrupts */
dev_cfg->irq_config();

LOG_INF("Device %s initialized", dev->name);
LOG_INF("Device %s initialized", device_name_get(dev));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/counter/counter_sam_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static int counter_sam_initialize(const struct device *dev)
#endif
dev_cfg->irq_config_func(dev);

LOG_INF("Device %s initialized", dev->name);
LOG_INF("Device %s initialized", device_name_get(dev));

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/counter/rtc_mcp7940n.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ static int mcp7940n_init(const struct device *dev)
k_sem_init(&data->lock, 0, 1);

if (!device_is_ready(cfg->i2c.bus)) {
LOG_ERR("I2C device %s is not ready", cfg->i2c.bus->name);
LOG_ERR("I2C device %s is not ready", device_name_get(cfg->i2c.bus));
rc = -ENODEV;
goto out;
}
Expand Down Expand Up @@ -693,7 +693,7 @@ static int mcp7940n_init(const struct device *dev)

if (!device_is_ready(cfg->int_gpios.port)) {
LOG_ERR("Port device %s is not ready",
cfg->int_gpios.port->name);
device_name_get(cfg->int_gpios.port));
rc = -ENODEV;
goto out;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/dac/dac_dacx0508.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static int dacx0508_init(const struct device *dev)
int ret;

if (!spi_is_ready(&config->bus)) {
LOG_ERR("SPI bus %s not ready", config->bus.bus->name);
LOG_ERR("SPI bus %s not ready", device_name_get(config->bus.bus));
return -ENODEV;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/dac/dac_mcp4728.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static int dac_mcp4728_init(const struct device *dev)
const struct mcp4728_config *config = dev->config;

if (!device_is_ready(config->bus.bus)) {
LOG_ERR("%s device not found", config->bus.bus->name);
LOG_ERR("%s device not found", device_name_get(config->bus.bus));
return -ENODEV;
}
return 0;
Expand Down
Loading