From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dimitris Papastamos Subject: Re: [PATCH 4/4] ASoC: clean up cache accesser Date: Mon, 20 Dec 2010 16:27:49 +0000 Message-ID: <1292862469.29185.7.camel@dplaptop.localdomain> References: <20101220152709.GJ26706@rakim.wolfsonmicro.main> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from opensource2.wolfsonmicro.com (opensource.wolfsonmicro.com [80.75.67.52]) by alsa0.perex.cz (Postfix) with ESMTP id E5C51244AD for ; Mon, 20 Dec 2010 17:27:07 +0100 (CET) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Takashi Iwai Cc: alsa-devel@alsa-project.org, Mark Brown , Liam Girdwood List-Id: alsa-devel@alsa-project.org On Mon, 2010-12-20 at 17:05 +0100, Takashi Iwai wrote: > +static inline bool set_cache_val(void *base, unsigned int idx, > + unsigned int val, unsigned int word_size) > +{ > + if (word_size == 1) { > + u8 *cache = base; > + if (cache[idx] == val) > + return true; > + cache[idx] = val; > + } else { > + u16 *cache = base; > + if (cache[idx] == val) > + return true; > + cache[idx] = val; > + } > + return false; > +} If word_size is anything other than 1 byte, the above else will try to handle it and assume it is 16 bits. I'd expect for an explicit check for word_size == 2. A switch statement would perhaps be preferred for legibility. It'd perhaps be wise to simply die via BUG() or similar if an unsupported word size was passed in. > +static inline unsigned int get_cache_val(const void *base, unsigned int idx, > + unsigned int word_size) > +{ > + if (word_size == 1) { > + const u8 *cache = base; > + return cache[idx]; > + } else { > + const u16 *cache = base; > + return cache[idx]; > + } > +} Same here. The rest looks good. Thanks, Dimitrios