diff options
author | Holmes Chou <holmeschou@google.com> | 2023-04-14 08:08:46 +0000 |
---|---|---|
committer | Holmes Chou <holmeschou@google.com> | 2023-04-14 08:15:07 +0000 |
commit | b5e90bd1462896158a9d13f97dcb831661fedb0f (patch) | |
tree | 84fc1e570ad5e4beeed1959601882fdf6da1a922 /platform | |
parent | 18c649b8428ffca84abae15b7f569b9735ec0766 (diff) | |
download | lwis-b5e90bd1462896158a9d13f97dcb831661fedb0f.tar.gz |
LWIS: Add a struct device field in struce lwis_device
The plat_dev in lwis_device might be invalid when the device type
is not platform driver. But there are many common codes for all
device types that access plat_dev. It will cause NPE when the
device type is not a platform driver. Most of the codes to access
plat_dev are to access the struct device in it. So, we can add a
new struct device field in struct lwis_device and assign the
struct device value from struct platform_device when probe. Then
use the new added field in the common code. It should fix the NPE
when the device type is not a platform driver.
Bug: 278156602
Test: GCA, CTS
Change-Id: Ic46b5ea66d85e1299516c8da582e06ae69eedb41
Signed-off-by: Holmes Chou <holmeschou@google.com>
Diffstat (limited to 'platform')
-rw-r--r-- | platform/anchorage/lwis_platform_anchorage.c | 20 | ||||
-rw-r--r-- | platform/busan/lwis_platform_busan.c | 20 | ||||
-rw-r--r-- | platform/casablanca/lwis_platform_casablanca.c | 20 |
3 files changed, 27 insertions, 33 deletions
diff --git a/platform/anchorage/lwis_platform_anchorage.c b/platform/anchorage/lwis_platform_anchorage.c index 36fc0ba..b84c98c 100644 --- a/platform/anchorage/lwis_platform_anchorage.c +++ b/platform/anchorage/lwis_platform_anchorage.c @@ -40,7 +40,7 @@ int lwis_platform_probe(struct lwis_device *lwis_dev) lwis_dev->platform = platform; /* Enable runtime power management for the platform device */ - pm_runtime_enable(&lwis_dev->plat_dev->dev); + pm_runtime_enable(lwis_dev->k_dev); /* Only IOREG devices will access DMA resources */ if (lwis_dev->type != DEVICE_TYPE_IOREG) { @@ -69,7 +69,7 @@ static int lwis_iommu_fault_handler(struct iommu_fault *fault, void *param) pr_err("############ LWIS IOMMU PAGE FAULT ############\n"); pr_err("\n"); - of_for_each_phandle (&it, ret, lwis_dev->plat_dev->dev.of_node, "iommus", 0, 0) { + of_for_each_phandle (&it, ret, lwis_dev->k_dev->of_node, "iommus", 0, 0) { u64 iommus_reg; const char *port_name = NULL; struct device_node *iommus_info = of_node_get(it.node); @@ -135,17 +135,16 @@ int lwis_platform_device_enable(struct lwis_device *lwis_dev) } /* Upref the runtime power management controls for the platform dev */ - ret = pm_runtime_get_sync(&lwis_dev->plat_dev->dev); + ret = pm_runtime_get_sync(lwis_dev->k_dev); if (ret < 0) { pr_err("Unable to enable platform device\n"); return ret; } - if (of_find_property(lwis_dev->plat_dev->dev.of_node, "iommus", &iommus_len) && - iommus_len) { + if (of_find_property(lwis_dev->k_dev->of_node, "iommus", &iommus_len) && iommus_len) { /* Activate IOMMU for the platform device */ - ret = iommu_register_device_fault_handler(&lwis_dev->plat_dev->dev, - lwis_iommu_fault_handler, lwis_dev); + ret = iommu_register_device_fault_handler(lwis_dev->k_dev, lwis_iommu_fault_handler, + lwis_dev); if (ret < 0) { pr_err("Failed to register fault handler for the device: %d\n", ret); return ret; @@ -215,14 +214,13 @@ int lwis_platform_device_disable(struct lwis_device *lwis_dev) lwis_platform_remove_qos(lwis_dev); - if (of_find_property(lwis_dev->plat_dev->dev.of_node, "iommus", &iommus_len) && - iommus_len) { + if (of_find_property(lwis_dev->k_dev->of_node, "iommus", &iommus_len) && iommus_len) { /* Deactivate IOMMU */ - iommu_unregister_device_fault_handler(&lwis_dev->plat_dev->dev); + iommu_unregister_device_fault_handler(lwis_dev->k_dev); } /* Disable platform device */ - return pm_runtime_put_sync(&lwis_dev->plat_dev->dev); + return pm_runtime_put_sync(lwis_dev->k_dev); } int lwis_platform_update_qos(struct lwis_device *lwis_dev, int value, int32_t clock_family) diff --git a/platform/busan/lwis_platform_busan.c b/platform/busan/lwis_platform_busan.c index 19588a9..3eb317c 100644 --- a/platform/busan/lwis_platform_busan.c +++ b/platform/busan/lwis_platform_busan.c @@ -37,7 +37,7 @@ int lwis_platform_probe(struct lwis_device *lwis_dev) lwis_dev->platform = platform; /* Enable runtime power management for the platform device */ - pm_runtime_enable(&lwis_dev->plat_dev->dev); + pm_runtime_enable(lwis_dev->k_dev); /* Only IOREG devices will access DMA resources */ if (lwis_dev->type != DEVICE_TYPE_IOREG) { @@ -66,7 +66,7 @@ static int lwis_iommu_fault_handler(struct iommu_fault *fault, void *param) pr_err("############ LWIS IOMMU PAGE FAULT ############\n"); pr_err("\n"); - of_for_each_phandle (&it, ret, lwis_dev->plat_dev->dev.of_node, "iommus", 0, 0) { + of_for_each_phandle (&it, ret, lwis_dev->k_dev->of_node, "iommus", 0, 0) { u64 iommus_reg; const char *port_name = NULL; struct device_node *iommus_info = of_node_get(it.node); @@ -132,17 +132,16 @@ int lwis_platform_device_enable(struct lwis_device *lwis_dev) } /* Upref the runtime power management controls for the platform dev */ - ret = pm_runtime_get_sync(&lwis_dev->plat_dev->dev); + ret = pm_runtime_get_sync(lwis_dev->k_dev); if (ret < 0) { pr_err("Unable to enable platform device\n"); return ret; } - if (of_find_property(lwis_dev->plat_dev->dev.of_node, "iommus", &iommus_len) && - iommus_len) { + if (of_find_property(lwis_dev->k_dev->of_node, "iommus", &iommus_len) && iommus_len) { /* Activate IOMMU for the platform device */ - ret = iommu_register_device_fault_handler(&lwis_dev->plat_dev->dev, - lwis_iommu_fault_handler, lwis_dev); + ret = iommu_register_device_fault_handler(lwis_dev->k_dev, lwis_iommu_fault_handler, + lwis_dev); if (ret < 0) { pr_err("Failed to register fault handler for the device: %d\n", ret); return ret; @@ -201,14 +200,13 @@ int lwis_platform_device_disable(struct lwis_device *lwis_dev) lwis_platform_remove_qos(lwis_dev); - if (of_find_property(lwis_dev->plat_dev->dev.of_node, "iommus", &iommus_len) && - iommus_len) { + if (of_find_property(lwis_dev->k_dev->of_node, "iommus", &iommus_len) && iommus_len) { /* Deactivate IOMMU */ - iommu_unregister_device_fault_handler(&lwis_dev->plat_dev->dev); + iommu_unregister_device_fault_handler(lwis_dev->k_dev); } /* Disable platform device */ - return pm_runtime_put_sync(&lwis_dev->plat_dev->dev); + return pm_runtime_put_sync(lwis_dev->k_dev); } int lwis_platform_update_qos(struct lwis_device *lwis_dev, int value, int32_t clock_family) diff --git a/platform/casablanca/lwis_platform_casablanca.c b/platform/casablanca/lwis_platform_casablanca.c index fbf332d..b160f36 100644 --- a/platform/casablanca/lwis_platform_casablanca.c +++ b/platform/casablanca/lwis_platform_casablanca.c @@ -38,7 +38,7 @@ int lwis_platform_probe(struct lwis_device *lwis_dev) lwis_dev->platform = platform; /* Enable runtime power management for the platform device */ - pm_runtime_enable(&lwis_dev->plat_dev->dev); + pm_runtime_enable(lwis_dev->k_dev); /* Only IOREG devices will access DMA resources */ if (lwis_dev->type != DEVICE_TYPE_IOREG) { @@ -67,7 +67,7 @@ static int lwis_iommu_fault_handler(struct iommu_fault *fault, void *param) pr_err("############ LWIS IOMMU PAGE FAULT ############\n"); pr_err("\n"); - of_for_each_phandle (&it, ret, lwis_dev->plat_dev->dev.of_node, "iommus", 0, 0) { + of_for_each_phandle (&it, ret, lwis_dev->k_dev->of_node, "iommus", 0, 0) { u64 iommus_reg; const char *port_name = NULL; struct device_node *iommus_info = of_node_get(it.node); @@ -133,17 +133,16 @@ int lwis_platform_device_enable(struct lwis_device *lwis_dev) } /* Upref the runtime power management controls for the platform dev */ - ret = pm_runtime_get_sync(&lwis_dev->plat_dev->dev); + ret = pm_runtime_get_sync(lwis_dev->k_dev); if (ret < 0) { pr_err("Unable to enable platform device\n"); return ret; } - if (of_find_property(lwis_dev->plat_dev->dev.of_node, "iommus", &iommus_len) && - iommus_len) { + if (of_find_property(lwis_dev->k_dev->of_node, "iommus", &iommus_len) && iommus_len) { /* Activate IOMMU for the platform device */ - ret = iommu_register_device_fault_handler(&lwis_dev->plat_dev->dev, - lwis_iommu_fault_handler, lwis_dev); + ret = iommu_register_device_fault_handler(lwis_dev->k_dev, lwis_iommu_fault_handler, + lwis_dev); if (ret < 0) { pr_err("Failed to register fault handler for the device: %d\n", ret); return ret; @@ -202,14 +201,13 @@ int lwis_platform_device_disable(struct lwis_device *lwis_dev) lwis_platform_remove_qos(lwis_dev); - if (of_find_property(lwis_dev->plat_dev->dev.of_node, "iommus", &iommus_len) && - iommus_len) { + if (of_find_property(lwis_dev->k_dev->of_node, "iommus", &iommus_len) && iommus_len) { /* Deactivate IOMMU */ - iommu_unregister_device_fault_handler(&lwis_dev->plat_dev->dev); + iommu_unregister_device_fault_handler(lwis_dev->k_dev); } /* Disable platform device */ - return pm_runtime_put_sync(&lwis_dev->plat_dev->dev); + return pm_runtime_put_sync(lwis_dev->k_dev); } int lwis_platform_update_qos(struct lwis_device *lwis_dev, int value, int32_t clock_family) |