All driver-model functions should have a device as the first parameter.
Update this function accordingly.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
struct acpi_table_header *header = &(spcr->header);
struct serial_device_info serial_info = {0};
ulong serial_address, serial_offset;
+ struct udevice *dev;
uint serial_config;
uint serial_width;
int access_size;
break;
}
- ret = serial_getconfig(&serial_config);
+ ret = uclass_first_device_err(UCLASS_SERIAL, &dev);
+ if (!ret)
+ ret = serial_getconfig(dev, &serial_config);
if (ret)
serial_config = SERIAL_DEFAULT_CONFIG;
ops->setbrg(gd->cur_serial_dev, gd->baudrate);
}
-int serial_getconfig(uint *config)
+int serial_getconfig(struct udevice *dev, uint *config)
{
struct dm_serial_ops *ops;
- if (!gd->cur_serial_dev)
- return 0;
-
- ops = serial_get_ops(gd->cur_serial_dev);
+ ops = serial_get_ops(dev);
if (ops->getconfig)
- return ops->getconfig(gd->cur_serial_dev, config);
+ return ops->getconfig(dev, config);
return 0;
}
/* Access the serial operations for a device */
#define serial_get_ops(dev) ((struct dm_serial_ops *)(dev)->driver->ops)
-int serial_getconfig(uint *config);
+int serial_getconfig(struct udevice *dev, uint *config);
int serial_setconfig(uint config);
int serial_getinfo(struct serial_device_info *info);
* sandbox_serial driver
*/
ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG));
- ut_assertok(serial_getconfig(&value_serial));
+ ut_assertok(serial_getconfig(dev_serial, &value_serial));
ut_assert(value_serial == SERIAL_DEFAULT_CONFIG);
ut_assertok(serial_getinfo(&info_serial));
ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN);
/*
* test with a parameter which is NULL pointer
*/
- ut_asserteq(-EINVAL, serial_getconfig(NULL));
+ ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL));
ut_asserteq(-EINVAL, serial_getinfo(NULL));
/*
* test with a serial config which is not supported by