Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3315802pxk; Mon, 21 Sep 2020 10:24:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2B0OI0WUFFNoDcI2paxwFb3KP7T6XTDy48zaHi148qaSn51+Ui3qKqIQc/GCMKMTeBl4A X-Received: by 2002:a17:906:82c8:: with SMTP id a8mr537971ejy.174.1600709064571; Mon, 21 Sep 2020 10:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600709064; cv=none; d=google.com; s=arc-20160816; b=vm0FAEfns91IYSZkRUbJyEq2ONB/4OxQRnmCJ9VlW/HsgK+03Os30TCmJ0XlpIwLvs V7olqhw2PRhyIYkhv6Enx1mgytmCJwwnqyp52NQcSnzcZdCpnZVV29vscsdToS1RfLGa ZJIfyU5dvsR1JkVJ9FTwSVlfMQ4KVUbMJmuOoV4Lth2BOU29BvHmi9x7io60ns9zAheJ NUTJY28Tvr6j01RddxYJKycd4w6pxLCvUqBcjlDtDSHOkfxcKzbXZT8QuC3rymWMuSMu X1LanR5DtiSlnmWDM0HsiNADz0K84w5bajxtBd4eoAOc16QYwsGc7TtrgxOmbqP3A8ly H4Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5eEdVeBjREunXQ/esIC8A/92F1rU6OvwLOe193k+NyY=; b=uCdMAe7FCk2fVdkL7G/t2fNQnPl/Tg3xghp/Lv/u79m5nwmBQEIBizow1Acxmz4oau Ck/UPsj5WgvFS+1Yb8BMru2emm1OopQnRSWW3KmgTX91M1gGoIXngfZ+ZEEfUCnxyJ+t tnZCcy8Cd6UAlN0CitAh8fLwivB7JkVjQfG0iaRVqXxBBd7RHhDB8fpPM2Fimeh8hh1D E31yDd/nwbMAJBKK1hHhjnXumfWlxvJLLA7QPzKxp/7ptwl9lpQ6zPqYoHIklxTl0Jc+ HJb+JZYUIA6KvhQuzuzhHT/GNEkLxLvTzk425XxOB67u0wMAFmk2M4xl+RvUdQXZ3Qwy as7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dez6+QkH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si8597393ejt.139.2020.09.21.10.24.00; Mon, 21 Sep 2020 10:24:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dez6+QkH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbgIURWj (ORCPT + 99 others); Mon, 21 Sep 2020 13:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbgIURWj (ORCPT ); Mon, 21 Sep 2020 13:22:39 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87D11C061755; Mon, 21 Sep 2020 10:22:39 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id v8so9519528iom.6; Mon, 21 Sep 2020 10:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=5eEdVeBjREunXQ/esIC8A/92F1rU6OvwLOe193k+NyY=; b=Dez6+QkHxZPpqfsN5aPsPbBdNSLRM/Ok6lm7nbUpv4YEnKEv9fx90K0qvKt1w/fiOz agseOobdbg5hYqnDq1dFb9je+XEtyecu8jTUo4zOQKBo7jjy13/BUglJocLEyGp9vHL5 zZRN+oDAy14TmmzBlIRKeGu12JkIiVyrcK8S8ZdC7hw/IZSFMEY8BZVcSTpTs/Bcb85u 3TX/DnysCV7hxm3xjoJSxUj6CP9G2QH74Y4xs5KuQE6cMdfK3aX12wX4nPWDt50P7sG2 FRKgZ1KB5hHFqb0ZNSRTXQ3xnjFiuYKcrPxrMJT30ds1K2B/QscDS7MdOiu/v08FL99A Lopw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=5eEdVeBjREunXQ/esIC8A/92F1rU6OvwLOe193k+NyY=; b=f6CrImmVehkb3QlAIynJ0cXK1ewJungTDcgmE2B6QDbJ4cXts8kUb6iub/d/uRhQbt SQ5nnwDTPHFltyDGm9xic0PDnjnhNLhTcRYBXOspbpbTO+aCu9qWBrxDPw6QjNI3J2ac EL7Qye2XYrTjsJghRxjgfTnbgCocdJezysyRDd7JMhWN6o+veoxmG08WgKGk45LAd5kP OWCxtkqfQRmFHL2n6ivaNORnjW5wj8WsiFfXL8JW37NK/mF8X+QRdCiLrdQ6XX1qa/Mq WyTrQD42UmHSQ2UviBwsY8s4HLRGKcGOihtE8NRJu2Nfgga47pvGcSIiW6GE8+gr6lP0 m34Q== X-Gm-Message-State: AOAM5321IUckeeyzse/n8xZLB9WtZ0a7RBZSVRIVYiiBxRwZT1SC26YU gPdK/JdFgFtTam8ikhzZArzHChSsXV4jUeLC4Rc= X-Received: by 2002:a5e:a613:: with SMTP id q19mr392021ioi.36.1600708958749; Mon, 21 Sep 2020 10:22:38 -0700 (PDT) MIME-Version: 1.0 References: <20200921102731.747736-1-peron.clem@gmail.com> <20200921102731.747736-4-peron.clem@gmail.com> <20200921135530.q36i4l5m4p7u7zyy@gilmour.lan> In-Reply-To: <20200921135530.q36i4l5m4p7u7zyy@gilmour.lan> From: =?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?= Date: Mon, 21 Sep 2020 19:22:27 +0200 Message-ID: Subject: Re: [PATCH v4 03/22] ASoC: sun4i-i2s: Change get_sr() and get_wss() to be more explicit To: Maxime Ripard Cc: Chen-Yu Tsai , Rob Herring , Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Marcus Cooper , Jernej Skrabec , Linux-ALSA , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, On Mon, 21 Sep 2020 at 15:55, Maxime Ripard wrote: > > On Mon, Sep 21, 2020 at 12:27:12PM +0200, Cl=C3=A9ment P=C3=A9ron wrote: > > We are actually using a complex formula to just return a bunch of > > simple values. Also this formula is wrong for sun4i. > > Just like the previous patch, this could use a bit more explanation, > like why it's a good thing, or how it's wrong on sun4i Okay I will comment a bit more. > > > Replace this with a simpler switch case. > > > > Also drop the i2s params not used. > > > > Signed-off-by: Cl=C3=A9ment P=C3=A9ron > > --- > > sound/soc/sunxi/sun4i-i2s.c | 69 +++++++++++++++++++++++-------------- > > 1 file changed, 44 insertions(+), 25 deletions(-) > > > > diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c > > index 0633b9fba3d7..11bbcbe24d6b 100644 > > --- a/sound/soc/sunxi/sun4i-i2s.c > > +++ b/sound/soc/sunxi/sun4i-i2s.c > > @@ -175,8 +175,8 @@ struct sun4i_i2s_quirks { > > unsigned int num_mclk_dividers; > > > > unsigned long (*get_bclk_parent_rate)(const struct sun4i_i2s *); > > - s8 (*get_sr)(const struct sun4i_i2s *, int); > > - s8 (*get_wss)(const struct sun4i_i2s *, int); > > + int (*get_sr)(unsigned int width); > > + int (*get_wss)(unsigned int width); > > int (*set_chan_cfg)(const struct sun4i_i2s *i2s, > > unsigned int channels, unsigned int slot= s, > > unsigned int slot_width); > > @@ -381,37 +381,56 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_= dai *dai, > > return 0; > > } > > > > -static s8 sun4i_i2s_get_sr(const struct sun4i_i2s *i2s, int width) > > +static int sun4i_i2s_get_sr(unsigned int width) > > { > > - if (width < 16 || width > 24) > > - return -EINVAL; > > - > > - if (width % 4) > > - return -EINVAL; > > + switch (width) { > > + case 16: > > + return 0x0; > > + case 20: > > + return 0x1; > > + case 24: > > + return 0x2; > > + } > > Why do we need an hex number here? This is a register value, so I thought it's usually written using hexadecimal representation. > > Also, why is the return type change needed? This function returns a ERROR defined in errno.h which actually could be -133 but S8 only supports -128..127. There is no real reason to have a S8 here and doesn't give any optimisation= . Clement > > Maxime