summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/x86-android-tablets.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2022-01-10 13:39:51 +0300
committerHans de Goede <hdegoede@redhat.com>2022-01-24 12:41:44 +0300
commit84c2dcdd475f3f5d1d30c87404cafba4dd4b75ec (patch)
treebb0189d1275f98d71afa1964d191ed3bbe467c72 /drivers/platform/x86/x86-android-tablets.c
parent4ce2a32d40260374dfce5344960c419fde23ce87 (diff)
downloadlinux-84c2dcdd475f3f5d1d30c87404cafba4dd4b75ec.tar.xz
platform/x86: x86-android-tablets: Add an init() callback to struct x86_dev_info
Add an init() callback to struct x86_dev_info, board descriptions can use this to do some custom setup before registering the i2c_clients, platform- devices and servdevs. Also add an exit() callback to also allow for cleanup of the custom setup. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-By: Lubomir Rintel <lkundrak@V3.sk> Link: https://lore.kernel.org/r/20220110103952.48760-2-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform/x86/x86-android-tablets.c')
-rw-r--r--drivers/platform/x86/x86-android-tablets.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 08c98e881d0e..fe4dba5997fe 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -153,6 +153,8 @@ struct x86_dev_info {
int i2c_client_count;
int pdev_count;
int serdev_count;
+ int (*init)(void);
+ void (*exit)(void);
};
/* Generic / shared bq24190 settings */
@@ -674,6 +676,7 @@ static struct i2c_client **i2c_clients;
static struct platform_device **pdevs;
static struct serdev_device **serdevs;
static struct gpiod_lookup_table **gpiod_lookup_tables;
+static void (*exit_handler)(void);
static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
int idx)
@@ -791,6 +794,9 @@ static void x86_android_tablet_cleanup(void)
kfree(i2c_clients);
+ if (exit_handler)
+ exit_handler();
+
for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
}
@@ -833,6 +839,15 @@ static __init int x86_android_tablet_init(void)
for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
gpiod_add_lookup_table(gpiod_lookup_tables[i]);
+ if (dev_info->init) {
+ ret = dev_info->init();
+ if (ret < 0) {
+ x86_android_tablet_cleanup();
+ return ret;
+ }
+ exit_handler = dev_info->exit;
+ }
+
i2c_clients = kcalloc(dev_info->i2c_client_count, sizeof(*i2c_clients), GFP_KERNEL);
if (!i2c_clients) {
x86_android_tablet_cleanup();