From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752260AbcGODN6 (ORCPT ); Thu, 14 Jul 2016 23:13:58 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:34994 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751279AbcGODN4 (ORCPT ); Thu, 14 Jul 2016 23:13:56 -0400 Date: Thu, 14 Jul 2016 21:13:51 -0600 From: Jason Gunthorpe To: Andrey Pronin 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 Subject: Re: [PATCH 1/2] tpm_tis_core: add optional max xfer size check Message-ID: <20160715031351.GD9347@obsidianresearch.com> References: <1468546745-14646-1-git-send-email-apronin@chromium.org> <1468546745-14646-2-git-send-email-apronin@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1468546745-14646-2-git-send-email-apronin@chromium.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.151 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 14, 2016 at 06:39:04PM -0700, Andrey Pronin wrote: > +static inline u16 tpm_tis_max_xfer_size(struct tpm_tis_data *data) > +{ > + return data->phy_ops->max_xfer_size; > +} > + > +static inline bool tpm_tis_burstcnt_is_valid(struct tpm_tis_data *data, > + u16 burstcnt) > +{ > + return (tpm_tis_max_xfer_size(data) == 0) > + || (burstcnt <= tpm_tis_max_xfer_size(data)); > +} We don't need these accessors, just open code it in the one call site. That is more clear as the ==0 case is important to understand that the flow is correct. BTW, I dodn't think || as the start of a line was cannonical kernel style.. Did checkpatch accept that? Jason From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Subject: Re: [PATCH 1/2] tpm_tis_core: add optional max xfer size check Date: Thu, 14 Jul 2016 21:13:51 -0600 Message-ID: <20160715031351.GD9347@obsidianresearch.com> References: <1468546745-14646-1-git-send-email-apronin@chromium.org> <1468546745-14646-2-git-send-email-apronin@chromium.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1468546745-14646-2-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Andrey Pronin Cc: 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 List-Id: tpmdd-devel@lists.sourceforge.net On Thu, Jul 14, 2016 at 06:39:04PM -0700, Andrey Pronin wrote: > +static inline u16 tpm_tis_max_xfer_size(struct tpm_tis_data *data) > +{ > + return data->phy_ops->max_xfer_size; > +} > + > +static inline bool tpm_tis_burstcnt_is_valid(struct tpm_tis_data *data, > + u16 burstcnt) > +{ > + return (tpm_tis_max_xfer_size(data) == 0) > + || (burstcnt <= tpm_tis_max_xfer_size(data)); > +} We don't need these accessors, just open code it in the one call site. That is more clear as the ==0 case is important to understand that the flow is correct. BTW, I dodn't think || as the start of a line was cannonical kernel style.. Did checkpatch accept that? Jason ------------------------------------------------------------------------------ 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