Exemple #1
0
static int console_std_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct console_device *cdev = to_console_dev(dev);
	char active[4];
	unsigned int flag = 0, i = 0;

	if (!val)
		dev_param_set_generic(dev, param, NULL);

	if (strchr(val, 'i') && cdev->f_caps & CONSOLE_STDIN) {
		active[i++] = 'i';
		flag |= CONSOLE_STDIN;
	}

	if (strchr(val, 'o') && cdev->f_caps & CONSOLE_STDOUT) {
		active[i++] = 'o';
		flag |= CONSOLE_STDOUT;
	}

	if (strchr(val, 'e') && cdev->f_caps & CONSOLE_STDERR) {
		active[i++] = 'e';
		flag |= CONSOLE_STDERR;
	}

	active[i] = 0;
	cdev->f_active = flag;

	dev_param_set_generic(dev, param, active);

	return 0;
}
Exemple #2
0
static int console_baudrate_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct console_device *cdev = to_console_dev(dev);
	int baudrate;
	char baudstr[16];
	unsigned char c;

	if (!val)
		dev_param_set_generic(dev, param, NULL);

	baudrate = simple_strtoul(val, NULL, 10);

	if (cdev->f_active) {
		printf("## Switch baudrate to %d bps and press ENTER ...\n",
			baudrate);
		mdelay(50);
		cdev->setbrg(cdev, baudrate);
		mdelay(50);
		do {
			c = getc();
		} while (c != '\r' && c != '\n');
	} else
		cdev->setbrg(cdev, baudrate);

	sprintf(baudstr, "%d", baudrate);
	dev_param_set_generic(dev, param, baudstr);

	return 0;
}
Exemple #3
0
static int console_std_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct console_device *cdev = to_console_dev(dev);
	char active[4];
	unsigned int flag = 0, i = 0;

	if (!val)
		dev_param_set_generic(dev, param, NULL);

	if (strchr(val, 'i') && cdev->f_caps & CONSOLE_STDIN) {
		active[i++] = 'i';
		flag |= CONSOLE_STDIN;
	}

	if (strchr(val, 'o') && cdev->f_caps & CONSOLE_STDOUT) {
		active[i++] = 'o';
		flag |= CONSOLE_STDOUT;
	}

	if (strchr(val, 'e') && cdev->f_caps & CONSOLE_STDERR) {
		active[i++] = 'e';
		flag |= CONSOLE_STDERR;
	}

	active[i] = 0;
	cdev->f_active = flag;

	dev_param_set_generic(dev, param, active);

	if (initialized < CONSOLE_INIT_FULL) {
		char ch;
		initialized = CONSOLE_INIT_FULL;
		PUTS_LL("Switch to console [");
		PUTS_LL(dev_name(dev));
		PUTS_LL("]\n");
		barebox_banner();
		while (kfifo_getc(console_output_fifo, &ch) == 0)
			console_putc(CONSOLE_STDOUT, ch);
	}

	return 0;
}
Exemple #4
0
static int nc_remoteip_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct nc_priv *priv = g_priv;
	IPaddr_t ip;
	int ret;

	if (!val)
		dev_param_set_generic(dev, param, NULL);

	if (string_to_ip(val, &ip))
		return -EINVAL;

	priv->ip = ip;
	ret = nc_init();
	if (ret)
		return ret;

	dev_param_set_generic(dev, param, val);

	return 0;
}
Exemple #5
0
static int nc_port_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct nc_priv *priv = g_priv;
	char portstr[16];
	int port;

	if (!val)
		dev_param_set_generic(dev, param, NULL);

	port = simple_strtoul(val, NULL, 10);
	if (port > 65535)
		return -EINVAL;

	priv->port = port;
	nc_init();

	sprintf(portstr, "%d", port);
	dev_param_set_generic(dev, param, portstr);

	return 0;
}
Exemple #6
0
static int console_std_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct console_device *cdev = to_console_dev(dev);
	char active[4];
	unsigned int flag = 0, i = 0;

	if (val) {
		if (strchr(val, 'i') && cdev->getc) {
			active[i++] = 'i';
			flag |= CONSOLE_STDIN;
		}

		if (cdev->putc) {
			if (strchr(val, 'o')) {
				active[i++] = 'o';
				flag |= CONSOLE_STDOUT;
			}

			if (strchr(val, 'e')) {
				active[i++] = 'e';
				flag |= CONSOLE_STDERR;
			}
		}
	}

	if (flag && !cdev->f_active) {
		/* The device is being activated, set its baudrate */
		if (cdev->setbrg)
			cdev->setbrg(cdev, cdev->baudrate);
	}

	active[i] = 0;
	cdev->f_active = flag;

	dev_param_set_generic(dev, param, active);

	if (initialized < CONSOLE_INIT_FULL) {
		char ch;
		initialized = CONSOLE_INIT_FULL;
		puts_ll("Switch to console [");
		puts_ll(dev_name(dev));
		puts_ll("]\n");
		barebox_banner();
		while (kfifo_getc(console_output_fifo, &ch) == 0)
			console_putc(CONSOLE_STDOUT, ch);
	}

	return 0;
}
Exemple #7
0
static int mxs_ocotp_write_enable_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	unsigned long write_enable;

	if (!val)
		return -EINVAL;

	write_enable = simple_strtoul(val, NULL, 0);
	if (write_enable > 1)
		return -EINVAL;

	return dev_param_set_generic(dev, param, write_enable ? "1" : "0");
}
static int ata_set_probe(struct device_d *class_dev, struct param_d *param,
				const char *val)
{
	struct ata_port *port = container_of(class_dev, struct ata_port, class_dev);
	int ret, probe;

	if (port->initialized) {
		dev_info(class_dev, "already initialized\n");
		return 0;
	}

	probe = !!simple_strtoul(val, NULL, 0);
	if (!probe)
		return 0;

	ret = ata_port_init(port);
	if (ret)
		return ret;

	port->initialized = 1;

	return dev_param_set_generic(class_dev, param, "1");
}