[tpmdd-devel,v6,7/8] tpm: Use read/write_bytes for drivers without more specialized methods
diff mbox

Message ID 1461363085-9908-8-git-send-email-christophe-h.ricard@st.com
State New
Headers show

Commit Message

Christophe Ricard April 22, 2016, 10:11 p.m. UTC
Some drivers might need to implement only functions for transferring an
arbitrary number of bytes. Provides a generic functions for handling  of
word or dword transfers to be dump into driver functions pointers.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
 drivers/char/tpm/tpm_tis_core.c | 30 ++++++++++++++++++++++++++++++
 drivers/char/tpm/tpm_tis_core.h |  4 ++++
 2 files changed, 34 insertions(+)

Comments

Jarkko Sakkinen May 2, 2016, 8:32 p.m. UTC | #1
On Sat, Apr 23, 2016 at 12:11:24AM +0200, Christophe Ricard wrote:
> Some drivers might need to implement only functions for transferring an
> arbitrary number of bytes. Provides a generic functions for handling  of
> word or dword transfers to be dump into driver functions pointers.
> 
> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>

Ignore my comment for 6/8. This patch is not necessary for the series.

/Jarkko

> ---
>  drivers/char/tpm/tpm_tis_core.c | 30 ++++++++++++++++++++++++++++++
>  drivers/char/tpm/tpm_tis_core.h |  4 ++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index f4e05ac..fd9c6a5 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -854,6 +854,36 @@ int tpm_tis_resume(struct device *dev)
>  EXPORT_SYMBOL_GPL(tpm_tis_resume);
>  #endif
>  
> +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result)
> +{
> +	int rc;
> +
> +	rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result);
> +	if (!rc)
> +		*result = le16_to_cpu(*result);
> +	return rc;
> +}
> +EXPORT_SYMBOL_GPL(tpm_tis_common_read16);
> +
> +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result)
> +{
> +	int rc;
> +
> +	rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), (u8 *)result);
> +	if (!rc)
> +		*result = le32_to_cpu(*result);
> +	return rc;
> +}
> +EXPORT_SYMBOL_GPL(tpm_tis_common_read32);
> +
> +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value)
> +{
> +	value = cpu_to_le32(value);
> +	return data->phy_ops->write_bytes(data, addr, sizeof(u32),
> +					   (u8 *)&value);
> +}
> +EXPORT_SYMBOL_GPL(tpm_tis_common_write32);
> +
>  MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
>  MODULE_DESCRIPTION("TPM Driver");
>  MODULE_VERSION("2.0");
> diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
> index 91aa305..bdc7899 100644
> --- a/drivers/char/tpm/tpm_tis_core.h
> +++ b/drivers/char/tpm/tpm_tis_core.h
> @@ -141,6 +141,10 @@ static inline int tpm_write32(struct tpm_tis_data *data, u32 addr, u32 value)
>  	return data->phy_ops->write32(data, addr, value);
>  }
>  
> +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result);
> +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result);
> +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value);
> +
>  void tpm_tis_remove(struct tpm_chip *chip);
>  int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>  		      const struct tpm_tis_phy_ops *phy_ops,
> -- 
> 2.1.4
> 

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
Christophe Ricard May 3, 2016, 8:28 p.m. UTC | #2
Ok will do

On 02/05/2016 22:32, Jarkko Sakkinen wrote:
> On Sat, Apr 23, 2016 at 12:11:24AM +0200, Christophe Ricard wrote:
>> Some drivers might need to implement only functions for transferring an
>> arbitrary number of bytes. Provides a generic functions for handling  of
>> word or dword transfers to be dump into driver functions pointers.
>>
>> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
>> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
> Ignore my comment for 6/8. This patch is not necessary for the series.
>
> /Jarkko
>
>> ---
>>   drivers/char/tpm/tpm_tis_core.c | 30 ++++++++++++++++++++++++++++++
>>   drivers/char/tpm/tpm_tis_core.h |  4 ++++
>>   2 files changed, 34 insertions(+)
>>
>> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
>> index f4e05ac..fd9c6a5 100644
>> --- a/drivers/char/tpm/tpm_tis_core.c
>> +++ b/drivers/char/tpm/tpm_tis_core.c
>> @@ -854,6 +854,36 @@ int tpm_tis_resume(struct device *dev)
>>   EXPORT_SYMBOL_GPL(tpm_tis_resume);
>>   #endif
>>   
>> +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result)
>> +{
>> +	int rc;
>> +
>> +	rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result);
>> +	if (!rc)
>> +		*result = le16_to_cpu(*result);
>> +	return rc;
>> +}
>> +EXPORT_SYMBOL_GPL(tpm_tis_common_read16);
>> +
>> +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result)
>> +{
>> +	int rc;
>> +
>> +	rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), (u8 *)result);
>> +	if (!rc)
>> +		*result = le32_to_cpu(*result);
>> +	return rc;
>> +}
>> +EXPORT_SYMBOL_GPL(tpm_tis_common_read32);
>> +
>> +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value)
>> +{
>> +	value = cpu_to_le32(value);
>> +	return data->phy_ops->write_bytes(data, addr, sizeof(u32),
>> +					   (u8 *)&value);
>> +}
>> +EXPORT_SYMBOL_GPL(tpm_tis_common_write32);
>> +
>>   MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
>>   MODULE_DESCRIPTION("TPM Driver");
>>   MODULE_VERSION("2.0");
>> diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
>> index 91aa305..bdc7899 100644
>> --- a/drivers/char/tpm/tpm_tis_core.h
>> +++ b/drivers/char/tpm/tpm_tis_core.h
>> @@ -141,6 +141,10 @@ static inline int tpm_write32(struct tpm_tis_data *data, u32 addr, u32 value)
>>   	return data->phy_ops->write32(data, addr, value);
>>   }
>>   
>> +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result);
>> +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result);
>> +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value);
>> +
>>   void tpm_tis_remove(struct tpm_chip *chip);
>>   int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>>   		      const struct tpm_tis_phy_ops *phy_ops,
>> -- 
>> 2.1.4
>>


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
Jarkko Sakkinen May 4, 2016, 10:52 a.m. UTC | #3
On Tue, 2016-05-03 at 22:28 +0200, Christophe Ricard wrote:
> Ok will do

Great, I'll start testing the next version if they apply cleanly to my
tree.

/Jarkko

> On 02/05/2016 22:32, Jarkko Sakkinen wrote:
> > 
> > On Sat, Apr 23, 2016 at 12:11:24AM +0200, Christophe Ricard wrote:
> > > 
> > > Some drivers might need to implement only functions for transferring an
> > > arbitrary number of bytes. Provides a generic functions for handling  of
> > > word or dword transfers to be dump into driver functions pointers.
> > > 
> > > Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> > > Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
> > Ignore my comment for 6/8. This patch is not necessary for the series.
> > 
> > /Jarkko
> > 
> > > 
> > > ---
> > >   drivers/char/tpm/tpm_tis_core.c | 30 ++++++++++++++++++++++++++++++
> > >   drivers/char/tpm/tpm_tis_core.h |  4 ++++
> > >   2 files changed, 34 insertions(+)
> > > 
> > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > > index f4e05ac..fd9c6a5 100644
> > > --- a/drivers/char/tpm/tpm_tis_core.c
> > > +++ b/drivers/char/tpm/tpm_tis_core.c
> > > @@ -854,6 +854,36 @@ int tpm_tis_resume(struct device *dev)
> > >   EXPORT_SYMBOL_GPL(tpm_tis_resume);
> > >   #endif
> > >   
> > > +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result)
> > > +{
> > > +	int rc;
> > > +
> > > +	rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result);
> > > +	if (!rc)
> > > +		*result = le16_to_cpu(*result);
> > > +	return rc;
> > > +}
> > > +EXPORT_SYMBOL_GPL(tpm_tis_common_read16);
> > > +
> > > +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result)
> > > +{
> > > +	int rc;
> > > +
> > > +	rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), (u8 *)result);
> > > +	if (!rc)
> > > +		*result = le32_to_cpu(*result);
> > > +	return rc;
> > > +}
> > > +EXPORT_SYMBOL_GPL(tpm_tis_common_read32);
> > > +
> > > +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value)
> > > +{
> > > +	value = cpu_to_le32(value);
> > > +	return data->phy_ops->write_bytes(data, addr, sizeof(u32),
> > > +					   (u8 *)&value);
> > > +}
> > > +EXPORT_SYMBOL_GPL(tpm_tis_common_write32);
> > > +
> > >   MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
> > >   MODULE_DESCRIPTION("TPM Driver");
> > >   MODULE_VERSION("2.0");
> > > diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
> > > index 91aa305..bdc7899 100644
> > > --- a/drivers/char/tpm/tpm_tis_core.h
> > > +++ b/drivers/char/tpm/tpm_tis_core.h
> > > @@ -141,6 +141,10 @@ static inline int tpm_write32(struct tpm_tis_data *data, u32
> > > addr, u32 value)
> > >   	return data->phy_ops->write32(data, addr, value);
> > >   }
> > >   
> > > +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result);
> > > +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result);
> > > +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value);
> > > +
> > >   void tpm_tis_remove(struct tpm_chip *chip);
> > >   int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> > >   		      const struct tpm_tis_phy_ops *phy_ops,

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

Patch
diff mbox

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index f4e05ac..fd9c6a5 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -854,6 +854,36 @@  int tpm_tis_resume(struct device *dev)
 EXPORT_SYMBOL_GPL(tpm_tis_resume);
 #endif
 
+int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result)
+{
+	int rc;
+
+	rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result);
+	if (!rc)
+		*result = le16_to_cpu(*result);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(tpm_tis_common_read16);
+
+int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result)
+{
+	int rc;
+
+	rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), (u8 *)result);
+	if (!rc)
+		*result = le32_to_cpu(*result);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(tpm_tis_common_read32);
+
+int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value)
+{
+	value = cpu_to_le32(value);
+	return data->phy_ops->write_bytes(data, addr, sizeof(u32),
+					   (u8 *)&value);
+}
+EXPORT_SYMBOL_GPL(tpm_tis_common_write32);
+
 MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
 MODULE_DESCRIPTION("TPM Driver");
 MODULE_VERSION("2.0");
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 91aa305..bdc7899 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -141,6 +141,10 @@  static inline int tpm_write32(struct tpm_tis_data *data, u32 addr, u32 value)
 	return data->phy_ops->write32(data, addr, value);
 }
 
+int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result);
+int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result);
+int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value);
+
 void tpm_tis_remove(struct tpm_chip *chip);
 int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		      const struct tpm_tis_phy_ops *phy_ops,