]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: serial: Adjust serial_getconfig() to use proper API
authorSimon Glass <sjg@chromium.org>
Fri, 28 Dec 2018 21:23:08 +0000 (14:23 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 15 Jan 2019 00:47:13 +0000 (17:47 -0700)
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>
arch/x86/lib/acpi_table.c
drivers/serial/serial-uclass.c
include/serial.h
test/dm/serial.c

index 79bc2000bdaa14df5370681e498d2a957bb670f0..bfcf2adbf12288a5d532b7a52acc5466322b17d3 100644 (file)
@@ -342,6 +342,7 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
        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;
@@ -431,7 +432,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
                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;
 
index ffcd6d15af2b07049fc5973a68c4478b2fc510ce..81f1067f42232d95e7772f57785063dded70c8f0 100644 (file)
@@ -294,16 +294,13 @@ void serial_setbrg(void)
                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;
 }
index fa7e0130bd2f2b3b3c21fa87fe1744d82599bc52..5ba031ab534a68a21d80866d169fd3ff42fcfb7e 100644 (file)
@@ -281,7 +281,7 @@ struct serial_dev_priv {
 /* 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);
 
index 19a15d5d95235d21f82cbbae3cf796dba7bcdc91..972755face32704bc549eacec650eca23942eb5c 100644 (file)
@@ -24,7 +24,7 @@ static int dm_test_serial(struct unit_test_state *uts)
         * 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);
@@ -32,7 +32,7 @@ static int dm_test_serial(struct unit_test_state *uts)
        /*
         * 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