在remove函数中,pm_runtime_disable前必须还要调用pm_runtime_dont_use_autosuspend,否则rmmod的时候有可能不会suspend设备。
static int hello_remove(struct platform_device *pdev)
{
struct data *data = platform_get_drvdata(pdev);
printk("%s\n", __func__);
if (data->miscdevice_registered) {
misc_deregister(&data->miscdevice);
data->miscdevice_registered = false;
}
printk("---disable begin---\n");
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_disable(&pdev->dev);
printk("---disable end---\n");
return 0;
}
root@rk3308b-buildroot:/root# echo "xxx" > /dev/hello_file
[ 1852.244258] hello_open
[ 1852.244513] hello_write
[ 1852.244578] hello_release
root@rk3308b-buildroot:/root# rmmod platform_test
[ 1852.618912] hello_exit
[ 1852.619244] hello_remove
[ 1852.620159] ---disable begin---
[ 1852.620229] hello_suspend
[ 1852.620265] ---disable end---
[ 1852.620552] hello_device_release
root@rk3308b-buildroot:/root#
