Commit 4d08a363 authored by James Morris's avatar James Morris

Merge branch 'for-current' of https://github.com/PeterHuewe/linux-tpmdd into for-linus

parents 9eccca08 19913b6d
...@@ -140,24 +140,24 @@ static int tpm_dev_add_device(struct tpm_chip *chip) ...@@ -140,24 +140,24 @@ static int tpm_dev_add_device(struct tpm_chip *chip)
{ {
int rc; int rc;
rc = device_add(&chip->dev); rc = cdev_add(&chip->cdev, chip->dev.devt, 1);
if (rc) { if (rc) {
dev_err(&chip->dev, dev_err(&chip->dev,
"unable to device_register() %s, major %d, minor %d, err=%d\n", "unable to cdev_add() %s, major %d, minor %d, err=%d\n",
chip->devname, MAJOR(chip->dev.devt), chip->devname, MAJOR(chip->dev.devt),
MINOR(chip->dev.devt), rc); MINOR(chip->dev.devt), rc);
device_unregister(&chip->dev);
return rc; return rc;
} }
rc = cdev_add(&chip->cdev, chip->dev.devt, 1); rc = device_add(&chip->dev);
if (rc) { if (rc) {
dev_err(&chip->dev, dev_err(&chip->dev,
"unable to cdev_add() %s, major %d, minor %d, err=%d\n", "unable to device_register() %s, major %d, minor %d, err=%d\n",
chip->devname, MAJOR(chip->dev.devt), chip->devname, MAJOR(chip->dev.devt),
MINOR(chip->dev.devt), rc); MINOR(chip->dev.devt), rc);
device_unregister(&chip->dev);
return rc; return rc;
} }
...@@ -174,27 +174,17 @@ static void tpm_dev_del_device(struct tpm_chip *chip) ...@@ -174,27 +174,17 @@ static void tpm_dev_del_device(struct tpm_chip *chip)
* tpm_chip_register() - create a character device for the TPM chip * tpm_chip_register() - create a character device for the TPM chip
* @chip: TPM chip to use. * @chip: TPM chip to use.
* *
* Creates a character device for the TPM chip and adds sysfs interfaces for * Creates a character device for the TPM chip and adds sysfs attributes for
* the device, PPI and TCPA. As the last step this function adds the * the device. As the last step this function adds the chip to the list of TPM
* chip to the list of TPM chips available for use. * chips available for in-kernel use.
* *
* NOTE: This function should be only called after the chip initialization * This function should be only called after the chip initialization is
* is complete. * complete.
*
* Called from tpm_<specific>.c probe function only for devices
* the driver has determined it should claim. Prior to calling
* this function the specific probe function has called pci_enable_device
* upon errant exit from this function specific probe function should call
* pci_disable_device
*/ */
int tpm_chip_register(struct tpm_chip *chip) int tpm_chip_register(struct tpm_chip *chip)
{ {
int rc; int rc;
rc = tpm_dev_add_device(chip);
if (rc)
return rc;
/* Populate sysfs for TPM1 devices. */ /* Populate sysfs for TPM1 devices. */
if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
rc = tpm_sysfs_add_device(chip); rc = tpm_sysfs_add_device(chip);
...@@ -208,6 +198,10 @@ int tpm_chip_register(struct tpm_chip *chip) ...@@ -208,6 +198,10 @@ int tpm_chip_register(struct tpm_chip *chip)
chip->bios_dir = tpm_bios_log_setup(chip->devname); chip->bios_dir = tpm_bios_log_setup(chip->devname);
} }
rc = tpm_dev_add_device(chip);
if (rc)
return rc;
/* Make the chip available. */ /* Make the chip available. */
spin_lock(&driver_lock); spin_lock(&driver_lock);
list_add_rcu(&chip->list, &tpm_chip_list); list_add_rcu(&chip->list, &tpm_chip_list);
......
...@@ -124,7 +124,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -124,7 +124,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
{ {
struct ibmvtpm_dev *ibmvtpm; struct ibmvtpm_dev *ibmvtpm;
struct ibmvtpm_crq crq; struct ibmvtpm_crq crq;
u64 *word = (u64 *) &crq; __be64 *word = (__be64 *)&crq;
int rc; int rc;
ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip); ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip);
...@@ -145,11 +145,11 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -145,11 +145,11 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count); memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count);
crq.valid = (u8)IBMVTPM_VALID_CMD; crq.valid = (u8)IBMVTPM_VALID_CMD;
crq.msg = (u8)VTPM_TPM_COMMAND; crq.msg = (u8)VTPM_TPM_COMMAND;
crq.len = (u16)count; crq.len = cpu_to_be16(count);
crq.data = ibmvtpm->rtce_dma_handle; crq.data = cpu_to_be32(ibmvtpm->rtce_dma_handle);
rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(word[0]), rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]),
cpu_to_be64(word[1])); be64_to_cpu(word[1]));
if (rc != H_SUCCESS) { if (rc != H_SUCCESS) {
dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc); dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc);
rc = 0; rc = 0;
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
struct ibmvtpm_crq { struct ibmvtpm_crq {
u8 valid; u8 valid;
u8 msg; u8 msg;
u16 len; __be16 len;
u32 data; __be32 data;
u64 reserved; __be64 reserved;
} __attribute__((packed, aligned(8))); } __attribute__((packed, aligned(8)));
struct ibmvtpm_crq_queue { struct ibmvtpm_crq_queue {
......
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