]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: serial: Adjust serial_setconfig() to use proper API
authorSimon Glass <sjg@chromium.org>
Fri, 28 Dec 2018 21:23:09 +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>
drivers/serial/serial-uclass.c
include/serial.h
test/dm/serial.c

index 81f1067f42232d95e7772f57785063dded70c8f0..669c82f37931fa6dbfdae6939a68491a01227110 100644 (file)
@@ -305,16 +305,13 @@ int serial_getconfig(struct udevice *dev, uint *config)
        return 0;
 }
 
-int serial_setconfig(uint config)
+int serial_setconfig(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->setconfig)
-               return ops->setconfig(gd->cur_serial_dev, config);
+               return ops->setconfig(dev, config);
 
        return 0;
 }
index 5ba031ab534a68a21d80866d169fd3ff42fcfb7e..8a05a0908980cbd5b09b5255326f8a9ac5d87718 100644 (file)
@@ -282,7 +282,7 @@ struct serial_dev_priv {
 #define serial_get_ops(dev)    ((struct dm_serial_ops *)(dev)->driver->ops)
 
 int serial_getconfig(struct udevice *dev, uint *config);
-int serial_setconfig(uint config);
+int serial_setconfig(struct udevice *dev, uint config);
 int serial_getinfo(struct serial_device_info *info);
 
 void atmel_serial_initialize(void);
index 972755face32704bc549eacec650eca23942eb5c..f82b4a19e8fb9933afcb564d6f1fe46a6ff9a64b 100644 (file)
@@ -23,7 +23,7 @@ static int dm_test_serial(struct unit_test_state *uts)
         * test with default config which is the only one supported by
         * sandbox_serial driver
         */
-       ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG));
+       ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG));
        ut_assertok(serial_getconfig(dev_serial, &value_serial));
        ut_assert(value_serial == SERIAL_DEFAULT_CONFIG);
        ut_assertok(serial_getinfo(&info_serial));
@@ -39,7 +39,8 @@ static int dm_test_serial(struct unit_test_state *uts)
         * sandbox_serial driver: test with wrong parity
         */
        ut_asserteq(-ENOTSUPP,
-                   serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD,
+                   serial_setconfig(dev_serial,
+                                    SERIAL_CONFIG(SERIAL_PAR_ODD,
                                                   SERIAL_8_BITS,
                                                   SERIAL_ONE_STOP)));
        /*
@@ -47,7 +48,8 @@ static int dm_test_serial(struct unit_test_state *uts)
         * sandbox_serial driver: test with wrong bits number
         */
        ut_asserteq(-ENOTSUPP,
-                   serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
+                   serial_setconfig(dev_serial,
+                                    SERIAL_CONFIG(SERIAL_PAR_NONE,
                                                   SERIAL_6_BITS,
                                                   SERIAL_ONE_STOP)));
 
@@ -56,7 +58,8 @@ static int dm_test_serial(struct unit_test_state *uts)
         * sandbox_serial driver: test with wrong stop bits number
         */
        ut_asserteq(-ENOTSUPP,
-                   serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
+                   serial_setconfig(dev_serial,
+                                    SERIAL_CONFIG(SERIAL_PAR_NONE,
                                                   SERIAL_8_BITS,
                                                   SERIAL_TWO_STOP)));