Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 3065
b: refs/heads/master
c: 6659ca2
h: refs/heads/master
i:
  3063: 32a5330
v: v3
  • Loading branch information
Kylene Hall authored and Linus Torvalds committed Jun 24, 2005
1 parent 2a8d92c commit 3e23b24
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 14 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: 81179bb6a54c2c626b4cbcc084ca974bb2d7f2a3
refs/heads/master: 6659ca2ab6730c3bbb9fa495f2327b95b955decd
35 changes: 23 additions & 12 deletions trunk/drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ static const u8 pcrread[] = {
0, 0, 0, 0 /* PCR index */
};

static ssize_t show_pcrs(struct device *dev, struct device_attribute *attr, char *buf)
ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
char *buf)
{
u8 data[READ_PCR_RESULT_SIZE];
ssize_t len;
Expand Down Expand Up @@ -243,7 +244,7 @@ static ssize_t show_pcrs(struct device *dev, struct device_attribute *attr, char
return str - buf;
}

static DEVICE_ATTR(pcrs, S_IRUGO, show_pcrs, NULL);
EXPORT_SYMBOL_GPL(tpm_show_pcrs);

#define READ_PUBEK_RESULT_SIZE 314
static const u8 readpubek[] = {
Expand All @@ -252,7 +253,8 @@ static const u8 readpubek[] = {
0, 0, 0, 124, /* TPM_ORD_ReadPubek */
};

static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf)
ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
char *buf)
{
u8 *data;
ssize_t len;
Expand Down Expand Up @@ -311,7 +313,7 @@ static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, cha
return rc;
}

static DEVICE_ATTR(pubek, S_IRUGO, show_pubek, NULL);
EXPORT_SYMBOL_GPL(tpm_show_pubek);

#define CAP_VER_RESULT_SIZE 18
static const u8 cap_version[] = {
Expand All @@ -332,7 +334,8 @@ static const u8 cap_manufacturer[] = {
0, 0, 1, 3
};

static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf)
ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
char *buf)
{
u8 data[sizeof(cap_manufacturer)];
ssize_t len;
Expand Down Expand Up @@ -365,8 +368,20 @@ static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char

return str - buf;
}
EXPORT_SYMBOL_GPL(tpm_show_caps);

ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct tpm_chip *chip = dev_get_drvdata(dev);
if (chip == NULL)
return 0;

chip->vendor->cancel(chip);
return count;
}
EXPORT_SYMBOL_GPL(tpm_store_cancel);

static DEVICE_ATTR(caps, S_IRUGO, show_caps, NULL);

/*
* Device file system interface to the TPM
Expand Down Expand Up @@ -517,9 +532,7 @@ void __devexit tpm_remove(struct pci_dev *pci_dev)
pci_set_drvdata(pci_dev, NULL);
misc_deregister(&chip->vendor->miscdev);

device_remove_file(&pci_dev->dev, &dev_attr_pubek);
device_remove_file(&pci_dev->dev, &dev_attr_pcrs);
device_remove_file(&pci_dev->dev, &dev_attr_caps);
sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group);

pci_disable_device(pci_dev);

Expand Down Expand Up @@ -648,9 +661,7 @@ int tpm_register_hardware(struct pci_dev *pci_dev,

list_add(&chip->list, &tpm_chip_list);

device_create_file(&pci_dev->dev, &dev_attr_pubek);
device_create_file(&pci_dev->dev, &dev_attr_pcrs);
device_create_file(&pci_dev->dev, &dev_attr_caps);
sysfs_create_group(&pci_dev->dev.kobj, chip->vendor->attr_group);

return 0;
}
Expand Down
9 changes: 9 additions & 0 deletions trunk/drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ enum tpm_addr {
TPM_DATA = 0x4F
};

extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr,
char *);
extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr,
char *);
extern ssize_t tpm_show_caps(struct device *, struct device_attribute *attr,
char *);
extern ssize_t tpm_store_cancel(struct device *, struct device_attribute *attr,
const char *, size_t);

struct tpm_chip;

Expand All @@ -47,6 +55,7 @@ struct tpm_vendor_specific {
int (*send) (struct tpm_chip *, u8 *, size_t);
void (*cancel) (struct tpm_chip *);
struct miscdevice miscdev;
struct attribute_group *attr_group;
};

struct tpm_chip {
Expand Down
16 changes: 16 additions & 0 deletions trunk/drivers/char/tpm/tpm_atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,29 @@ static struct file_operations atmel_ops = {
.release = tpm_release,
};

static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
static DEVICE_ATTR(cancel, S_IWUSR |S_IWGRP, NULL, tpm_store_cancel);

static struct attribute* atmel_attrs[] = {
&dev_attr_pubek.attr,
&dev_attr_pcrs.attr,
&dev_attr_caps.attr,
&dev_attr_cancel.attr,
0,
};

static struct attribute_group atmel_attr_grp = { .attrs = atmel_attrs };

static struct tpm_vendor_specific tpm_atmel = {
.recv = tpm_atml_recv,
.send = tpm_atml_send,
.cancel = tpm_atml_cancel,
.req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
.req_complete_val = ATML_STATUS_DATA_AVAIL,
.base = TPM_ATML_BASE,
.attr_group = &atmel_attr_grp,
.miscdev = { .fops = &atmel_ops, },
};

Expand Down
17 changes: 16 additions & 1 deletion trunk/drivers/char/tpm/tpm_nsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,30 @@ static struct file_operations nsc_ops = {
.release = tpm_release,
};

static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
static DEVICE_ATTR(cancel, S_IWUSR|S_IWGRP, NULL, tpm_store_cancel);

static struct attribute * nsc_attrs[] = {
&dev_attr_pubek.attr,
&dev_attr_pcrs.attr,
&dev_attr_caps.attr,
&dev_attr_cancel.attr,
0,
};

static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs };

static struct tpm_vendor_specific tpm_nsc = {
.recv = tpm_nsc_recv,
.send = tpm_nsc_send,
.cancel = tpm_nsc_cancel,
.req_complete_mask = NSC_STATUS_OBF,
.req_complete_val = NSC_STATUS_OBF,
.base = TPM_NSC_BASE,
.attr_group = &nsc_attr_grp,
.miscdev = { .fops = &nsc_ops, },

};

static int __devinit tpm_nsc_init(struct pci_dev *pci_dev,
Expand Down

0 comments on commit 3e23b24

Please sign in to comment.