From patchwork Fri Dec 26 04:44:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 5542171 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 1C8579F326 for ; Fri, 26 Dec 2014 04:45:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D7572012D for ; Fri, 26 Dec 2014 04:45:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 15AD620107 for ; Fri, 26 Dec 2014 04:45:24 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id BC05926517F; Fri, 26 Dec 2014 05:45:22 +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 BA252265141; Fri, 26 Dec 2014 05:45:14 +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 B7BD0265152; Fri, 26 Dec 2014 05:45:13 +0100 (CET) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by alsa0.perex.cz (Postfix) with ESMTP id A0CA3265132 for ; Fri, 26 Dec 2014 05:45:05 +0100 (CET) Received: by mail-pd0-f170.google.com with SMTP id v10so12523419pde.29 for ; Thu, 25 Dec 2014 20:45:04 -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=2EdTt9AtuSBmJM71uCoQqt8JlszntR4KAassewoDaGY=; b=lvCKdmJsNcIAB1WrZNB4o8mYGQRKZVMwAHG0op2lIwz1Ed2XfEuVVi8y4aVwhyAQrx pCR+IY6niOdqjMOVMWQ2MIKJyBiFRAe9J+LEOAyBkZB7GDLe83uycZxSjOK3n/Ty2SxH ct9T8wtGwpDHndei+Mkn0LOvJ6xLbBJ8uuwOQppMxeMVXrzHAO0kzaquXlokZ40b4e5F aHyO8bUx7uYkFtYeiPjUan8m14khdHW6uykOcbyqPiKZ9UZeB0fPDJSjQbYHEobi7kfz mONMBkbEpWxHt3YPVFGIR/OCvVQ+q7NKUQrsCTRUWDmOYacsLpJDeZi0f7LpFNfCnprr oNDw== X-Received: by 10.68.195.133 with SMTP id ie5mr12377875pbc.46.1419569104513; Thu, 25 Dec 2014 20:45:04 -0800 (PST) Received: from vaishali-Ideapad-Z570 ([150.107.240.197]) by mx.google.com with ESMTPSA id nr15sm26792047pdb.73.2014.12.25.20.45.02 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Dec 2014 20:45:03 -0800 (PST) Date: Fri, 26 Dec 2014 10:14:57 +0530 From: Vaishali Thakkar To: broonie@kernel.org Message-ID: <20141226044457.GA12777@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_be16. 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 Acked-by: Charles Keepax --- 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;