Skip to content

Commit 09f50c9

Browse files
David Smithtorvalds
authored andcommitted
tpm: clean up tpm_nsc driver for platform_device suspend/resume compliance
Signed-off-by: Marcel Selhorst <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ad8f07c commit 09f50c9

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

drivers/char/tpm/tpm_nsc.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,23 @@ static void tpm_nsc_remove(struct device *dev)
273273
}
274274
}
275275

276-
static struct device_driver nsc_drv = {
277-
.name = "tpm_nsc",
278-
.bus = &platform_bus_type,
279-
.owner = THIS_MODULE,
280-
.suspend = tpm_pm_suspend,
281-
.resume = tpm_pm_resume,
276+
static int tpm_nsc_suspend(struct platform_device *dev, pm_message_t msg)
277+
{
278+
return tpm_pm_suspend(&dev->dev, msg);
279+
}
280+
281+
static int tpm_nsc_resume(struct platform_device *dev)
282+
{
283+
return tpm_pm_resume(&dev->dev);
284+
}
285+
286+
static struct platform_driver nsc_drv = {
287+
.suspend = tpm_nsc_suspend,
288+
.resume = tpm_nsc_resume,
289+
.driver = {
290+
.name = "tpm_nsc",
291+
.owner = THIS_MODULE,
292+
},
282293
};
283294

284295
static int __init init_nsc(void)
@@ -297,7 +308,7 @@ static int __init init_nsc(void)
297308
return -ENODEV;
298309
}
299310

300-
err = driver_register(&nsc_drv);
311+
err = platform_driver_register(&nsc_drv);
301312
if (err)
302313
return err;
303314

@@ -308,17 +319,15 @@ static int __init init_nsc(void)
308319
/* enable the DPM module */
309320
tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);
310321

311-
pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
322+
pdev = platform_device_alloc("tpm_nscl0", -1);
312323
if (!pdev) {
313324
rc = -ENOMEM;
314325
goto err_unreg_drv;
315326
}
316327

317-
pdev->name = "tpm_nscl0";
318-
pdev->id = -1;
319328
pdev->num_resources = 0;
329+
pdev->dev.driver = &nsc_drv.driver;
320330
pdev->dev.release = tpm_nsc_remove;
321-
pdev->dev.driver = &nsc_drv;
322331

323332
if ((rc = platform_device_register(pdev)) < 0)
324333
goto err_free_dev;
@@ -377,7 +386,7 @@ static int __init init_nsc(void)
377386
err_free_dev:
378387
kfree(pdev);
379388
err_unreg_drv:
380-
driver_unregister(&nsc_drv);
389+
platform_driver_unregister(&nsc_drv);
381390
return rc;
382391
}
383392

@@ -390,7 +399,7 @@ static void __exit cleanup_nsc(void)
390399
pdev = NULL;
391400
}
392401

393-
driver_unregister(&nsc_drv);
402+
platform_driver_unregister(&nsc_drv);
394403
}
395404

396405
module_init(init_nsc);

0 commit comments

Comments
 (0)