mirror of
git://nv-tegra.nvidia.com/linux-hwpm.git
synced 2025-12-23 18:01:07 +03:00
tegra: hwpm: add device_opened flag
Add device_opened flag to indicate device node open success. Use device_opened flag to allow execution of IOCTL and device teardown functionality. Jira THWPM-41 Change-Id: I218a45abed1de9f314cba696fd86c9bd8596cacc Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675514 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com> Reviewed-by: Seema Khowala <seemaj@nvidia.com> Reviewed-by: Vasuki Shankar <vasukis@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
mobile promotions
parent
9f2a83a828
commit
778356e12d
@@ -244,6 +244,7 @@ struct tegra_soc_hwpm {
|
|||||||
|
|
||||||
/* SW State */
|
/* SW State */
|
||||||
bool bind_completed;
|
bool bind_completed;
|
||||||
|
bool device_opened;
|
||||||
u64 full_alist_size;
|
u64 full_alist_size;
|
||||||
|
|
||||||
atomic_t hwpm_in_use;
|
atomic_t hwpm_in_use;
|
||||||
|
|||||||
@@ -343,6 +343,12 @@ static long tegra_hwpm_ioctl(struct file *file,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hwpm->device_opened) {
|
||||||
|
tegra_hwpm_err(hwpm, "Device open failed, can't process IOCTL");
|
||||||
|
ret = -ENODEV;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* Only allocate a buffer if the IOCTL needs a buffer */
|
/* Only allocate a buffer if the IOCTL needs a buffer */
|
||||||
if (!(ioc_dir & _IOC_NONE)) {
|
if (!(ioc_dir & _IOC_NONE)) {
|
||||||
arg_copy = kzalloc(arg_size, GFP_KERNEL);
|
arg_copy = kzalloc(arg_size, GFP_KERNEL);
|
||||||
@@ -486,6 +492,8 @@ static int tegra_hwpm_open(struct inode *inode, struct file *filp)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hwpm->device_opened = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
ret = tegra_hwpm_release_hw(hwpm);
|
ret = tegra_hwpm_release_hw(hwpm);
|
||||||
@@ -531,6 +539,11 @@ static int tegra_hwpm_release(struct inode *inode, struct file *filp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hwpm->device_opened == false) {
|
||||||
|
/* Device was not opened, do nothing */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ret = tegra_hwpm_disable_triggers(hwpm);
|
ret = tegra_hwpm_disable_triggers(hwpm);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tegra_hwpm_err(hwpm, "Failed to disable PMA triggers");
|
tegra_hwpm_err(hwpm, "Failed to disable PMA triggers");
|
||||||
@@ -570,6 +583,8 @@ static int tegra_hwpm_release(struct inode *inode, struct file *filp)
|
|||||||
}
|
}
|
||||||
clk_disable_unprepare(hwpm->la_clk);
|
clk_disable_unprepare(hwpm->la_clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hwpm->device_opened = false;
|
||||||
fail:
|
fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user