static int netconsole_init(void) { struct nc_priv *priv; struct console_device *cdev; priv = xzalloc(sizeof(*priv)); cdev = &priv->cdev; cdev->tstc = nc_tstc; cdev->putc = nc_putc; cdev->getc = nc_getc; g_priv = priv; priv->fifo = kfifo_alloc(1024); console_register(cdev); dev_add_param(&cdev->class_dev, "ip", nc_remoteip_set, NULL, 0); dev_add_param(&cdev->class_dev, "port", nc_port_set, NULL, 0); dev_set_param(&cdev->class_dev, "port", "6666"); printf("registered netconsole as %s%d\n", cdev->class_dev.name, cdev->class_dev.id); return 0; }
int console_register(struct console_device *newcdev) { struct device_d *dev = &newcdev->class_dev; int first = 0; char ch; strcpy(dev->name, "cs"); dev->type_data = newcdev; register_device(dev); if (newcdev->setbrg) { newcdev->baudrate_param.set = console_baudrate_set; newcdev->baudrate_param.name = "baudrate"; sprintf(newcdev->baudrate_string, "%d", CONFIG_BAUDRATE); console_baudrate_set(dev, &newcdev->baudrate_param, newcdev->baudrate_string); newcdev->baudrate_param.value = newcdev->baudrate_string; dev_add_param(dev, &newcdev->baudrate_param); } newcdev->active_param.set = console_std_set; newcdev->active_param.name = "active"; newcdev->active_param.value = newcdev->active; dev_add_param(dev, &newcdev->active_param); initialized = CONSOLE_INIT_FULL; #ifdef CONFIG_CONSOLE_ACTIVATE_ALL console_std_set(dev, &newcdev->active_param, "ioe"); #endif #ifdef CONFIG_CONSOLE_ACTIVATE_FIRST if (list_empty(&console_list)) { first = 1; console_std_set(dev, &newcdev->active_param, "ioe"); } #endif list_add_tail(&newcdev->list, &console_list); if (console_output_buffer) { while (kfifo_getc(console_output_buffer, &ch) == 0) console_putc(CONSOLE_STDOUT, ch); kfifo_free(console_output_buffer); console_output_buffer = NULL; } #ifndef CONFIG_HAS_EARLY_INIT if (first) display_banner(); #endif return 0; }
static int mxs_ocotp_probe(struct device_d *dev) { int err; struct ocotp_priv *priv = xzalloc(sizeof (*priv)); priv->base = dev_request_mem_region(dev, 0); priv->cdev.dev = dev; priv->cdev.ops = &mxs_ocotp_ops; priv->cdev.priv = priv; priv->cdev.size = cpu_is_mx23() ? 128 : 160; priv->cdev.name = DRIVERNAME; err = devfs_create(&priv->cdev); if (err < 0) return err; if (IS_ENABLED(CONFIG_MXS_OCOTP_WRITABLE)) { mxs_ocotp_ops.write = mxs_ocotp_cdev_write; err = dev_add_param(dev, "permanent_write_enable", mxs_ocotp_write_enable_set, NULL, 0); if (err < 0) return err; err = dev_set_param(dev, "permanent_write_enable", "0"); if (err < 0) return err; } return 0; }
int console_register(struct console_device *newcdev) { struct device_d *dev = &newcdev->class_dev; int first = 0; char ch; if (initialized == CONSOLE_UNINITIALIZED) console_init_early(); dev->id = DEVICE_ID_DYNAMIC; strcpy(dev->name, "cs"); if (newcdev->dev) dev_add_child(newcdev->dev, dev); register_device(dev); if (newcdev->setbrg) { dev_add_param(dev, "baudrate", console_baudrate_set, NULL, 0); dev_set_param(dev, "baudrate", __stringify(CONFIG_BAUDRATE)); } dev_add_param(dev, "active", console_std_set, NULL, 0); initialized = CONSOLE_INIT_FULL; #ifdef CONFIG_CONSOLE_ACTIVATE_ALL dev_set_param(dev, "active", "ioe"); #endif #ifdef CONFIG_CONSOLE_ACTIVATE_FIRST if (list_empty(&console_list)) { first = 1; dev_set_param(dev, "active", "ioe"); } #endif list_add_tail(&newcdev->list, &console_list); while (kfifo_getc(console_output_fifo, &ch) == 0) console_putc(CONSOLE_STDOUT, ch); if (first) barebox_banner(); return 0; }
int console_register(struct console_device *newcdev) { struct device_d *dev = &newcdev->class_dev; int activate = 0; if (initialized == CONSOLE_UNINITIALIZED) console_init_early(); dev->id = DEVICE_ID_DYNAMIC; strcpy(dev->name, "cs"); if (newcdev->dev) dev->parent = newcdev->dev; platform_device_register(dev); if (newcdev->setbrg) { dev_add_param(dev, "baudrate", console_baudrate_set, NULL, 0); dev_set_param(dev, "baudrate", __stringify(CONFIG_BAUDRATE)); } dev_add_param(dev, "active", console_std_set, NULL, 0); if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_FIRST)) { if (list_empty(&console_list)) activate = 1; } else if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_ALL)) { activate = 1; } if (newcdev->dev && of_device_is_stdout_path(newcdev->dev)) activate = 1; list_add_tail(&newcdev->list, &console_list); if (activate) dev_set_param(dev, "active", "ioe"); return 0; }
/** * Register an ATA drive behind an IDE like interface * @param dev The interface device * @param io ATA register file description * @return 0 on success */ int ata_port_register(struct ata_port *port) { int ret; port->class_dev.id = DEVICE_ID_DYNAMIC; strcpy(port->class_dev.name, "ata"); port->class_dev.parent = port->dev; ret = register_device(&port->class_dev); if (ret) return ret; dev_add_param(&port->class_dev, "probe", ata_set_probe, NULL, 0); return ret; }