[fprint] [PATCH 6/8] lib: Skip extern refs. to driver data structures.

Kunal Gangakhedkar kunal.gangakhedkar at gmail.com
Mon Oct 8 07:39:30 PDT 2012


When building the drivers as shared objects, we don't need to reference
the data structures with 'extern's.

Each driver needs to take care of registering the data structures
in the entry point functions.

This is precisely how linux kernel handles it.

Moreover, this allows the driver to initialize any other *internal*
state that it may need - in the entry point function call.

Signed-off-by: Kunal Gangakhedkar <kunal.gangakhedkar at gmail.com>
---
 libfprint/core.c        |    6 ++++++
 libfprint/fp_internal.h |    4 ++++
 2 files changed, 10 insertions(+)

diff --git a/libfprint/core.c b/libfprint/core.c
index 84f3c92..0ce40c2 100644
--- a/libfprint/core.c
+++ b/libfprint/core.c
@@ -345,6 +345,8 @@ API_INTERNAL void unregister_driver(struct fp_driver *drv)
 	fp_dbg("unregistered driver %s", drv->name);
 }
 
+#ifndef ENABLE_DYNAMIC_DRIVERS
+
 static struct fp_driver * const primitive_drivers[] = {
 #ifdef ENABLE_UPEKTS
 	&upekts_driver,
@@ -420,6 +422,7 @@ API_EXPORTED struct fp_driver **fprint_get_drivers (void)
 
 	return (struct fp_driver **) g_ptr_array_free (array, FALSE);
 }
+#endif /* ENABLE_DYNAMIC_DRIVERS */
 
 static struct fp_driver *find_supporting_driver(libusb_device *udev,
 	const struct usb_id **usb_id, uint32_t *devtype)
@@ -946,7 +949,10 @@ API_EXPORTED int fp_init(void)
 		}
 	}
 
+#ifndef ENABLE_DYNAMIC_DRIVERS
 	register_drivers();
+#endif /* ENABLE_DYNAMIC_DRIVERS */
+
 	fpi_poll_init();
 	return 0;
 }
diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h
index da0276c..ac8f38d 100644
--- a/libfprint/fp_internal.h
+++ b/libfprint/fp_internal.h
@@ -235,6 +235,8 @@ struct fp_img_driver {
 	void (*deactivate)(struct fp_img_dev *dev);
 };
 
+#ifndef ENABLE_DYNAMIC_DRIVERS
+
 #ifdef ENABLE_UPEKTS
 extern struct fp_driver upekts_driver;
 #endif
@@ -272,6 +274,8 @@ extern struct fp_img_driver vfs101_driver;
 extern struct fp_img_driver vfs301_driver;
 #endif
 
+#endif /* ENABLE_DYNAMIC_DRIVERS */
+
 extern libusb_context *fpi_usb_ctx;
 extern GSList *opened_devices;
 
-- 
1.7.9.5



More information about the fprint mailing list