From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 1/3] Fix GPE registers read/write handling. Date: Wed, 4 Feb 2009 14:39:57 +0200 Message-ID: <20090204123957.GF30234@redhat.com> References: <20090204095805.6892.47195.stgit@dhcp-1-237.tlv.redhat.com> <49898A13.8030706@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:48722 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbZBDMmT (ORCPT ); Wed, 4 Feb 2009 07:42:19 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n14CgJBe030460 for ; Wed, 4 Feb 2009 07:42:19 -0500 Content-Disposition: inline In-Reply-To: <49898A13.8030706@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Feb 04, 2009 at 02:29:07PM +0200, Avi Kivity wrote: > Gleb Natapov wrote: >> For STS register bit are cleared by writing 1 into it. >> >> +static uint16_t gpe_write_val(uint16_t cur, int addr, uint32_t val) >> +{ >> + if (addr & 1) >> + return (cur & 0xff) | (val << 8); >> + return (cur & 0xff00) | (val & 0xff); >> +} >> + >> +static uint16_t gpe_reset_val(uint16_t cur, int addr, uint32_t val) >> +{ >> + uint16_t x1, x0 = val & 0xff; >> + int shift = (addr & 1) ? 8 : 0; >> + >> + x1 = (cur >> shift) & 0xff; >> + >> + x1 = x1 & ~x0; >> + >> + return (cur & (0xff << (8 - shift))) | (x1 << shift); >> +} >> > > It's strange that write_val() and reset_val() return a value. Won't it > be cleaner to make val a pointer? > >>From functional programing POV no, it is not cleaner. But I don't really care where to do assignment. -- Gleb.