From: Takashi Iwai Subject: Re: [PATCH 0/7] ALSA: USB-audio: Support Zoom R16 playback Date: Fri, 16 Oct 2015 14:27:57 +0200 Message-ID: References: <1444906657-16791-1-git-send-email-ricardw@axis.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id BB0D6260673 for ; Fri, 16 Oct 2015 14:27:57 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Ricard Wanderlof Cc: Ricard =?UTF-8?B?V2FuZGVybMO2Zg==?= , Ricard Wanderlof , alsa-devel List-Id: alsa-devel@alsa-project.org On Fri, 16 Oct 2015 13:20:22 +0200, Ricard Wanderlof wrote: > > > On Fri, 16 Oct 2015, Takashi Iwai wrote: > > > > unsigned int length; > > > u32 packet_length = cpu_to_le32((u32)length); > > > > No, other way round: the problem is that packet_length is declared as > > u32 while it should be __le32. The length variable must be CPU > > endian, of course, as you apply C arithmetic. > > So the cast shouldn't be necessary then, i.e. just simply: > > unsigned int length; > __le32 packet_length = cpu_to_le32(length); > > ? > > It makes sense to me (although that doesn't necessarily make it right. :-) ) Right, it's the correct usage. The __le32 data converted via cpu_to_le32() means just a 32bit raw data and can't be used for arithmetic operation. It's different from integer. By annotation, we can catch such failures more easily. Takashi