From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932079AbcGODov (ORCPT ); Thu, 14 Jul 2016 23:44:51 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:36844 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751503AbcGODos (ORCPT ); Thu, 14 Jul 2016 23:44:48 -0400 Date: Thu, 14 Jul 2016 20:44:44 -0700 From: Andrey Pronin To: Jason Gunthorpe Cc: Jarkko Sakkinen , Peter Huewe , Marcel Selhorst , tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, groeck@chromium.org, smbarber@chromium.org, dianders@chromium.org, Christophe Ricard Subject: Re: [PATCH 2/2] tpm: add driver for cr50 on SPI Message-ID: <20160715034444.GA28128@apronin> References: <1468549218-19215-1-git-send-email-apronin@chromium.org> <1468549218-19215-3-git-send-email-apronin@chromium.org> <20160715033236.GH9347@obsidianresearch.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160715033236.GH9347@obsidianresearch.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.