From patchwork Fri Dec 26 04:39:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 5542161 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 51B9A9F3CC for ; Fri, 26 Dec 2014 04:40:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8292220148 for ; Fri, 26 Dec 2014 04:40:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0797920103 for ; Fri, 26 Dec 2014 04:40:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E3749265171; Fri, 26 Dec 2014 05:40:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 933AD265152; Fri, 26 Dec 2014 05:39:56 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0D63D265163; Fri, 26 Dec 2014 05:39:55 +0100 (CET) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by alsa0.perex.cz (Postfix) with ESMTP id DB10D265141 for ; Fri, 26 Dec 2014 05:39:46 +0100 (CET) Received: by mail-pa0-f50.google.com with SMTP id bj1so12707199pad.9 for ; Thu, 25 Dec 2014 20:39:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=5CYGrq98RwMwkCWRTBu4gJ/Ex7SeJtb09p7xG49eBwI=; b=Bg5daEj/rz2jOn/DOXxydfoTTy9Cjt86t89/p454oF/fQjAxzLJKTDVGrJghihikv+ g8AjiyZB7qNHcaGFz+OKMcqKV6axp7M89gJTbakXv4N0wv67imatmEfHu2bpnZcSkXp3 2nMuyBA3Jeqx3D2yqMO+EkbG52X+7bL0szci7g82uQJJdrHRHiKGBtKyroJ8QY93UZgt PWa35CCSuKQhFUqlBWUChNaQmjkfgPIJoX4OJB9xU1tzaCBTGpK3LRmNLA2PEJuhM78d awB1qwqgKttmtnLCue7nSMzIVMSzr9/dInXUd65JVimnFp4zH7z08Bo3u5FqM2QSEUoH fR0g== X-Received: by 10.70.128.232 with SMTP id nr8mr34340067pdb.110.1419568785037; Thu, 25 Dec 2014 20:39:45 -0800 (PST) Received: from vaishali-Ideapad-Z570 ([150.107.240.197]) by mx.google.com with ESMTPSA id or4sm10687336pab.30.2014.12.25.20.39.42 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Dec 2014 20:39:43 -0800 (PST) Date: Fri, 26 Dec 2014 10:09:37 +0530 From: Vaishali Thakkar To: Mark Brown Message-ID: <20141226043937.GA12723@vaishali-Ideapad-Z570> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Takashi Iwai , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] ASoC: wm5102: Use put_unaligned_be16 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" 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 X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces the use of function put_unaligned_le16. This is done using Coccinelle and semantic patch used is as follows: @a@ typedef u16, __be16, uint16_t; {u16,__be16,uint16_t} e16; identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_be16(y); <+... when != tmp ( - memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__be16)\|sizeof(uint16_t)\|sizeof(e16)\)); + put_unaligned_be16(y,ptr); | - memcpy(ptr, (T)&tmp, ...); + put_unaligned_be16(y,ptr); ) ...+> ? tmp = e @@ type T; identifier a.tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar --- sound/soc/codecs/wm5102.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index f602349..fec21f9 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -28,6 +28,7 @@ #include #include +#include #include "arizona.h" #include "wm5102.h" @@ -617,11 +618,11 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct arizona *arizona = dev_get_drvdata(codec->dev->parent); - uint16_t data; mutex_lock(&codec->mutex); - data = cpu_to_be16(arizona->dac_comp_coeff); - memcpy(ucontrol->value.bytes.data, &data, sizeof(data)); + + put_unaligned_be16(arizona->dac_comp_coeff, + ucontrol->value.bytes.data); mutex_unlock(&codec->mutex); return 0;