Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 26111
b: refs/heads/master
c: 90dda52
h: refs/heads/master
i:
  26109: cba9b9a
  26107: 518fc0f
  26103: 85d778e
  26095: 65e310b
  26079: a4bfeb3
  26047: b3fd1ae
  25983: fb41147
  25855: f6e42e6
  25599: e77db04
v: v3
  • Loading branch information
Kylene Jo Hall authored and Linus Torvalds committed Apr 22, 2006
1 parent 9947597 commit ef1a864
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 56 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: beed53a1aaeaae4eb93297c23f1598a726716adf
refs/heads/master: 90dda520c1962d55a0e1d2571deed0d75fd6d6f1
48 changes: 23 additions & 25 deletions trunk/drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,20 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,

down(&chip->tpm_mutex);

if ((rc = chip->vendor->send(chip, (u8 *) buf, count)) < 0) {
if ((rc = chip->vendor.send(chip, (u8 *) buf, count)) < 0) {
dev_err(chip->dev,
"tpm_transmit: tpm_send: error %zd\n", rc);
goto out;
}

stop = jiffies + 2 * 60 * HZ;
do {
u8 status = chip->vendor->status(chip);
if ((status & chip->vendor->req_complete_mask) ==
chip->vendor->req_complete_val) {
u8 status = chip->vendor.status(chip);
if ((status & chip->vendor.req_complete_mask) ==
chip->vendor.req_complete_val)
goto out_recv;
}

if ((status == chip->vendor->req_canceled)) {
if ((status == chip->vendor.req_canceled)) {
dev_err(chip->dev, "Operation Canceled\n");
rc = -ECANCELED;
goto out;
Expand All @@ -102,14 +101,13 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
rmb();
} while (time_before(jiffies, stop));


chip->vendor->cancel(chip);
chip->vendor.cancel(chip);
dev_err(chip->dev, "Operation Timed out\n");
rc = -ETIME;
goto out;

out_recv:
rc = chip->vendor->recv(chip, (u8 *) buf, bufsiz);
rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz);
if (rc < 0)
dev_err(chip->dev,
"tpm_transmit: tpm_recv: error %zd\n", rc);
Expand Down Expand Up @@ -340,7 +338,7 @@ ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr,
if (chip == NULL)
return 0;

chip->vendor->cancel(chip);
chip->vendor.cancel(chip);
return count;
}
EXPORT_SYMBOL_GPL(tpm_store_cancel);
Expand All @@ -356,7 +354,7 @@ int tpm_open(struct inode *inode, struct file *file)
spin_lock(&driver_lock);

list_for_each_entry(pos, &tpm_chip_list, list) {
if (pos->vendor->miscdev.minor == minor) {
if (pos->vendor.miscdev.minor == minor) {
chip = pos;
break;
}
Expand Down Expand Up @@ -488,14 +486,14 @@ void tpm_remove_hardware(struct device *dev)
spin_unlock(&driver_lock);

dev_set_drvdata(dev, NULL);
misc_deregister(&chip->vendor->miscdev);
kfree(chip->vendor->miscdev.name);
misc_deregister(&chip->vendor.miscdev);
kfree(chip->vendor.miscdev.name);

sysfs_remove_group(&dev->kobj, chip->vendor->attr_group);
sysfs_remove_group(&dev->kobj, chip->vendor.attr_group);
tpm_bios_log_teardown(chip->bios_dir);

dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &=
~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES] &=
~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));

kfree(chip);

Expand Down Expand Up @@ -569,7 +567,7 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)
chip->user_read_timer.function = user_reader_timeout;
chip->user_read_timer.data = (unsigned long) chip;

chip->vendor = entry;
memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific));

chip->dev_num = -1;

Expand All @@ -588,22 +586,22 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)
kfree(chip);
return -ENODEV;
} else if (chip->dev_num == 0)
chip->vendor->miscdev.minor = TPM_MINOR;
chip->vendor.miscdev.minor = TPM_MINOR;
else
chip->vendor->miscdev.minor = MISC_DYNAMIC_MINOR;
chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR;

devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL);
scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
chip->vendor->miscdev.name = devname;
chip->vendor.miscdev.name = devname;

chip->vendor->miscdev.dev = dev;
chip->vendor.miscdev.dev = dev;
chip->dev = get_device(dev);

if (misc_register(&chip->vendor->miscdev)) {
if (misc_register(&chip->vendor.miscdev)) {
dev_err(chip->dev,
"unable to misc_register %s, minor %d\n",
chip->vendor->miscdev.name,
chip->vendor->miscdev.minor);
chip->vendor.miscdev.name,
chip->vendor.miscdev.minor);
put_device(dev);
kfree(chip);
dev_mask[i] &= !(1 << j);
Expand All @@ -618,7 +616,7 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)

spin_unlock(&driver_lock);

sysfs_create_group(&dev->kobj, chip->vendor->attr_group);
sysfs_create_group(&dev->kobj, chip->vendor.attr_group);

chip->bios_dir = tpm_bios_log_setup(devname);

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct tpm_chip {
struct work_struct work;
struct semaphore tpm_mutex; /* tpm is processing */

struct tpm_vendor_specific *vendor;
struct tpm_vendor_specific vendor;

struct dentry **bios_dir;

Expand Down
26 changes: 13 additions & 13 deletions trunk/drivers/char/tpm/tpm_atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
return -EIO;

for (i = 0; i < 6; i++) {
status = ioread8(chip->vendor->iobase + 1);
status = ioread8(chip->vendor.iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(chip->dev, "error reading header\n");
return -EIO;
}
*buf++ = ioread8(chip->vendor->iobase);
*buf++ = ioread8(chip->vendor.iobase);
}

/* size of the data received */
Expand All @@ -63,7 +63,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
dev_err(chip->dev,
"Recv size(%d) less than available space\n", size);
for (; i < size; i++) { /* clear the waiting data anyway */
status = ioread8(chip->vendor->iobase + 1);
status = ioread8(chip->vendor.iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(chip->dev, "error reading data\n");
return -EIO;
Expand All @@ -74,16 +74,16 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)

/* read all the data available */
for (; i < size; i++) {
status = ioread8(chip->vendor->iobase + 1);
status = ioread8(chip->vendor.iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(chip->dev, "error reading data\n");
return -EIO;
}
*buf++ = ioread8(chip->vendor->iobase);
*buf++ = ioread8(chip->vendor.iobase);
}

/* make sure data available is gone */
status = ioread8(chip->vendor->iobase + 1);
status = ioread8(chip->vendor.iobase + 1);

if (status & ATML_STATUS_DATA_AVAIL) {
dev_err(chip->dev, "data available is stuck\n");
Expand All @@ -100,20 +100,20 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
dev_dbg(chip->dev, "tpm_atml_send:\n");
for (i = 0; i < count; i++) {
dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]);
iowrite8(buf[i], chip->vendor->iobase);
iowrite8(buf[i], chip->vendor.iobase);
}

return count;
}

static void tpm_atml_cancel(struct tpm_chip *chip)
{
iowrite8(ATML_STATUS_ABORT, chip->vendor->iobase + 1);
iowrite8(ATML_STATUS_ABORT, chip->vendor.iobase + 1);
}

static u8 tpm_atml_status(struct tpm_chip *chip)
{
return ioread8(chip->vendor->iobase + 1);
return ioread8(chip->vendor.iobase + 1);
}

static struct file_operations atmel_ops = {
Expand Down Expand Up @@ -159,10 +159,10 @@ static void atml_plat_remove(void)
struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);

if (chip) {
if (chip->vendor->have_region)
atmel_release_region(chip->vendor->base,
chip->vendor->region_size);
atmel_put_base_addr(chip->vendor);
if (chip->vendor.have_region)
atmel_release_region(chip->vendor.base,
chip->vendor.region_size);
atmel_put_base_addr(chip->vendor.iobase);
tpm_remove_hardware(chip->dev);
platform_device_unregister(pdev);
}
Expand Down
32 changes: 16 additions & 16 deletions trunk/drivers/char/tpm/tpm_nsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
unsigned long stop;

/* status immediately available check */
*data = inb(chip->vendor->base + NSC_STATUS);
*data = inb(chip->vendor.base + NSC_STATUS);
if ((*data & mask) == val)
return 0;

/* wait for status */
stop = jiffies + 10 * HZ;
do {
msleep(TPM_TIMEOUT);
*data = inb(chip->vendor->base + 1);
*data = inb(chip->vendor.base + 1);
if ((*data & mask) == val)
return 0;
}
Expand All @@ -94,19 +94,19 @@ static int nsc_wait_for_ready(struct tpm_chip *chip)
unsigned long stop;

/* status immediately available check */
status = inb(chip->vendor->base + NSC_STATUS);
status = inb(chip->vendor.base + NSC_STATUS);
if (status & NSC_STATUS_OBF)
status = inb(chip->vendor->base + NSC_DATA);
status = inb(chip->vendor.base + NSC_DATA);
if (status & NSC_STATUS_RDY)
return 0;

/* wait for status */
stop = jiffies + 100;
do {
msleep(TPM_TIMEOUT);
status = inb(chip->vendor->base + NSC_STATUS);
status = inb(chip->vendor.base + NSC_STATUS);
if (status & NSC_STATUS_OBF)
status = inb(chip->vendor->base + NSC_DATA);
status = inb(chip->vendor.base + NSC_DATA);
if (status & NSC_STATUS_RDY)
return 0;
}
Expand All @@ -132,7 +132,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO;
}
if ((data =
inb(chip->vendor->base + NSC_DATA)) != NSC_COMMAND_NORMAL) {
inb(chip->vendor.base + NSC_DATA)) != NSC_COMMAND_NORMAL) {
dev_err(chip->dev, "not in normal mode (0x%x)\n",
data);
return -EIO;
Expand All @@ -148,15 +148,15 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
}
if (data & NSC_STATUS_F0)
break;
*p = inb(chip->vendor->base + NSC_DATA);
*p = inb(chip->vendor.base + NSC_DATA);
}

if ((data & NSC_STATUS_F0) == 0 &&
(wait_for_stat(chip, NSC_STATUS_F0, NSC_STATUS_F0, &data) < 0)) {
dev_err(chip->dev, "F0 not set\n");
return -EIO;
}
if ((data = inb(chip->vendor->base + NSC_DATA)) != NSC_COMMAND_EOC) {
if ((data = inb(chip->vendor.base + NSC_DATA)) != NSC_COMMAND_EOC) {
dev_err(chip->dev,
"expected end of command(0x%x)\n", data);
return -EIO;
Expand All @@ -182,7 +182,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
* fix it. Not sure why this is needed, we followed the flow
* chart in the manual to the letter.
*/
outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND);
outb(NSC_COMMAND_CANCEL, chip->vendor.base + NSC_COMMAND);

if (nsc_wait_for_ready(chip) != 0)
return -EIO;
Expand All @@ -192,7 +192,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO;
}

outb(NSC_COMMAND_NORMAL, chip->vendor->base + NSC_COMMAND);
outb(NSC_COMMAND_NORMAL, chip->vendor.base + NSC_COMMAND);
if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) {
dev_err(chip->dev, "IBR timeout\n");
return -EIO;
Expand All @@ -204,26 +204,26 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
"IBF timeout (while writing data)\n");
return -EIO;
}
outb(buf[i], chip->vendor->base + NSC_DATA);
outb(buf[i], chip->vendor.base + NSC_DATA);
}

if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) {
dev_err(chip->dev, "IBF timeout\n");
return -EIO;
}
outb(NSC_COMMAND_EOC, chip->vendor->base + NSC_COMMAND);
outb(NSC_COMMAND_EOC, chip->vendor.base + NSC_COMMAND);

return count;
}

static void tpm_nsc_cancel(struct tpm_chip *chip)
{
outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND);
outb(NSC_COMMAND_CANCEL, chip->vendor.base + NSC_COMMAND);
}

static u8 tpm_nsc_status(struct tpm_chip *chip)
{
return inb(chip->vendor->base + NSC_STATUS);
return inb(chip->vendor.base + NSC_STATUS);
}

static struct file_operations nsc_ops = {
Expand Down Expand Up @@ -268,7 +268,7 @@ static void __devexit tpm_nsc_remove(struct device *dev)
{
struct tpm_chip *chip = dev_get_drvdata(dev);
if ( chip ) {
release_region(chip->vendor->base, 2);
release_region(chip->vendor.base, 2);
tpm_remove_hardware(chip->dev);
}
}
Expand Down

0 comments on commit ef1a864

Please sign in to comment.