diff options
author | Zhijun He <zhhe@nvidia.com> | 2010-10-11 20:50:07 -0700 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2010-10-13 14:56:24 -0700 |
commit | 41aebc5456d4c6ae5f8d1543b478739331d500ec (patch) | |
tree | af480d761174120c5fecb5c41f331393572c1e89 /arch | |
parent | 98b1475bce96ad088e4105a73d34f1cf803f2ee0 (diff) |
[Android Camera]: ref count for i2c and gpio
Code added to track i2c and gpio object types on NVRM reftracker. This can be
used to release handles whenever a system crash happens.
This can help properly shutdown and deinitialize imager peripherals.
Bug 728160
Reviewed-on: http://git-master/r/5877
(cherry picked from commit 2661d755bfb401204cacafcc5f944085c19df627)
Change-Id: Iae3d08ef0fa5ef21d1e243249caa386f2a37fc3a
Reviewed-on: http://git-master.nvidia.com/r/8261
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-tegra/include/nvreftrack.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-tegra/nvrm/dispatch/nvrm_gpio_dispatch.c | 10 | ||||
-rw-r--r-- | arch/arm/mach-tegra/nvrm/dispatch/nvrm_i2c_dispatch.c | 18 | ||||
-rw-r--r-- | arch/arm/mach-tegra/nvrm_user.c | 557 |
4 files changed, 316 insertions, 271 deletions
diff --git a/arch/arm/mach-tegra/include/nvreftrack.h b/arch/arm/mach-tegra/include/nvreftrack.h index 69dfdeb1f638..ceecaab0a523 100644 --- a/arch/arm/mach-tegra/include/nvreftrack.h +++ b/arch/arm/mach-tegra/include/nvreftrack.h @@ -99,6 +99,8 @@ typedef enum { NvRtObjType_NvRm_NvRmMemHandle = 0, NvRtObjType_NvRm_NvRmDmaHandle, + NvRtObjType_NvRm_NvRmI2cHandle, + NvRtObjType_NvRm_GpioHandle, NvRtObjType_NvRm_Num, NvRtObjType_NvRm_ForceWord = 0x7FFFFFFF } NvRtObjType_NvRm; diff --git a/arch/arm/mach-tegra/nvrm/dispatch/nvrm_gpio_dispatch.c b/arch/arm/mach-tegra/nvrm/dispatch/nvrm_gpio_dispatch.c index d932c98db502..2a029ece124b 100644 --- a/arch/arm/mach-tegra/nvrm/dispatch/nvrm_gpio_dispatch.c +++ b/arch/arm/mach-tegra/nvrm/dispatch/nvrm_gpio_dispatch.c @@ -452,6 +452,7 @@ clean: static NvError NvRmGpioReleasePinHandles_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) { + NvU32 cnt = 0; NvError err_ = NvSuccess; NvRmGpioReleasePinHandles_in *p_in; NvRmGpioPinHandle *hPin = NULL; @@ -478,6 +479,10 @@ static NvError NvRmGpioReleasePinHandles_dispatch_( void *InBuffer, NvU32 InSize } NvRmGpioReleasePinHandles( p_in->hGpio, hPin, p_in->pinCount ); + for (cnt=0; cnt<p_in->pinCount; cnt++) + { + NvRtFreeObjRef(Ctx, NvRtObjType_NvRm_GpioHandle, (void *)hPin[cnt]); + } clean: NvOsFree( hPin ); @@ -487,6 +492,7 @@ clean: static NvError NvRmGpioAcquirePinHandle_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) { NvError err_ = NvSuccess; + NvRtObjRefHandle ref_phGpio = 0; NvRmGpioAcquirePinHandle_in *p_in; NvRmGpioAcquirePinHandle_out *p_out; @@ -494,8 +500,12 @@ static NvError NvRmGpioAcquirePinHandle_dispatch_( void *InBuffer, NvU32 InSize, p_out = (NvRmGpioAcquirePinHandle_out *)((NvU8 *)OutBuffer + OFFSET(NvRmGpioAcquirePinHandle_params, out) - OFFSET(NvRmGpioAcquirePinHandle_params, inout)); + if (NvSuccess != (err_ = NvRtAllocObjRef(Ctx, &ref_phGpio))) + goto clean; p_out->ret_ = NvRmGpioAcquirePinHandle( p_in->hGpio, p_in->port, p_in->pin, &p_out->phPin ); + NvRtStoreObjRef(Ctx, ref_phGpio, NvRtObjType_NvRm_GpioHandle, (void *)p_out->phPin); +clean: return err_; } diff --git a/arch/arm/mach-tegra/nvrm/dispatch/nvrm_i2c_dispatch.c b/arch/arm/mach-tegra/nvrm/dispatch/nvrm_i2c_dispatch.c index 6e2672dff896..e18e146baccd 100644 --- a/arch/arm/mach-tegra/nvrm/dispatch/nvrm_i2c_dispatch.c +++ b/arch/arm/mach-tegra/nvrm/dispatch/nvrm_i2c_dispatch.c @@ -195,6 +195,7 @@ static NvError NvRmI2cClose_dispatch_( void *InBuffer, NvU32 InSize, void *OutBu p_in = (NvRmI2cClose_in *)InBuffer; + NvRtFreeObjRef(Ctx, NvRtObjType_NvRm_NvRmI2cHandle, p_in->hI2c); NvRmI2cClose( p_in->hI2c ); @@ -206,13 +207,28 @@ static NvError NvRmI2cOpen_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuf NvError err_ = NvSuccess; NvRmI2cOpen_in *p_in; NvRmI2cOpen_out *p_out; + NvRtObjRefHandle ref_phI2c = 0; p_in = (NvRmI2cOpen_in *)InBuffer; p_out = (NvRmI2cOpen_out *)((NvU8 *)OutBuffer + OFFSET(NvRmI2cOpen_params, out) - OFFSET(NvRmI2cOpen_params, inout)); - p_out->ret_ = NvRmI2cOpen( p_in->hDevice, p_in->IoModule, p_in->instance, &p_out->phI2c ); + if (p_out->ret_ != NvSuccess) + { + err_ = p_out->ret_; + goto clean; + } + err_ = NvRtAllocObjRef(Ctx, &ref_phI2c); + if (err_ == NvSuccess) + { + NvRtStoreObjRef(Ctx, ref_phI2c, NvRtObjType_NvRm_NvRmI2cHandle, p_out->phI2c); + } + else + { + NvRmI2cClose(p_out->phI2c); + } +clean: return err_; } diff --git a/arch/arm/mach-tegra/nvrm_user.c b/arch/arm/mach-tegra/nvrm_user.c index 85b78b1389a3..d10686f91b28 100644 --- a/arch/arm/mach-tegra/nvrm_user.c +++ b/arch/arm/mach-tegra/nvrm_user.c @@ -35,6 +35,7 @@ #include "nvos.h" #include "nvrm_memmgr.h" #include "nvrm_dma.h" +#include "nvrm_i2c.h" #include "nvrm_ioctls.h" #include "nvrm_power_private.h" #include "mach/nvrm_linux.h" @@ -124,6 +125,15 @@ static void client_detach(NvRtClientHandle client) NvBool found = NV_FALSE; if ((ptr = NvRtFreeObjRef(&dctx, + NvRtObjType_NvRm_GpioHandle, + NULL)) != NULL) + { + printk(KERN_INFO "close gpio handle in case something is wrong, GPIO handle: 0x%x\n", (NvU32)ptr); + NvRmGpioReleasePinHandles((NvRmGpioHandle)s_hRmGlobal, (NvRmGpioPinHandle *)&ptr, 1); + found = NV_TRUE; + } + + if ((ptr = NvRtFreeObjRef(&dctx, NvRtObjType_NvRm_NvRmMemHandle, NULL)) != NULL) { @@ -132,6 +142,15 @@ static void client_detach(NvRtClientHandle client) found = NV_TRUE; } if ((ptr = NvRtFreeObjRef(&dctx, + NvRtObjType_NvRm_NvRmI2cHandle, + NULL)) != NULL) + { + printk(KERN_INFO "close i2c in client_detach\n"); + NvRmI2cClose((NvRmI2cHandle)ptr); + found = NV_TRUE; + } + + if ((ptr = NvRtFreeObjRef(&dctx, NvRtObjType_NvRm_NvRmDmaHandle, NULL)) != NULL) { @@ -267,7 +286,7 @@ long nvrm_unlocked_ioctl(struct file *file, goto fail; case NvRmIoctls_NvRmFbControl: printk( "NvRmIoctls_NvRmFbControl: deprecated \n" ); - break; + break; case NvRmIoctls_NvRmMemRead: case NvRmIoctls_NvRmMemWrite: @@ -283,173 +302,172 @@ long nvrm_unlocked_ioctl(struct file *file, case NvRmIoctls_NvRmBootDone: return tegra_start_dvfsd(); case NvRmIoctls_NvRmGetClientId: - err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); - if (err != NvSuccess) - { - NvOsDebugPrintf("NvRmIoctls_NvRmGetClientId: copy in failed\n"); - goto fail; - } - - NV_ASSERT(p.InBufferSize == 0); - NV_ASSERT(p.OutBufferSize == sizeof(NvRtClientHandle)); - NV_ASSERT(p.InOutBufferSize == 0); - - if (NvOsCopyOut(p.pBuffer, - &priv->rt_client, - sizeof(NvRtClientHandle)) != NvSuccess) - { - NvOsDebugPrintf("Failed to copy client id\n"); - goto fail; - } - break; - case NvRmIoctls_NvRmClientAttach: - { - NvRtClientHandle Client; - - err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); - if (err != NvSuccess) - { - NvOsDebugPrintf("NvRmIoctls_NvRmClientAttach: copy in failed\n"); - goto fail; - } - - NV_ASSERT(p.InBufferSize == sizeof(NvRtClientHandle)); - NV_ASSERT(p.OutBufferSize == 0); - NV_ASSERT(p.InOutBufferSize == 0); - - if (NvOsCopyIn((void*)&Client, - p.pBuffer, - sizeof(NvRtClientHandle)) != NvSuccess) - { - NvOsDebugPrintf("Failed to copy client id\n"); - goto fail; - } - - NV_ASSERT(Client || !"Bad client"); - - if (Client == priv->rt_client) - { - // The daemon is attaching to itself, no need to add refcount - break; - } - if (NvRtAddClientRef(s_RtHandle, Client) != NvSuccess) - { - NvOsDebugPrintf("Client ref add unsuccessful\n"); - goto fail; - } - break; - } - case NvRmIoctls_NvRmClientDetach: - { - NvRtClientHandle Client; - - err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); - if (err != NvSuccess) - { - NvOsDebugPrintf("NvRmIoctls_NvRmClientAttach: copy in failed\n"); - goto fail; - } - - NV_ASSERT(p.InBufferSize == sizeof(NvRtClientHandle)); - NV_ASSERT(p.OutBufferSize == 0); - NV_ASSERT(p.InOutBufferSize == 0); - - if (NvOsCopyIn((void*)&Client, - p.pBuffer, - sizeof(NvRtClientHandle)) != NvSuccess) - { - NvOsDebugPrintf("Failed to copy client id\n"); - goto fail; - } - - NV_ASSERT(Client || !"Bad client"); - - if (Client == priv->rt_client) - { - // The daemon is detaching from itself, no need to dec refcount - break; - } - - client_detach(Client); - break; - } - // FIXME: power ioctls? - default: - printk( "unknown ioctl code\n" ); - goto fail; - } - - e = 0; - goto clean; + err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); + if (err != NvSuccess) + { + NvOsDebugPrintf("NvRmIoctls_NvRmGetClientId: copy in failed\n"); + goto fail; + } + + NV_ASSERT(p.InBufferSize == 0); + NV_ASSERT(p.OutBufferSize == sizeof(NvRtClientHandle)); + NV_ASSERT(p.InOutBufferSize == 0); + + if (NvOsCopyOut(p.pBuffer, + &priv->rt_client, + sizeof(NvRtClientHandle)) != NvSuccess) + { + NvOsDebugPrintf("Failed to copy client id\n"); + goto fail; + } + break; + case NvRmIoctls_NvRmClientAttach: + { + NvRtClientHandle Client; + + err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); + if (err != NvSuccess) + { + NvOsDebugPrintf("NvRmIoctls_NvRmClientAttach: copy in failed\n"); + goto fail; + } + + NV_ASSERT(p.InBufferSize == sizeof(NvRtClientHandle)); + NV_ASSERT(p.OutBufferSize == 0); + NV_ASSERT(p.InOutBufferSize == 0); + + if (NvOsCopyIn((void*)&Client, + p.pBuffer, + sizeof(NvRtClientHandle)) != NvSuccess) + { + NvOsDebugPrintf("Failed to copy client id\n"); + goto fail; + } + + NV_ASSERT(Client || !"Bad client"); + + if (Client == priv->rt_client) + { + // The daemon is attaching to itself, no need to add refcount + break; + } + if (NvRtAddClientRef(s_RtHandle, Client) != NvSuccess) + { + NvOsDebugPrintf("Client ref add unsuccessful\n"); + goto fail; + } + break; + } + case NvRmIoctls_NvRmClientDetach: + { + NvRtClientHandle Client; + + err = NvOsCopyIn(&p, (void*)arg, sizeof(p)); + if (err != NvSuccess) + { + NvOsDebugPrintf("NvRmIoctls_NvRmClientAttach: copy in failed\n"); + goto fail; + } + + NV_ASSERT(p.InBufferSize == sizeof(NvRtClientHandle)); + NV_ASSERT(p.OutBufferSize == 0); + NV_ASSERT(p.InOutBufferSize == 0); + + if (NvOsCopyIn((void*)&Client, + p.pBuffer, + sizeof(NvRtClientHandle)) != NvSuccess) + { + NvOsDebugPrintf("Failed to copy client id\n"); + goto fail; + } + + NV_ASSERT(Client || !"Bad client"); + + if (Client == priv->rt_client) + { + // The daemon is detaching from itself, no need to dec refcount + break; + } + + client_detach(Client); + break; + } + // FIXME: power ioctls? + default: + printk( "unknown ioctl code\n" ); + goto fail; + } + + e = 0; + goto clean; fail: - e = -EINVAL; + e = -EINVAL; clean: - if( bAlloc ) - { - NvOsFree( ptr ); - } + if( bAlloc ) + { + NvOsFree( ptr ); + } - return e; + return e; } int nvrm_mmap(struct file *file, struct vm_area_struct *vma) { - return 0; + return 0; } static int nvrm_probe(struct platform_device *pdev) { - int e = 0; - NvU32 NumTypes = NvRtObjType_NvRm_Num; - - printk("nvrm probe\n"); - - NV_ASSERT(s_RtHandle == NULL); - - if (NvRtCreate(1, &NumTypes, &s_RtHandle) != NvSuccess) - { - e = -ENOMEM; - } - - if (e == 0) - { - e = misc_register( &nvrm_dev ); - } - - if (e == 0) - { - e = misc_register( &knvrm_dev ); - } - - if( e < 0 ) - { - if (s_RtHandle) - { - NvRtDestroy(s_RtHandle); - s_RtHandle = NULL; - } - - printk("nvrm probe failed to open\n"); - } - return e; + int e = 0; + NvU32 NumTypes = NvRtObjType_NvRm_Num; + + printk("nvrm probe\n"); + + NV_ASSERT(s_RtHandle == NULL); + + if (NvRtCreate(1, &NumTypes, &s_RtHandle) != NvSuccess) + { + e = -ENOMEM; + } + + if (e == 0) + { + e = misc_register( &nvrm_dev ); + } + + if (e == 0) + { + e = misc_register( &knvrm_dev ); + } + + if( e < 0 ) + { + if (s_RtHandle) + { + NvRtDestroy(s_RtHandle); + s_RtHandle = NULL; + } + printk("nvrm probe failed to open\n"); + } + return e; } static int nvrm_remove(struct platform_device *pdev) { - misc_deregister( &nvrm_dev ); - misc_deregister( &knvrm_dev ); - NvRtDestroy(s_RtHandle); - s_RtHandle = NULL; - return 0; + misc_deregister( &nvrm_dev ); + misc_deregister( &knvrm_dev ); + NvRtDestroy(s_RtHandle); + s_RtHandle = NULL; + return 0; } static struct platform_driver nvrm_driver = { - .probe = nvrm_probe, - .remove = nvrm_remove, - .driver = { .name = "nvrm" } + .probe = nvrm_probe, + .remove = nvrm_remove, + .driver = { .name = "nvrm" } }; #if defined(CONFIG_PM) @@ -476,56 +494,56 @@ static const char *STRING_PM_SIGNAL = "PM_SIGNAL"; // Reading blocks if the value is not available. static ssize_t nvrm_notifier_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) + char *buf) { - int nchar; - - // Block if the value is not available yet. - if (! sys_nvrm_notifier) - { - printk(KERN_INFO "%s: blocking\n", __func__); - wait_event_interruptible(sys_nvrm_notifier_wait, sys_nvrm_notifier); - } - - // In case of false wakeup, return "". - if (! sys_nvrm_notifier) - { - printk(KERN_INFO "%s: false wakeup, returning with '\\n'\n", __func__); - nchar = sprintf(buf, "\n"); - return nchar; - } - - // Return the value, and clear. - printk(KERN_INFO "%s: returning with '%s'\n", __func__, sys_nvrm_notifier); - nchar = sprintf(buf, "%s\n", sys_nvrm_notifier); - sys_nvrm_notifier = NULL; - return nchar; + int nchar; + + // Block if the value is not available yet. + if (! sys_nvrm_notifier) + { + printk(KERN_INFO "%s: blocking\n", __func__); + wait_event_interruptible(sys_nvrm_notifier_wait, sys_nvrm_notifier); + } + + // In case of false wakeup, return "". + if (! sys_nvrm_notifier) + { + printk(KERN_INFO "%s: false wakeup, returning with '\\n'\n", __func__); + nchar = sprintf(buf, "\n"); + return nchar; + } + + // Return the value, and clear. + printk(KERN_INFO "%s: returning with '%s'\n", __func__, sys_nvrm_notifier); + nchar = sprintf(buf, "%s\n", sys_nvrm_notifier); + sys_nvrm_notifier = NULL; + return nchar; } // Writing is no blocking. static ssize_t nvrm_notifier_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { - if (!strncmp(buf, STRING_PM_CONTINUE, strlen(STRING_PM_CONTINUE))) { - // Wake up pm_notifier. - tegra_pm_notifier_continue_ok = 1; - wake_up(&tegra_pm_notifier_wait); - } - else if (!strncmp(buf, STRING_PM_SIGNAL, strlen(STRING_PM_SIGNAL))) { - s_nvrm_daemon_pid = 0; - sscanf(buf, "%*s %d", &s_nvrm_daemon_pid); - printk(KERN_INFO "%s: nvrm_daemon=%d\n", __func__, s_nvrm_daemon_pid); - } - else { - printk(KERN_ERR "%s: wrong value '%s'\n", __func__, buf); - } + if (!strncmp(buf, STRING_PM_CONTINUE, strlen(STRING_PM_CONTINUE))) { + // Wake up pm_notifier. + tegra_pm_notifier_continue_ok = 1; + wake_up(&tegra_pm_notifier_wait); + } + else if (!strncmp(buf, STRING_PM_SIGNAL, strlen(STRING_PM_SIGNAL))) { + s_nvrm_daemon_pid = 0; + sscanf(buf, "%*s %d", &s_nvrm_daemon_pid); + printk(KERN_INFO "%s: nvrm_daemon=%d\n", __func__, s_nvrm_daemon_pid); + } + else { + printk(KERN_ERR "%s: wrong value '%s'\n", __func__, buf); + } - return count; + return count; } static struct kobj_attribute nvrm_notifier_attribute = - __ATTR(notifier, 0666, nvrm_notifier_show, nvrm_notifier_store); + __ATTR(notifier, 0666, nvrm_notifier_show, nvrm_notifier_store); // // PM notifier @@ -533,76 +551,76 @@ static struct kobj_attribute nvrm_notifier_attribute = static void notify_daemon(const char* notice) { - long timeout = HZ * 30; - - // In case daemon's pid is not reported, do not signal or wait. - if (!s_nvrm_daemon_pid) { - printk(KERN_ERR "%s: don't know nvrm_daemon's PID\n", __func__); - return; - } - - // Clear before kicking nvrm_daemon. - tegra_pm_notifier_continue_ok = 0; - - // Notify nvrm_daemon. - sys_nvrm_notifier = notice; - wake_up(&sys_nvrm_notifier_wait); - - // Wait for the reply from nvrm_daemon. - printk(KERN_INFO "%s: wait for nvrm_daemon\n", __func__); - if (wait_event_timeout(tegra_pm_notifier_wait, - tegra_pm_notifier_continue_ok, timeout) == 0) { - printk(KERN_ERR "%s: timed out. nvrm_daemon did not reply\n", __func__); - } - - // Go back to the initial state. - sys_nvrm_notifier = NULL; + long timeout = HZ * 30; + + // In case daemon's pid is not reported, do not signal or wait. + if (!s_nvrm_daemon_pid) { + printk(KERN_ERR "%s: don't know nvrm_daemon's PID\n", __func__); + return; + } + + // Clear before kicking nvrm_daemon. + tegra_pm_notifier_continue_ok = 0; + + // Notify nvrm_daemon. + sys_nvrm_notifier = notice; + wake_up(&sys_nvrm_notifier_wait); + + // Wait for the reply from nvrm_daemon. + printk(KERN_INFO "%s: wait for nvrm_daemon\n", __func__); + if (wait_event_timeout(tegra_pm_notifier_wait, + tegra_pm_notifier_continue_ok, timeout) == 0) { + printk(KERN_ERR "%s: timed out. nvrm_daemon did not reply\n", __func__); + } + + // Go back to the initial state. + sys_nvrm_notifier = NULL; } int tegra_pm_notifier(struct notifier_block *nb, - unsigned long event, void *nouse) + unsigned long event, void *nouse) { - printk(KERN_INFO "%s: start processing event=%lx\n", __func__, event); + printk(KERN_INFO "%s: start processing event=%lx\n", __func__, event); - // Notify the event to nvrm_daemon. - switch (event) { - case PM_SUSPEND_PREPARE: + // Notify the event to nvrm_daemon. + switch (event) { + case PM_SUSPEND_PREPARE: #ifndef CONFIG_HAS_EARLYSUSPEND - notify_daemon(STRING_PM_DISPLAY_OFF); + notify_daemon(STRING_PM_DISPLAY_OFF); #endif - notify_daemon(STRING_PM_SUSPEND_PREPARE); - break; - case PM_POST_SUSPEND: - notify_daemon(STRING_PM_POST_SUSPEND); + notify_daemon(STRING_PM_SUSPEND_PREPARE); + break; + case PM_POST_SUSPEND: + notify_daemon(STRING_PM_POST_SUSPEND); #ifndef CONFIG_HAS_EARLYSUSPEND - notify_daemon(STRING_PM_DISPLAY_ON); + notify_daemon(STRING_PM_DISPLAY_ON); #endif - break; - default: - printk(KERN_ERR "%s: unknown event %ld\n", __func__, event); - return NOTIFY_DONE; - } - - printk(KERN_INFO "%s: finished processing event=%ld\n", __func__, event); - return NOTIFY_OK; + break; + default: + printk(KERN_ERR "%s: unknown event %ld\n", __func__, event); + return NOTIFY_DONE; + } + + printk(KERN_INFO "%s: finished processing event=%ld\n", __func__, event); + return NOTIFY_OK; } #ifdef CONFIG_HAS_EARLYSUSPEND void tegra_display_off(struct early_suspend *h) { - notify_daemon(STRING_PM_DISPLAY_OFF); + notify_daemon(STRING_PM_DISPLAY_OFF); } void tegra_display_on(struct early_suspend *h) { - notify_daemon(STRING_PM_DISPLAY_ON); + notify_daemon(STRING_PM_DISPLAY_ON); } static struct early_suspend tegra_display_power = { - .suspend = tegra_display_off, - .resume = tegra_display_on, - .level = EARLY_SUSPEND_LEVEL_DISABLE_FB + .suspend = tegra_display_off, + .resume = tegra_display_on, + .level = EARLY_SUSPEND_LEVEL_DISABLE_FB }; #endif @@ -611,27 +629,27 @@ static struct early_suspend tegra_display_power = */ static ssize_t nvrm_lp2policy_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) + char *buf) { - return sprintf(buf, "%u\n", g_Lp2Policy); + return sprintf(buf, "%u\n", g_Lp2Policy); } static ssize_t nvrm_lp2policy_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { - unsigned int n, policy; + unsigned int n, policy; - n = sscanf(buf, "%u", &policy); - if ((n != 1) || (policy >= NvRmLp2Policy_Num)) - return -1; + n = sscanf(buf, "%u", &policy); + if ((n != 1) || (policy >= NvRmLp2Policy_Num)) + return -1; - g_Lp2Policy = policy; - return count; + g_Lp2Policy = policy; + return count; } static struct kobj_attribute nvrm_lp2policy_attribute = - __ATTR(lp2policy, 0644, nvrm_lp2policy_show, nvrm_lp2policy_store); + __ATTR(lp2policy, 0644, nvrm_lp2policy_show, nvrm_lp2policy_store); /* * NVRM lowest power state run-time selection @@ -664,32 +682,31 @@ static struct kobj_attribute nvrm_core_lock_attribute = static int __init nvrm_init(void) { - int ret = 0; - printk(KERN_INFO "%s called\n", __func__); - - #if defined(CONFIG_PM) - // Register PM notifier. - pm_notifier(tegra_pm_notifier, 0); - tegra_pm_notifier_continue_ok = 0; - init_waitqueue_head(&tegra_pm_notifier_wait); - - #if defined(CONFIG_HAS_EARLYSUSPEND) - register_early_suspend(&tegra_display_power); - #endif - - // Create /sys/power/nvrm/notifier. - nvrm_kobj = kobject_create_and_add("nvrm", power_kobj); - sysfs_create_file(nvrm_kobj, &nvrm_core_lock_attribute.attr); - sysfs_create_file(nvrm_kobj, &nvrm_lp2policy_attribute.attr); - sysfs_create_file(nvrm_kobj, &nvrm_notifier_attribute.attr); - sys_nvrm_notifier = NULL; - init_waitqueue_head(&sys_nvrm_notifier_wait); - #endif - - // Register NvRm platform driver. - ret = platform_driver_register(&nvrm_driver); - - return ret; + int ret = 0; + printk(KERN_INFO "%s called\n", __func__); + + #if defined(CONFIG_PM) + // Register PM notifier. + pm_notifier(tegra_pm_notifier, 0); + tegra_pm_notifier_continue_ok = 0; + init_waitqueue_head(&tegra_pm_notifier_wait); + + #if defined(CONFIG_HAS_EARLYSUSPEND) + register_early_suspend(&tegra_display_power); + #endif + + // Create /sys/power/nvrm/notifier. + nvrm_kobj = kobject_create_and_add("nvrm", power_kobj); + sysfs_create_file(nvrm_kobj, &nvrm_lp2policy_attribute.attr); + sysfs_create_file(nvrm_kobj, &nvrm_notifier_attribute.attr); + sys_nvrm_notifier = NULL; + init_waitqueue_head(&sys_nvrm_notifier_wait); + #endif + + // Register NvRm platform driver. + ret = platform_driver_register(&nvrm_driver); + + return ret; } static void __exit nvrm_deinit(void) |