9
0
Fork 0

console: Use dev_add_param_int for baudrate parameter

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-04-06 11:25:28 +02:00
parent 3c9b5c1a61
commit ab855df99f
3 changed files with 18 additions and 25 deletions

View File

@ -99,33 +99,22 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
return 0;
}
static int console_baudrate_set(struct device_d *dev, struct param_d *param,
const char *val)
static int console_baudrate_set(struct param_d *param, void *priv)
{
struct console_device *cdev = to_console_dev(dev);
int baudrate;
char baudstr[16];
struct console_device *cdev = priv;
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);
cdev->baudrate);
mdelay(50);
cdev->setbrg(cdev, baudrate);
cdev->setbrg(cdev, 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);
cdev->setbrg(cdev, cdev->baudrate);
return 0;
}
@ -155,8 +144,9 @@ int console_register(struct console_device *newcdev)
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));
newcdev->baudrate = CONFIG_BAUDRATE;
dev_add_param_int(dev, "baudrate", console_baudrate_set,
NULL, &newcdev->baudrate, "%u", newcdev);
}
dev_add_param(dev, "active", console_std_set, NULL, 0);

View File

@ -1461,15 +1461,16 @@ static int mci_set_probe(struct param_d *param, void *priv)
struct mci *mci = priv;
int rc;
if (!mci->probe)
return 0;
rc = mci_check_if_already_initialized(mci);
if (rc != 0)
return 0;
if (mci->probe) {
rc = mci_card_probe(mci);
if (rc != 0)
return rc;
}
rc = mci_card_probe(mci);
if (rc != 0)
return rc;
return 0;
}
@ -1494,8 +1495,8 @@ static int mci_probe(struct device_d *mci_dev)
dev_info(mci->host->hw_dev, "registered as %s\n", dev_name(mci_dev));
mci->param_probe = dev_add_param_int(mci_dev, "probe",
mci_set_probe, NULL, &mci->probe, "%d", mci);
mci->param_probe = dev_add_param_bool(mci_dev, "probe",
mci_set_probe, NULL, &mci->probe, mci);
if (IS_ERR(mci->param_probe)) {
dev_dbg(mci->mci_dev, "Failed to add 'probe' parameter to the MCI device\n");

View File

@ -42,6 +42,8 @@ struct console_device {
unsigned char f_caps;
unsigned char f_active;
unsigned int baudrate;
};
int console_register(struct console_device *cdev);