Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759771AbbFBSNh (ORCPT ); Tue, 2 Jun 2015 14:13:37 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:33107 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754325AbbFBSN2 (ORCPT ); Tue, 2 Jun 2015 14:13:28 -0400 Date: Tue, 2 Jun 2015 12:13:15 -0600 From: Jason Gunthorpe To: Jarkko Sakkinen Cc: peterhuewe@gmx.de, safford@us.ibm.com, Marcel Selhorst , "moderated list:TPM DEVICE DRIVER" , open list Subject: Re: [PATCH] tpm: introduce struct tpm_buf Message-ID: <20150602181315.GE17776@obsidianresearch.com> References: <1433250262-17200-1-git-send-email-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433250262-17200-1-git-send-email-jarkko.sakkinen@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.192 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1287 Lines: 48 On Tue, Jun 02, 2015 at 04:04:22PM +0300, Jarkko Sakkinen wrote: > +/* A string buffer type for constructing TPM commands. This is based on the > + * code in security/keys/trusted.h. > + */ > + > +#define TPM_BUF_SIZE 512 > + > +struct tpm_buf { > + u8 data[TPM_BUF_SIZE]; This should be u32 or u64 to guarentee correct alignment for the casting. > +}; > + > +static inline void tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal) > +{ > + struct tpm_input_header *head; > + > + head = (struct tpm_input_header *) buf->data; > + > + head->tag = cpu_to_be16(tag); > + head->length = cpu_to_be32(sizeof(*head)); > + head->ordinal = cpu_to_be32(ordinal); > +} > + > +static inline u32 tpm_buf_length(struct tpm_buf *buf) > +{ > + struct tpm_input_header *head = (struct tpm_input_header *) buf->data; > + > + return be32_to_cpu(head->length); > +} > + > +static inline u16 tpm_buf_tag(struct tpm_buf *buf) > +{ > + return be16_to_cpu(*(__be16 *) &buf->data[0]); be16_to_cpup ? Any thought on someday using this for tpm1 as well? Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/