Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01ad1fa7 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Peter Huewe
Browse files

tpm: Create a tpm_class_ops structure and use it in the drivers



This replaces the static initialization of a tpm_vendor_specific
structure in the drivers with the standard Linux idiom of providing
a const structure of function pointers.

Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: default avatarJoel Schopp <jschopp@linux.vnet.ibm.com>
Reviewed-by: default avatarAshley Lai <adlai@linux.vnet.ibm.com>
[phuewe: did apply manually due to commit
191ffc6bde3 tpm/tpm_i2c_atmel: fix coccinelle warnings]
Signed-off-by: default avatarPeter Huewe <peterhuewe@gmx.de>
parent 1e3b73a9
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1060,7 +1060,7 @@ static void tpm_dev_release(struct device *dev)
 * pci_disable_device
 */
struct tpm_chip *tpm_register_hardware(struct device *dev,
					const struct tpm_vendor_specific *entry)
				       const struct tpm_class_ops *ops)
{
	struct tpm_chip *chip;

@@ -1073,7 +1073,13 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
	mutex_init(&chip->tpm_mutex);
	INIT_LIST_HEAD(&chip->list);

	memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific));
	chip->vendor.req_complete_mask = ops->req_complete_mask;
	chip->vendor.req_complete_val = ops->req_complete_val;
	chip->vendor.req_canceled = ops->req_canceled;
	chip->vendor.recv = ops->recv;
	chip->vendor.send = ops->send;
	chip->vendor.cancel = ops->cancel;
	chip->vendor.status = ops->status;

	chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES);

+3 −3
Original line number Diff line number Diff line
@@ -64,8 +64,8 @@ enum tpm_duration {
struct tpm_chip;

struct tpm_vendor_specific {
	const u8 req_complete_mask;
	const u8 req_complete_val;
	u8 req_complete_mask;
	u8 req_complete_val;
	bool (*req_canceled)(struct tpm_chip *chip, u8 status);
	void __iomem *iobase;		/* ioremapped address */
	unsigned long base;		/* TPM base address */
@@ -336,7 +336,7 @@ extern void tpm_gen_interrupt(struct tpm_chip *);
extern int tpm_do_selftest(struct tpm_chip *);
extern unsigned long tpm_calc_ordinal_duration(struct tpm_chip *, u32);
extern struct tpm_chip* tpm_register_hardware(struct device *,
				 const struct tpm_vendor_specific *);
					      const struct tpm_class_ops *ops);
extern void tpm_dev_vendor_release(struct tpm_chip *);
extern void tpm_remove_hardware(struct device *);
extern int tpm_pm_suspend(struct device *);
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ static bool tpm_atml_req_canceled(struct tpm_chip *chip, u8 status)
	return (status == ATML_STATUS_READY);
}

static const struct tpm_vendor_specific tpm_atmel = {
static const struct tpm_class_ops tpm_atmel = {
	.recv = tpm_atml_recv,
	.send = tpm_atml_send,
	.cancel = tpm_atml_cancel,
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ static bool i2c_atmel_req_canceled(struct tpm_chip *chip, u8 status)
	return false;
}

static const struct tpm_vendor_specific i2c_atmel = {
static const struct tpm_class_ops i2c_atmel = {
	.status = i2c_atmel_read_status,
	.recv = i2c_atmel_recv,
	.send = i2c_atmel_send,
+1 −1
Original line number Diff line number Diff line
@@ -566,7 +566,7 @@ static bool tpm_tis_i2c_req_canceled(struct tpm_chip *chip, u8 status)
	return (status == TPM_STS_COMMAND_READY);
}

static struct tpm_vendor_specific tpm_tis_i2c = {
static const struct tpm_class_ops tpm_tis_i2c = {
	.status = tpm_tis_i2c_status,
	.recv = tpm_tis_i2c_recv,
	.send = tpm_tis_i2c_send,
Loading