hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/char/tpm/tpm_vtpm_proxy.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2015, 2016 IBM Corporation
34 * Copyright (C) 2016 Intel Corporation
....@@ -7,12 +8,6 @@
78 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
89 *
910 * Device driver for vTPM (vTPM proxy driver)
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License as
13
- * published by the Free Software Foundation, version 2 of the
14
- * License.
15
- *
1611 */
1712
1813 #include <linux/types.h>
....@@ -303,9 +298,9 @@
303298 static int vtpm_proxy_is_driver_command(struct tpm_chip *chip,
304299 u8 *buf, size_t count)
305300 {
306
- struct tpm_input_header *hdr = (struct tpm_input_header *)buf;
301
+ struct tpm_header *hdr = (struct tpm_header *)buf;
307302
308
- if (count < sizeof(struct tpm_input_header))
303
+ if (count < sizeof(struct tpm_header))
309304 return 0;
310305
311306 if (chip->flags & TPM_CHIP_FLAG_TPM2) {
....@@ -401,7 +396,7 @@
401396 {
402397 struct tpm_buf buf;
403398 int rc;
404
- const struct tpm_output_header *header;
399
+ const struct tpm_header *header;
405400 struct proxy_dev *proxy_dev = dev_get_drvdata(&chip->dev);
406401
407402 if (chip->flags & TPM_CHIP_FLAG_TPM2)
....@@ -416,9 +411,7 @@
416411
417412 proxy_dev->state |= STATE_DRIVER_COMMAND;
418413
419
- rc = tpm_transmit_cmd(chip, NULL, buf.data, tpm_buf_length(&buf), 0,
420
- TPM_TRANSMIT_NESTED,
421
- "attempting to set locality");
414
+ rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to set locality");
422415
423416 proxy_dev->state &= ~STATE_DRIVER_COMMAND;
424417
....@@ -427,7 +420,7 @@
427420 goto out;
428421 }
429422
430
- header = (const struct tpm_output_header *)buf.data;
423
+ header = (const struct tpm_header *)buf.data;
431424 rc = be32_to_cpu(header->return_code);
432425 if (rc)
433426 locality = -1;
....@@ -677,20 +670,10 @@
677670 }
678671 }
679672
680
-#ifdef CONFIG_COMPAT
681
-static long vtpmx_fops_compat_ioctl(struct file *f, unsigned int ioctl,
682
- unsigned long arg)
683
-{
684
- return vtpmx_fops_ioctl(f, ioctl, (unsigned long)compat_ptr(arg));
685
-}
686
-#endif
687
-
688673 static const struct file_operations vtpmx_fops = {
689674 .owner = THIS_MODULE,
690675 .unlocked_ioctl = vtpmx_fops_ioctl,
691
-#ifdef CONFIG_COMPAT
692
- .compat_ioctl = vtpmx_fops_compat_ioctl,
693
-#endif
676
+ .compat_ioctl = compat_ptr_ioctl,
694677 .llseek = noop_llseek,
695678 };
696679
....@@ -700,37 +683,21 @@
700683 .fops = &vtpmx_fops,
701684 };
702685
703
-static int vtpmx_init(void)
704
-{
705
- return misc_register(&vtpmx_miscdev);
706
-}
707
-
708
-static void vtpmx_cleanup(void)
709
-{
710
- misc_deregister(&vtpmx_miscdev);
711
-}
712
-
713686 static int __init vtpm_module_init(void)
714687 {
715688 int rc;
716689
717
- rc = vtpmx_init();
718
- if (rc) {
719
- pr_err("couldn't create vtpmx device\n");
720
- return rc;
721
- }
722
-
723690 workqueue = create_workqueue("tpm-vtpm");
724691 if (!workqueue) {
725692 pr_err("couldn't create workqueue\n");
726
- rc = -ENOMEM;
727
- goto err_vtpmx_cleanup;
693
+ return -ENOMEM;
728694 }
729695
730
- return 0;
731
-
732
-err_vtpmx_cleanup:
733
- vtpmx_cleanup();
696
+ rc = misc_register(&vtpmx_miscdev);
697
+ if (rc) {
698
+ pr_err("couldn't create vtpmx device\n");
699
+ destroy_workqueue(workqueue);
700
+ }
734701
735702 return rc;
736703 }
....@@ -738,7 +705,7 @@
738705 static void __exit vtpm_module_exit(void)
739706 {
740707 destroy_workqueue(workqueue);
741
- vtpmx_cleanup();
708
+ misc_deregister(&vtpmx_miscdev);
742709 }
743710
744711 module_init(vtpm_module_init);