tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Andrey Pronin <apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Jarkko Sakkinen
	<jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: Christophe Ricard
	<christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	smbarber-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	groeck-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Subject: Re: [PATCH 2/2] tpm: add driver for cr50 on SPI
Date: Tue, 19 Jul 2016 17:24:11 -0700	[thread overview]
Message-ID: <20160720002411.GA147098@apronin> (raw)
In-Reply-To: <20160719125527.GB5047-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

On Tue, Jul 19, 2016 at 03:55:27PM +0300, Jarkko Sakkinen wrote:
> On Thu, Jul 14, 2016 at 08:44:44PM -0700, Andrey Pronin wrote:
> > On Thu, Jul 14, 2016 at 09:32:36PM -0600, Jason Gunthorpe wrote:
> > > On Thu, Jul 14, 2016 at 07:20:18PM -0700, Andrey Pronin wrote:
> > > 
> > > > +static int cr50_spi_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;
> > > > +}
> > > 
> > > I thought we had core support for this pattern?
> > > 
> > > Christophe ?
> > > 
> > > Please change this so this code isn't duplicated.
> > > 
> > > Jason
> > >
> > Hmm, didn't see the support. Would be great if there is.
> > The pattern itself is copied from tpm_tis_spi as is.
> > read_bytes/write_bytes were de-dup'ed as they used a lot of common code
> > (even more for this driver than for tpm_tis_spi).
> > But as for _readNN/_writeNN, there're only three of these functions,
> > so it din't seem too bad.
> 
> If there isn't, please add a separate commit before this that adds an
> inline function to tpm_tis_core.h.
>
tpm_tis_core.h currently has access functions defined like:
static inline int tpm_tis_read16(struct tpm_tis_data *data, u32 addr,
                                 u16 *result)
{
        return data->phy_ops->read16(data, addr, result);
}

And it's up to the drivers implementing phy_ops to do (or not)
byte-swapping as necessary before/after IO ops. For example,
tpm_tis.c in its phy_ops->read16 simply does ioread16(), while
tpm_tis_spi.c (and cr50_spi.c) does phy_ops->read_bytes()
followed by le16_to_cpu().

Still, I can create add'l inline functions:
static inline int tpm_tis_read_le16(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;
}
and re-use them both in cr50_spi.c and tpm_tis_spi.c

The only two things that bother me with such approach are
(1) whatever names I pick for the new set of functions, they
    will be similar to and thus might be confused with the
    original tpm_tis_read/writeXX;
(2) these functions are phy-specific, so possibly it's better
    to create tpm_tis_spi.h and put them there with proper
    name prefixes. And then use in tpm_tis_spi and cr50_spi.

Any preferences on what I should better do?

Andrey

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

  parent reply	other threads:[~2016-07-20  0:24 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-15  2:20 [PATCH 0/2] tpm: add driver for cr50 on SPI Andrey Pronin
     [not found] ` <1468549218-19215-1-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-15  2:20   ` [PATCH 1/2] tpm: devicetree: document properties for cr50 Andrey Pronin
2016-07-15  4:05     ` Guenter Roeck
     [not found]       ` <CABXOdTcVcZ10c6uShN2AXUZfOuK=FESeo73Assi0sziMZJ_+Fw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-15 17:31         ` Andrey Pronin
2016-07-15 18:28           ` Guenter Roeck
     [not found]     ` <1468549218-19215-2-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-17 13:28       ` Rob Herring
2016-07-15  2:20   ` [PATCH 2/2] tpm: add driver for cr50 on SPI Andrey Pronin
     [not found]     ` <1468549218-19215-3-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-15  3:32       ` Jason Gunthorpe
     [not found]         ` <20160715033236.GH9347-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-07-15  3:44           ` Andrey Pronin
2016-07-19 12:55             ` Jarkko Sakkinen
     [not found]               ` <20160719125527.GB5047-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-07-20  0:24                 ` Andrey Pronin [this message]
2016-07-20 17:03                   ` Jason Gunthorpe
     [not found]                     ` <20160720170336.GC21460-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-07-21 18:10                       ` Andrey Pronin
2016-07-21 21:00                         ` Jason Gunthorpe
2016-07-15  2:28   ` [PATCH 0/2] " Peter Huewe
2016-07-15  2:50     ` Andrey Pronin
2016-07-15  3:28       ` Jason Gunthorpe
     [not found]         ` <20160715032814.GG9347-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-07-15 17:15           ` Andrey Pronin
2016-07-20  3:41   ` [PATCH v2 " Andrey Pronin
     [not found]   ` <cover.1468985673.git.apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-20  3:41     ` [PATCH v2 1/2] tpm: devicetree: document properties for cr50 Andrey Pronin
2016-07-20 19:03       ` Rob Herring
2016-07-20 19:49         ` Andrey Pronin
2016-07-20 19:54           ` Jason Gunthorpe
     [not found]             ` <20160720195422.GA30947-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-07-27 21:02               ` Andrey Pronin
2016-07-21 21:03           ` Rob Herring
2016-07-27 21:00             ` Andrey Pronin
2016-07-20  3:41     ` [PATCH v2 2/2] tpm: add driver for cr50 on SPI Andrey Pronin
2016-07-25 17:09     ` [PATCH v2 0/2] " Peter Huewe
2016-07-27 21:12       ` Andrey Pronin
2016-07-28  4:25   ` [PATCH v3 " Andrey Pronin
     [not found]   ` <1469679917-120240-1-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-28  4:25     ` [PATCH v3 1/2] tpm: devicetree: document properties for cr50 Andrey Pronin
2016-07-28  4:25     ` [PATCH v3 2/2] tpm: add driver for cr50 on SPI Andrey Pronin
2016-07-28 23:01       ` Dmitry Torokhov
2016-07-28 23:17         ` Jason Gunthorpe
     [not found]           ` <20160728231706.GA22087-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-07-29  3:01             ` Andrey Pronin
2016-07-29  1:55   ` [PATCH v4 0/2] " Andrey Pronin
     [not found]   ` <1469757314-116169-1-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-29  1:55     ` [PATCH v4 1/2] tpm: devicetree: document properties for cr50 Andrey Pronin
     [not found]       ` <1469757314-116169-2-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-29 17:27         ` Jason Gunthorpe
     [not found]           ` <20160729172752.GA7458-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-07-29 21:42             ` Rob Herring
2016-08-09 10:08         ` Jarkko Sakkinen
2016-07-29  1:55     ` [PATCH v4 2/2] tpm: add driver for cr50 on SPI Andrey Pronin
2016-08-09 10:20       ` Jarkko Sakkinen
2016-07-19 12:56 ` [PATCH 0/2] " Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160720002411.GA147098@apronin \
    --to=apronin-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
    --cc=christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=groeck-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smbarber-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).