Commit 09f50c95 authored by David Smith's avatar David Smith Committed by Linus Torvalds

tpm: clean up tpm_nsc driver for platform_device suspend/resume compliance

Signed-off-by: default avatarMarcel Selhorst <tpm@selhorst.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ad8f07cc
...@@ -273,12 +273,23 @@ static void tpm_nsc_remove(struct device *dev) ...@@ -273,12 +273,23 @@ static void tpm_nsc_remove(struct device *dev)
} }
} }
static struct device_driver nsc_drv = { static int tpm_nsc_suspend(struct platform_device *dev, pm_message_t msg)
{
return tpm_pm_suspend(&dev->dev, msg);
}
static int tpm_nsc_resume(struct platform_device *dev)
{
return tpm_pm_resume(&dev->dev);
}
static struct platform_driver nsc_drv = {
.suspend = tpm_nsc_suspend,
.resume = tpm_nsc_resume,
.driver = {
.name = "tpm_nsc", .name = "tpm_nsc",
.bus = &platform_bus_type,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.suspend = tpm_pm_suspend, },
.resume = tpm_pm_resume,
}; };
static int __init init_nsc(void) static int __init init_nsc(void)
...@@ -297,7 +308,7 @@ static int __init init_nsc(void) ...@@ -297,7 +308,7 @@ static int __init init_nsc(void)
return -ENODEV; return -ENODEV;
} }
err = driver_register(&nsc_drv); err = platform_driver_register(&nsc_drv);
if (err) if (err)
return err; return err;
...@@ -308,17 +319,15 @@ static int __init init_nsc(void) ...@@ -308,17 +319,15 @@ static int __init init_nsc(void)
/* enable the DPM module */ /* enable the DPM module */
tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);
pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL); pdev = platform_device_alloc("tpm_nscl0", -1);
if (!pdev) { if (!pdev) {
rc = -ENOMEM; rc = -ENOMEM;
goto err_unreg_drv; goto err_unreg_drv;
} }
pdev->name = "tpm_nscl0";
pdev->id = -1;
pdev->num_resources = 0; pdev->num_resources = 0;
pdev->dev.driver = &nsc_drv.driver;
pdev->dev.release = tpm_nsc_remove; pdev->dev.release = tpm_nsc_remove;
pdev->dev.driver = &nsc_drv;
if ((rc = platform_device_register(pdev)) < 0) if ((rc = platform_device_register(pdev)) < 0)
goto err_free_dev; goto err_free_dev;
...@@ -377,7 +386,7 @@ err_unreg_dev: ...@@ -377,7 +386,7 @@ err_unreg_dev:
err_free_dev: err_free_dev:
kfree(pdev); kfree(pdev);
err_unreg_drv: err_unreg_drv:
driver_unregister(&nsc_drv); platform_driver_unregister(&nsc_drv);
return rc; return rc;
} }
...@@ -390,7 +399,7 @@ static void __exit cleanup_nsc(void) ...@@ -390,7 +399,7 @@ static void __exit cleanup_nsc(void)
pdev = NULL; pdev = NULL;
} }
driver_unregister(&nsc_drv); platform_driver_unregister(&nsc_drv);
} }
module_init(init_nsc); module_init(init_nsc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment