interface: Introduce operation for checking availability 26/228126/2
authorDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 18 Mar 2020 03:31:39 +0000 (12:31 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 19 Mar 2020 09:00:31 +0000 (18:00 +0900)
Because there is no need to setup interface not supported by target,
check availability of interface and ignore the target which is not
available. Since this, the interface not providing available function
will be also ignored.

Change-Id: Ic7cf11e2d46bd6b979cc02a87cb392cfb04ed399
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/interface.c
src/interface.h

index 027a3fc..103b749 100644 (file)
@@ -201,6 +201,17 @@ struct tfm_interface_context *tfm_interface_init(void)
        LIST_FOREACH(driver, &interface_avail_list, entry) {
                struct tfm_interface *intf;
 
+               if (!driver->ops.available) {
+                       fprintf(stderr,
+                               "Cannot check availability for interface %s.\n",
+                               driver->name);
+                       continue;
+               }
+
+               /* Ignore not supported interface */
+               if (!driver->ops.available())
+                       continue;
+
                intf = (struct tfm_interface *)malloc(sizeof(*intf));
                if (!intf)
                        goto err;
index 7bb9c02..c908c1a 100644 (file)
@@ -37,6 +37,7 @@ struct tfm_interface_ops {
        int (*disconnect)(struct tfm_interface *intf);
        ssize_t (*rx_data)(int fd, void *buf, ssize_t len);
        ssize_t (*tx_data)(int fd, void *buf, ssize_t len);
+       int (*available)(void);
 };
 
 struct tfm_interface_driver {