📄 tffs-pm26.c
字号:
/****************************************************************************** * * * Project: DOC Driver for Linux 2.6 Block device driver for mDOC H3 family * * of devices under Linux kernel 2.6. * * * * Version: 1.0 * * Email questions to: oemsupport@sandisk.com * * Copyright (C) SanDisk IL Ltd. 1995 - 2007 * * SanDisk IL Ltd., 7 Atir Yeda Street, Kfar Saba 44425, Israel * * * ****************************************************************************** * * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * * Software Foundation; either version 2 of the License, or any later version.* * This program is distributed in the hope that it will be useful, but WITHOUT* * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details, which is set forth in the readme.txt file. * * You should have received a copy of the GNU General Public License along * * with this program; if not, write to the Free Software Foundation, Inc., 51 * * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * * * This License does not grant you any right to use the trademarks, service * * marks or logos of SanDisk IL Ltd. or SanDisk Corporation. * * Subject to the foregoing, SanDisk IL Ltd., for itself and on behalf of its * * licensors, hereby reserves all intellectual property rights in the program,* * except for the rights expressly granted in this License. * * * ******************************************************************************/
/*
* $Log$
*/
#include "tffsdrv.h"
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && defined(CONFIG_PM)
# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
/******************************************************************************
* *
* Generic power management implementation for Linux kernels 2.6.15 and up. *
* *
******************************************************************************/
static int suspend_driver (struct platform_device * dev, pm_message_t state)
{
tffs_suspend();
return 0;
}
static int resume_driver (struct platform_device * dev)
{
tffs_resume ();
return 0;
}
static struct platform_driver pm_driver =
{
.suspend = suspend_driver,
.resume = resume_driver,
.driver =
{
.name = TFFS_DEVICE_NAME,
},
};
int tffs_pm_init (void)
{
int rc;
if( (rc = platform_driver_register(&pm_driver)) != 0)
PrintkError ("platform_driver_register() failed, PM disabled");
return rc;
}
int tffs_pm_exit (void)
{
platform_driver_unregister (&pm_driver);
return 0;
}
# else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) */
/******************************************************************************
* *
* Generic power management implementation for Linux kernels 2.6.0 .. 2.6.14 *
* *
******************************************************************************/
# if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11))
static pm_message_t suspend_driver (struct device * dev, u32 state, u32 level)
# else
static int suspend_driver (struct device * dev, u32 state, u32 level)
# endif
{
switch (level)
{
case SUSPEND_POWER_DOWN:
tffs_suspend ();
break;
case SUSPEND_DISABLE:
case SUSPEND_SAVE_STATE:
default:
break;
}
return 0;
}
static int resume_driver (struct device * dev, u32 level)
{
switch (level)
{
case RESUME_POWER_ON:
tffs_resume ();
break;
case RESUME_RESTORE_STATE:
case RESUME_ENABLE:
default:
break;
}
return 0;
}
static
void pm_release_device (struct device * pdev)
{ }
static struct platform_device pm_device = {
.name = TFFS_DEVICE_NAME,
.id = 0,
.dev.release = pm_release_device,
};
static struct device_driver pm_driver = {
.name = TFFS_DEVICE_NAME,
.bus = &platform_bus_type,
.suspend = suspend_driver,
.resume = resume_driver,
};
int tffs_pm_init (void)
{
/* register device with Linux Device Manager */
if( platform_device_register(&pm_device) != 0 )
{
PrintkError ("can't register device %s with LDM", pm_device.name);
return -ENODEV;
}
/* register driver with Linux Device Manager */
if( driver_register(&pm_driver) != 0 )
{
PrintkError ("can't register driver %s with LDM", pm_driver.name);
/* unregister device from Linux Device Manager */
platform_device_unregister (&pm_device);
return -ENODEV;
}
return 0; /* success */
}
int tffs_pm_exit (void)
{
/* unregister driver from Linux Device Manager */
driver_unregister (&pm_driver);
/* unregister device from Linux Device Manager */
platform_device_unregister (&pm_device);
return 0;
}
# endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) */
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && defined(CONFIG_PM) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -