tpm: two-phase chip management functions
[firefly-linux-kernel-4.4.55.git] / drivers / char / tpm / tpm_nsc.c
index 4d0a17ea8cde6be38446d3405ff901e55c3eb625..6e2c2e64b292e79086b9cb5e67fd99eb2e2c70b9 100644 (file)
@@ -247,10 +247,9 @@ static struct platform_device *pdev = NULL;
 static void tpm_nsc_remove(struct device *dev)
 {
        struct tpm_chip *chip = dev_get_drvdata(dev);
-       if ( chip ) {
-               release_region(chip->vendor.base, 2);
-               tpm_remove_hardware(chip->dev);
-       }
+
+       tpm_chip_unregister(chip);
+       release_region(chip->vendor.base, 2);
 }
 
 static SIMPLE_DEV_PM_OPS(tpm_nsc_pm, tpm_pm_suspend, tpm_pm_resume);
@@ -307,11 +306,16 @@ static int __init init_nsc(void)
                goto err_del_dev;
        }
 
-       if (!(chip = tpm_register_hardware(&pdev->dev, &tpm_nsc))) {
+       chip = tpmm_chip_alloc(&pdev->dev, &tpm_nsc);
+       if (IS_ERR(chip)) {
                rc = -ENODEV;
                goto err_rel_reg;
        }
 
+       rc = tpm_chip_register(chip);
+       if (rc)
+               goto err_rel_reg;
+
        dev_dbg(&pdev->dev, "NSC TPM detected\n");
        dev_dbg(&pdev->dev,
                "NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n",