summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinyuny <linyuny@google.com>2023-07-13 22:57:43 +0000
committerlinyuny <linyuny@google.com>2023-07-17 19:36:39 +0000
commit6e6e884ebfd08596507452a1082ab61c7b71c261 (patch)
treebaaf046f7925e58de61cbdac42e5e6a350f8698a
parent25d9c32f6c12d67e6058ecb93620c80ef1017f28 (diff)
downloadlwis-6e6e884ebfd08596507452a1082ab61c7b71c261.tar.gz
LWIS: Remove lwis_event_subscribe_operations
Bug: 283156240 Test: CTS, GCA Change-Id: I50d5d65ef16047a8f61dc3f7021775449911f178 Signed-off-by: linyuny <linyuny@google.com>
-rw-r--r--lwis_device.c5
-rw-r--r--lwis_device.h21
-rw-r--r--lwis_device_dpm.c8
-rw-r--r--lwis_device_i2c.c8
-rw-r--r--lwis_device_ioreg.c8
-rw-r--r--lwis_device_slc.c8
-rw-r--r--lwis_device_spi.c8
-rw-r--r--lwis_device_test.c8
-rw-r--r--lwis_device_top.c2
-rw-r--r--lwis_device_top.h21
-rw-r--r--lwis_event.c18
11 files changed, 38 insertions, 77 deletions
diff --git a/lwis_device.c b/lwis_device.c
index 1613684..1e8b974 100644
--- a/lwis_device.c
+++ b/lwis_device.c
@@ -29,6 +29,7 @@
#include "lwis_device_dpm.h"
#include "lwis_device_slc.h"
#include "lwis_device_test.h"
+#include "lwis_device_top.h"
#include "lwis_device_spi.h"
#include "lwis_dt.h"
#include "lwis_event.h"
@@ -1876,7 +1877,9 @@ static void __exit lwis_driver_exit(void)
}
/* Release event subscription components */
if (lwis_dev->type == DEVICE_TYPE_TOP) {
- lwis_dev->top_dev->subscribe_ops.release(lwis_dev);
+ struct lwis_top_device *top_dev;
+ top_dev = container_of(lwis_dev, struct lwis_top_device, base_dev);
+ top_dev->subscribe_ops.release(lwis_dev);
}
/* Destroy device */
diff --git a/lwis_device.h b/lwis_device.h
index 5f8c043..8895ee3 100644
--- a/lwis_device.h
+++ b/lwis_device.h
@@ -132,26 +132,6 @@ struct lwis_device_subclass_operations {
};
/*
- * struct lwis_event_subscribe_operations
- * This struct contains the 'virtual' functions for lwis_device subclasses
- * Top device should be the only device to implement it.
- */
-struct lwis_event_subscribe_operations {
- /* Subscribe an event for subscriber device */
- int (*subscribe_event)(struct lwis_device *lwis_dev, int64_t trigger_event_id,
- int trigger_device_id, int subscriber_device_id);
- /* Unsubscribe an event for subscriber device */
- int (*unsubscribe_event)(struct lwis_device *lwis_dev, int64_t trigger_event_id,
- int subscriber_device_id);
- /* Notify subscriber when an event is happening */
- void (*notify_event_subscriber)(struct lwis_device *lwis_dev, int64_t trigger_event_id,
- int64_t trigger_event_count,
- int64_t trigger_event_timestamp);
- /* Clean up event subscription hash table when unloading top device */
- void (*release)(struct lwis_device *lwis_dev);
-};
-
-/*
* struct lwis_device_power_sequence_info
* This struct is to store the power up/down sequence information
*/
@@ -254,7 +234,6 @@ struct lwis_device {
unsigned int native_value_bitwidth;
/* Point to lwis_top_dev */
struct lwis_device *top_dev;
- struct lwis_event_subscribe_operations subscribe_ops;
#ifdef CONFIG_DEBUG_FS
/* DebugFS directory and files */
struct dentry *dbg_dir;
diff --git a/lwis_device_dpm.c b/lwis_device_dpm.c
index 42b2115..96cff61 100644
--- a/lwis_device_dpm.c
+++ b/lwis_device_dpm.c
@@ -30,13 +30,6 @@ static struct lwis_device_subclass_operations dpm_vops = {
.close = NULL,
};
-static struct lwis_event_subscribe_operations dpm_subscribe_ops = {
- .subscribe_event = NULL,
- .unsubscribe_event = NULL,
- .notify_event_subscriber = NULL,
- .release = NULL,
-};
-
static int find_bts_block(struct lwis_device *lwis_dev, struct lwis_device *target_dev,
struct lwis_qos_setting_v2 *qos_setting)
{
@@ -205,7 +198,6 @@ static int lwis_dpm_device_probe(struct platform_device *plat_dev)
dpm_dev->base_dev.type = DEVICE_TYPE_DPM;
dpm_dev->base_dev.vops = dpm_vops;
- dpm_dev->base_dev.subscribe_ops = dpm_subscribe_ops;
dpm_dev->base_dev.plat_dev = plat_dev;
dpm_dev->base_dev.k_dev = &plat_dev->dev;
diff --git a/lwis_device_i2c.c b/lwis_device_i2c.c
index be2af79..9820b48 100644
--- a/lwis_device_i2c.c
+++ b/lwis_device_i2c.c
@@ -56,13 +56,6 @@ static struct lwis_device_subclass_operations i2c_vops = {
.close = NULL,
};
-static struct lwis_event_subscribe_operations i2c_subscribe_ops = {
- .subscribe_event = NULL,
- .unsubscribe_event = NULL,
- .notify_event_subscriber = NULL,
- .release = NULL,
-};
-
static int lwis_i2c_device_enable(struct lwis_device *lwis_dev)
{
int ret;
@@ -248,7 +241,6 @@ static int lwis_i2c_device_probe(struct platform_device *plat_dev)
i2c_dev->base_dev.type = DEVICE_TYPE_I2C;
i2c_dev->base_dev.vops = i2c_vops;
- i2c_dev->base_dev.subscribe_ops = i2c_subscribe_ops;
i2c_dev->base_dev.plat_dev = plat_dev;
i2c_dev->base_dev.k_dev = &plat_dev->dev;
diff --git a/lwis_device_ioreg.c b/lwis_device_ioreg.c
index aba34ba..2ca2c7a 100644
--- a/lwis_device_ioreg.c
+++ b/lwis_device_ioreg.c
@@ -47,13 +47,6 @@ static struct lwis_device_subclass_operations ioreg_vops = {
.close = NULL,
};
-static struct lwis_event_subscribe_operations ioreg_subscribe_ops = {
- .subscribe_event = NULL,
- .unsubscribe_event = NULL,
- .notify_event_subscriber = NULL,
- .release = NULL,
-};
-
static int lwis_ioreg_device_enable(struct lwis_device *lwis_dev)
{
return 0;
@@ -110,7 +103,6 @@ static int lwis_ioreg_device_probe(struct platform_device *plat_dev)
ioreg_dev->base_dev.type = DEVICE_TYPE_IOREG;
ioreg_dev->base_dev.vops = ioreg_vops;
- ioreg_dev->base_dev.subscribe_ops = ioreg_subscribe_ops;
ioreg_dev->base_dev.plat_dev = plat_dev;
ioreg_dev->base_dev.k_dev = &plat_dev->dev;
diff --git a/lwis_device_slc.c b/lwis_device_slc.c
index 59c2e50..a3a7705 100644
--- a/lwis_device_slc.c
+++ b/lwis_device_slc.c
@@ -46,13 +46,6 @@ static struct lwis_device_subclass_operations slc_vops = {
.close = NULL,
};
-static struct lwis_event_subscribe_operations slc_subscribe_ops = {
- .subscribe_event = NULL,
- .unsubscribe_event = NULL,
- .notify_event_subscriber = NULL,
- .release = NULL,
-};
-
static int lwis_slc_enable(struct lwis_device *lwis_dev)
{
#ifdef CONFIG_OF
@@ -260,7 +253,6 @@ static int lwis_slc_device_probe(struct platform_device *plat_dev)
slc_dev->base_dev.type = DEVICE_TYPE_SLC;
slc_dev->base_dev.vops = slc_vops;
- slc_dev->base_dev.subscribe_ops = slc_subscribe_ops;
slc_dev->base_dev.plat_dev = plat_dev;
slc_dev->base_dev.k_dev = &plat_dev->dev;
diff --git a/lwis_device_spi.c b/lwis_device_spi.c
index 5a81cc5..b3d5eed 100644
--- a/lwis_device_spi.c
+++ b/lwis_device_spi.c
@@ -51,13 +51,6 @@ static struct lwis_device_subclass_operations spi_vops = {
.close = NULL,
};
-static struct lwis_event_subscribe_operations spi_subscribe_ops = {
- .subscribe_event = NULL,
- .unsubscribe_event = NULL,
- .notify_event_subscriber = NULL,
- .release = NULL,
-};
-
static int lwis_spi_device_enable(struct lwis_device *lwis_dev)
{
return 0;
@@ -122,7 +115,6 @@ static int lwis_spi_device_probe(struct spi_device *spi)
spi_dev->base_dev.type = DEVICE_TYPE_SPI;
spi_dev->base_dev.vops = spi_vops;
- spi_dev->base_dev.subscribe_ops = spi_subscribe_ops;
spi_dev->base_dev.plat_dev = NULL;
spi_dev->base_dev.k_dev = &spi->dev;
spi_dev->spi = spi;
diff --git a/lwis_device_test.c b/lwis_device_test.c
index 1834a31..25aa1ae 100644
--- a/lwis_device_test.c
+++ b/lwis_device_test.c
@@ -41,13 +41,6 @@ static struct lwis_device_subclass_operations test_vops = {
.close = NULL,
};
-static struct lwis_event_subscribe_operations test_subscribe_ops = {
- .subscribe_event = NULL,
- .unsubscribe_event = NULL,
- .notify_event_subscriber = NULL,
- .release = NULL,
-};
-
static int lwis_test_device_enable(struct lwis_device *lwis_dev)
{
return 0;
@@ -164,7 +157,6 @@ static int lwis_test_device_probe(struct platform_device *plat_dev)
test_dev->base_dev.type = DEVICE_TYPE_TEST;
test_dev->base_dev.vops = test_vops;
- test_dev->base_dev.subscribe_ops = test_subscribe_ops;
test_dev->base_dev.plat_dev = plat_dev;
test_dev->base_dev.k_dev = &plat_dev->dev;
diff --git a/lwis_device_top.c b/lwis_device_top.c
index 61473b7..3aadc6d 100644
--- a/lwis_device_top.c
+++ b/lwis_device_top.c
@@ -486,7 +486,7 @@ static int lwis_top_device_probe(struct platform_device *plat_dev)
top_dev->base_dev.type = DEVICE_TYPE_TOP;
top_dev->base_dev.vops = top_vops;
- top_dev->base_dev.subscribe_ops = top_subscribe_ops;
+ top_dev->subscribe_ops = top_subscribe_ops;
top_dev->base_dev.plat_dev = plat_dev;
top_dev->base_dev.k_dev = &plat_dev->dev;
diff --git a/lwis_device_top.h b/lwis_device_top.h
index 1844098..152624a 100644
--- a/lwis_device_top.h
+++ b/lwis_device_top.h
@@ -16,6 +16,26 @@
#define SCRATCH_MEMORY_SIZE 16
/*
+ * struct lwis_event_subscribe_operations
+ * This struct contains the 'virtual' functions for lwis_device subclasses
+ * Top device should be the only device to implement it.
+ */
+struct lwis_event_subscribe_operations {
+ /* Subscribe an event for subscriber device */
+ int (*subscribe_event)(struct lwis_device *lwis_dev, int64_t trigger_event_id,
+ int trigger_device_id, int subscriber_device_id);
+ /* Unsubscribe an event for subscriber device */
+ int (*unsubscribe_event)(struct lwis_device *lwis_dev, int64_t trigger_event_id,
+ int subscriber_device_id);
+ /* Notify subscriber when an event is happening */
+ void (*notify_event_subscriber)(struct lwis_device *lwis_dev, int64_t trigger_event_id,
+ int64_t trigger_event_count,
+ int64_t trigger_event_timestamp);
+ /* Clean up event subscription hash table when unloading top device */
+ void (*release)(struct lwis_device *lwis_dev);
+};
+
+/*
* struct lwis_top_device
* "Derived" lwis_device struct, with added top device related elements.
*/
@@ -35,6 +55,7 @@ struct lwis_top_device {
/* Subscription thread */
struct kthread_worker subscribe_worker;
struct task_struct *subscribe_worker_thread;
+ struct lwis_event_subscribe_operations subscribe_ops;
};
int lwis_top_device_init(void);
diff --git a/lwis_event.c b/lwis_event.c
index 84164fb..f80ad2f 100644
--- a/lwis_event.c
+++ b/lwis_event.c
@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include "lwis_device.h"
+#include "lwis_device_top.h"
#include "lwis_event.h"
#include "lwis_transaction.h"
#include "lwis_util.h"
@@ -284,6 +285,7 @@ static int lwis_client_event_subscribe(struct lwis_client *lwis_client, int64_t
int ret = 0;
struct lwis_device *lwis_dev = lwis_client->lwis_dev;
struct lwis_device *trigger_device;
+ struct lwis_top_device *top_dev;
int trigger_device_id = EVENT_OWNER_DEVICE_ID(trigger_event_id);
/* Check if top device probe failed */
@@ -314,8 +316,9 @@ static int lwis_client_event_subscribe(struct lwis_client *lwis_client, int64_t
return -EINVAL;
}
- ret = lwis_dev->top_dev->subscribe_ops.subscribe_event(lwis_dev->top_dev, trigger_event_id,
- trigger_device->id, lwis_dev->id);
+ top_dev = container_of(lwis_dev->top_dev, struct lwis_top_device, base_dev);
+ ret = top_dev->subscribe_ops.subscribe_event(lwis_dev->top_dev, trigger_event_id,
+ trigger_device->id, lwis_dev->id);
if (ret < 0)
dev_err(lwis_dev->dev, "Failed to subscribe event: 0x%llx\n", trigger_event_id);
@@ -327,6 +330,7 @@ static int lwis_client_event_unsubscribe(struct lwis_client *lwis_client, int64_
int ret = 0;
struct lwis_device *lwis_dev = lwis_client->lwis_dev;
struct lwis_device_event_state *event_state;
+ struct lwis_top_device *top_dev;
unsigned long flags;
/* Check if top device probe failed */
@@ -335,8 +339,8 @@ static int lwis_client_event_unsubscribe(struct lwis_client *lwis_client, int64_
return -EINVAL;
}
- ret = lwis_dev->top_dev->subscribe_ops.unsubscribe_event(lwis_dev->top_dev, event_id,
- lwis_dev->id);
+ top_dev = container_of(lwis_dev->top_dev, struct lwis_top_device, base_dev);
+ ret = top_dev->subscribe_ops.unsubscribe_event(lwis_dev->top_dev, event_id, lwis_dev->id);
if (ret < 0) {
dev_err(lwis_dev->dev, "Failed to unsubscribe event: 0x%llx\n", event_id);
}
@@ -824,6 +828,7 @@ static int lwis_device_event_emit_impl(struct lwis_device *lwis_dev, int64_t eve
/* Our iterators */
struct lwis_client *lwis_client;
struct list_head *p, *n;
+ struct lwis_top_device *top_dev;
int64_t timestamp;
int64_t event_counter;
/* Flags for IRQ disable */
@@ -857,8 +862,9 @@ static int lwis_device_event_emit_impl(struct lwis_device *lwis_dev, int64_t eve
/* Emit event to subscriber via top device */
if (has_subscriber) {
- lwis_dev->top_dev->subscribe_ops.notify_event_subscriber(
- lwis_dev->top_dev, event_id, event_counter, timestamp);
+ top_dev = container_of(lwis_dev->top_dev, struct lwis_top_device, base_dev);
+ top_dev->subscribe_ops.notify_event_subscriber(lwis_dev->top_dev, event_id,
+ event_counter, timestamp);
}
/* Run internal handler if any */