Skip to content

Commit

Permalink
tpm: rename chip->dev to chip->pdev
Browse files Browse the repository at this point in the history
Rename chip->dev to chip->pdev to make it explicit that this not the
character device but actually represents the platform device.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jasob Gunthorpe <jason.gunthorpe@obsidianresearch.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Peter Huewe <peterhuewe@gmx.de>
Tested-by: Scot Doyle <lkml14@scotdoyle.com>
Tested-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
  • Loading branch information
Jarkko Sakkinen authored and Peter Huewe committed Jan 17, 2015
1 parent 0dc5536 commit 71ed848
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 94 deletions.
4 changes: 2 additions & 2 deletions drivers/char/tpm/tpm-chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
continue;

if (try_module_get(pos->dev->driver->owner)) {
if (try_module_get(pos->pdev->driver->owner)) {
chip = pos;
break;
}
Expand Down Expand Up @@ -110,7 +110,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,

scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);

chip->dev = dev;
chip->pdev = dev;
devm_add_action(dev, tpmm_chip_remove, chip);
dev_set_drvdata(dev, chip);

Expand Down
10 changes: 5 additions & 5 deletions drivers/char/tpm/tpm-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static int tpm_open(struct inode *inode, struct file *file)
* by the check of is_open variable, which is protected
* by driver_lock. */
if (test_and_set_bit(0, &chip->is_open)) {
dev_dbg(chip->dev, "Another process owns this TPM\n");
dev_dbg(chip->pdev, "Another process owns this TPM\n");
return -EBUSY;
}

Expand All @@ -81,7 +81,7 @@ static int tpm_open(struct inode *inode, struct file *file)
INIT_WORK(&priv->work, timeout_work);

file->private_data = priv;
get_device(chip->dev);
get_device(chip->pdev);
return 0;
}

Expand Down Expand Up @@ -168,7 +168,7 @@ static int tpm_release(struct inode *inode, struct file *file)
file->private_data = NULL;
atomic_set(&priv->data_pending, 0);
clear_bit(0, &priv->chip->is_open);
put_device(priv->chip->dev);
put_device(priv->chip->pdev);
kfree(priv);
return 0;
}
Expand All @@ -193,12 +193,12 @@ int tpm_dev_add_device(struct tpm_chip *chip)
chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR;

chip->vendor.miscdev.name = chip->devname;
chip->vendor.miscdev.parent = chip->dev;
chip->vendor.miscdev.parent = chip->pdev;

rc = misc_register(&chip->vendor.miscdev);
if (rc) {
chip->vendor.miscdev.name = NULL;
dev_err(chip->dev,
dev_err(chip->pdev,
"unable to misc_register %s, minor %d err=%d\n",
chip->vendor.miscdev.name,
chip->vendor.miscdev.minor, rc);
Expand Down
29 changes: 15 additions & 14 deletions drivers/char/tpm/tpm-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
if (count == 0)
return -ENODATA;
if (count > bufsiz) {
dev_err(chip->dev,
dev_err(chip->pdev,
"invalid count value %x %zx\n", count, bufsiz);
return -E2BIG;
}
Expand All @@ -352,7 +352,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,

rc = chip->ops->send(chip, (u8 *) buf, count);
if (rc < 0) {
dev_err(chip->dev,
dev_err(chip->pdev,
"tpm_transmit: tpm_send: error %zd\n", rc);
goto out;
}
Expand All @@ -368,7 +368,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
goto out_recv;

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

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

out_recv:
rc = chip->ops->recv(chip, (u8 *) buf, bufsiz);
if (rc < 0)
dev_err(chip->dev,
dev_err(chip->pdev,
"tpm_transmit: tpm_recv: error %zd\n", rc);
out:
mutex_unlock(&chip->tpm_mutex);
Expand All @@ -411,7 +411,8 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd,

err = be32_to_cpu(header->return_code);
if (err != 0 && desc)
dev_err(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
dev_err(chip->pdev, "A TPM error (%d) occurred %s\n", err,
desc);

return err;
}
Expand Down Expand Up @@ -505,7 +506,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)
if (rc == TPM_ERR_INVALID_POSTINIT) {
/* The TPM is not started, we are the first to talk to it.
Execute a startup command. */
dev_info(chip->dev, "Issuing TPM_STARTUP");
dev_info(chip->pdev, "Issuing TPM_STARTUP");
if (tpm_startup(chip, TPM_ST_CLEAR))
return rc;

Expand All @@ -517,7 +518,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)
NULL);
}
if (rc) {
dev_err(chip->dev,
dev_err(chip->pdev,
"A TPM error (%zd) occurred attempting to determine the timeouts\n",
rc);
goto duration;
Expand Down Expand Up @@ -556,7 +557,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)

/* Report adjusted timeouts */
if (chip->vendor.timeout_adjusted) {
dev_info(chip->dev,
dev_info(chip->pdev,
HW_ERR "Adjusting reported timeouts: A %lu->%luus B %lu->%luus C %lu->%luus D %lu->%luus\n",
old_timeout[0], new_timeout[0],
old_timeout[1], new_timeout[1],
Expand Down Expand Up @@ -603,7 +604,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)
chip->vendor.duration[TPM_MEDIUM] *= 1000;
chip->vendor.duration[TPM_LONG] *= 1000;
chip->vendor.duration_adjusted = true;
dev_info(chip->dev, "Adjusting TPM timeout parameters.");
dev_info(chip->pdev, "Adjusting TPM timeout parameters.");
}
return 0;
}
Expand Down Expand Up @@ -760,7 +761,7 @@ int tpm_do_selftest(struct tpm_chip *chip)
* around 300ms while the self test is ongoing, keep trying
* until the self test duration expires. */
if (rc == -ETIME) {
dev_info(chip->dev, HW_ERR "TPM command timed out during continue self test");
dev_info(chip->pdev, HW_ERR "TPM command timed out during continue self test");
msleep(delay_msec);
continue;
}
Expand All @@ -770,7 +771,7 @@ int tpm_do_selftest(struct tpm_chip *chip)

rc = be32_to_cpu(cmd.header.out.return_code);
if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
dev_info(chip->dev,
dev_info(chip->pdev,
"TPM is disabled/deactivated (0x%X)\n", rc);
/* TPM is disabled and/or deactivated; driver can
* proceed and TPM does handle commands for
Expand Down Expand Up @@ -918,10 +919,10 @@ int tpm_pm_suspend(struct device *dev)
}

if (rc)
dev_err(chip->dev,
dev_err(chip->pdev,
"Error (%d) sending savestate before suspend\n", rc);
else if (try > 0)
dev_warn(chip->dev, "TPM savestate took %dms\n",
dev_warn(chip->pdev, "TPM savestate took %dms\n",
try * TPM_TIMEOUT_RETRY);

return rc;
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/tpm/tpm-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,16 @@ static const struct attribute_group tpm_dev_group = {
int tpm_sysfs_add_device(struct tpm_chip *chip)
{
int err;
err = sysfs_create_group(&chip->dev->kobj,
err = sysfs_create_group(&chip->pdev->kobj,
&tpm_dev_group);

if (err)
dev_err(chip->dev,
dev_err(chip->pdev,
"failed to create sysfs attributes, %d\n", err);
return err;
}

void tpm_sysfs_del_device(struct tpm_chip *chip)
{
sysfs_remove_group(&chip->dev->kobj, &tpm_dev_group);
sysfs_remove_group(&chip->pdev->kobj, &tpm_dev_group);
}
4 changes: 2 additions & 2 deletions drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enum tpm_chip_flags {
};

struct tpm_chip {
struct device *dev; /* Device stuff */
struct device *pdev; /* Device stuff */
const struct tpm_class_ops *ops;
unsigned int flags;

Expand All @@ -130,7 +130,7 @@ struct tpm_chip {

static inline void tpm_chip_put(struct tpm_chip *chip)
{
module_put(chip->dev->driver->owner);
module_put(chip->pdev->driver->owner);
}

static inline int tpm_read_index(int base, int index)
Expand Down
14 changes: 7 additions & 7 deletions drivers/char/tpm/tpm_atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
for (i = 0; i < 6; i++) {
status = ioread8(chip->vendor.iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(chip->dev, "error reading header\n");
dev_err(chip->pdev, "error reading header\n");
return -EIO;
}
*buf++ = ioread8(chip->vendor.iobase);
Expand All @@ -60,12 +60,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
size = be32_to_cpu(*native_size);

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

if (status & ATML_STATUS_DATA_AVAIL) {
dev_err(chip->dev, "data available is stuck\n");
dev_err(chip->pdev, "data available is stuck\n");
return -EIO;
}

Expand All @@ -97,9 +97,9 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
{
int i;

dev_dbg(chip->dev, "tpm_atml_send:\n");
dev_dbg(chip->pdev, "tpm_atml_send:\n");
for (i = 0; i < count; i++) {
dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]);
dev_dbg(chip->pdev, "%d 0x%x(%d)\n", i, buf[i], buf[i]);
iowrite8(buf[i], chip->vendor.iobase);
}

Expand Down
16 changes: 8 additions & 8 deletions drivers/char/tpm/tpm_i2c_atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct priv_data {
static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
{
struct priv_data *priv = chip->vendor.priv;
struct i2c_client *client = to_i2c_client(chip->dev);
struct i2c_client *client = to_i2c_client(chip->pdev);
s32 status;

priv->len = 0;
Expand All @@ -62,7 +62,7 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)

status = i2c_master_send(client, buf, len);

dev_dbg(chip->dev,
dev_dbg(chip->pdev,
"%s(buf=%*ph len=%0zx) -> sts=%d\n", __func__,
(int)min_t(size_t, 64, len), buf, len, status);
return status;
Expand All @@ -71,7 +71,7 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
struct priv_data *priv = chip->vendor.priv;
struct i2c_client *client = to_i2c_client(chip->dev);
struct i2c_client *client = to_i2c_client(chip->pdev);
struct tpm_output_header *hdr =
(struct tpm_output_header *)priv->buffer;
u32 expected_len;
Expand All @@ -88,7 +88,7 @@ static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
return -ENOMEM;

if (priv->len >= expected_len) {
dev_dbg(chip->dev,
dev_dbg(chip->pdev,
"%s early(buf=%*ph count=%0zx) -> ret=%d\n", __func__,
(int)min_t(size_t, 64, expected_len), buf, count,
expected_len);
Expand All @@ -97,7 +97,7 @@ static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
}

rc = i2c_master_recv(client, buf, expected_len);
dev_dbg(chip->dev,
dev_dbg(chip->pdev,
"%s reread(buf=%*ph count=%0zx) -> ret=%d\n", __func__,
(int)min_t(size_t, 64, expected_len), buf, count,
expected_len);
Expand All @@ -106,13 +106,13 @@ static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)

static void i2c_atmel_cancel(struct tpm_chip *chip)
{
dev_err(chip->dev, "TPM operation cancellation was requested, but is not supported");
dev_err(chip->pdev, "TPM operation cancellation was requested, but is not supported");
}

static u8 i2c_atmel_read_status(struct tpm_chip *chip)
{
struct priv_data *priv = chip->vendor.priv;
struct i2c_client *client = to_i2c_client(chip->dev);
struct i2c_client *client = to_i2c_client(chip->pdev);
int rc;

/* The TPM fails the I2C read until it is ready, so we do the entire
Expand All @@ -125,7 +125,7 @@ static u8 i2c_atmel_read_status(struct tpm_chip *chip)
/* Once the TPM has completed the command the command remains readable
* until another command is issued. */
rc = i2c_master_recv(client, priv->buffer, sizeof(priv->buffer));
dev_dbg(chip->dev,
dev_dbg(chip->pdev,
"%s: sts=%d", __func__, rc);
if (rc <= 0)
return 0;
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/tpm/tpm_i2c_infineon.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
/* read first 10 bytes, including tag, paramsize, and result */
size = recv_data(chip, buf, TPM_HEADER_SIZE);
if (size < TPM_HEADER_SIZE) {
dev_err(chip->dev, "Unable to read header\n");
dev_err(chip->pdev, "Unable to read header\n");
goto out;
}

Expand All @@ -459,14 +459,14 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
size += recv_data(chip, &buf[TPM_HEADER_SIZE],
expected - TPM_HEADER_SIZE);
if (size < expected) {
dev_err(chip->dev, "Unable to read remainder of result\n");
dev_err(chip->pdev, "Unable to read remainder of result\n");
size = -ETIME;
goto out;
}

wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status);
if (status & TPM_STS_DATA_AVAIL) { /* retry? */
dev_err(chip->dev, "Error left over data\n");
dev_err(chip->pdev, "Error left over data\n");
size = -EIO;
goto out;
}
Expand Down
Loading

0 comments on commit 71ed848

Please sign in to comment.