Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp857758ybl; Wed, 14 Aug 2019 07:04:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6SlPk19qjHThKfUeXZPsiaR9v3cQ5igJW8ul35bSgFUq0jZmU8+qktyFLc/kWvKiF7GT3 X-Received: by 2002:a62:1c93:: with SMTP id c141mr71278pfc.9.1565791492308; Wed, 14 Aug 2019 07:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565791492; cv=none; d=google.com; s=arc-20160816; b=CNhimUJtbNEZ+5pOkvjyx7K65fx5cCRBRta96dm9oJkLh9iQl2X3/VYyIhHlr4ERGa N15g/veSSJxchtLNRjlGULngmO/i0kb9e3fTga4N8s1o2a/sALybVYm7gJELLBiQFc0T sQTrHDRhEPA1cMePFcb8AGVBZUYZ54czUmF77CqZkfVOps670PxjRnbbEm5AGZ05zZfI 85akCuGLHD20rPtplKKDppKyKWcTEHVgRq6+fBBYsaUEKmUpok/jjGgVu14ywYzfTCdk kAuXKWBpAgpy4zqljP0IprQK8QOSNfcGoutLwEQHEo5XoB+4hsTgmStjh8AS+lokg4Of xRqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=4yyJi9mvJ20yARLulZ/YwvC751j0Jtj4v4REbTjJygM=; b=trsRtu1SAChR4F1qFFmS1bVr00TDhNFbtMZd82IDIO4vS4HYfrvSmlcoglokV0FzI+ JRErjsMO4t144m6eECUeVcqRXWgFMJAaUvfUDe2A4QkXkrgYkniogCgmKjqbEMlXRkwu MhlwU7RUhJcShFk+VUgeTwTxOE7+0fVGVuaOEjfTODhziMnZx7wpAbmEmsAXKuwKgW6I fk14ix4MnbksJzSziRSd3qkBSoSV2Wq8z6VoOhijTfmQK4ClErC4qzE3ZhMZdPaXhbwH n7Ikv+8gIFRDH7LELaQYAf6kODvyYBD1Kp1KcpPde9yBSAhh42jkb29EnmbN1/yc3FZF wy7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l185si66479745pgd.379.2019.08.14.07.04.34; Wed, 14 Aug 2019 07:04:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727814AbfHNODs (ORCPT + 99 others); Wed, 14 Aug 2019 10:03:48 -0400 Received: from mga18.intel.com ([134.134.136.126]:28212 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbfHNODr (ORCPT ); Wed, 14 Aug 2019 10:03:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2019 07:03:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,385,1559545200"; d="scan'208";a="376051764" Received: from dthummal-mobl.amr.corp.intel.com (HELO [10.254.111.70]) ([10.254.111.70]) by fmsmga005.fm.intel.com with ESMTP; 14 Aug 2019 07:03:46 -0700 Subject: Re: [alsa-devel] [PATCH 06/17] soundwire: cadence_master: use firmware defaults for frame shape To: Vinod Koul , Cezary Rojewski Cc: alsa-devel@alsa-project.org, Blauciak@vger.kernel.org, tiwai@suse.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, broonie@kernel.org, srinivas.kandagatla@linaro.org, jank@cadence.com, Slawomir , Sanyog Kale References: <20190806005522.22642-1-pierre-louis.bossart@linux.intel.com> <20190806005522.22642-7-pierre-louis.bossart@linux.intel.com> <03b6091b-af41-ac54-43c7-196a3583a731@intel.com> <024b4fb4-bdfa-a6dc-48bb-c070f2ed36b2@linux.intel.com> <2445b5dc-246c-9c3b-b26e-784032feccf9@intel.com> <20190814043139.GV12733@vkoul-mobl.Dlink> From: Pierre-Louis Bossart Message-ID: <0e40ecee-d081-3cee-3e95-cd3c0f3e5b30@linux.intel.com> Date: Wed, 14 Aug 2019 09:03:44 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190814043139.GV12733@vkoul-mobl.Dlink> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>>> +static u32 cdns_set_initial_frame_shape(int n_rows, int n_cols) >>>>> +{ >>>>> +    u32 val; >>>>> +    int c; >>>>> +    int r; >>>>> + >>>>> +    r = sdw_find_row_index(n_rows); >>>>> +    c = sdw_find_col_index(n_cols) & CDNS_MCP_FRAME_SHAPE_COL_MASK; >>>>> + >>>>> +    val = (r << CDNS_MCP_FRAME_SHAPE_ROW_OFFSET) | c; >>>>> + >>>>> +    return val; >>>>> +} >>>>> + >>>> >>>> Guess this have been said already, but this function could be >>>> simplified - unless you really want to keep explicit variable >>>> declaration. Both "c" and "r" declarations could be merged into >>>> single line while "val" is not needed at all. >>>> >>>> One more thing - is AND bitwise op really needed for cols >>>> explicitly? We know all col values upfront - these are static and >>>> declared in global table nearby. Static declaration takes care of >>>> "initial range-check". Is another one necessary? >>>> >>>> Moreover, this is a _get_ and certainly not a _set_ type of >>>> function. I'd even consider renaming it to: "cdns_get_frame_shape" >>>> as this is neither a _set_ nor an explicit initial frame shape >>>> setter. >>>> >>>> It might be even helpful to split two usages: >>>> >>>> #define sdw_frame_shape(col_idx, row_idx) \ >>>>      ((row_idx << CDNS_MCP_FRAME_SHAPE_ROW_OFFSET) | col_idx) >>>> >>>> u32 cdns_get_frame_shape(u16 rows, u16 cols) >>>> { >>>>      u16 c, r; >>>> >>>>      r = sdw_find_row_index(rows); >>>>      c = sdw_find_col_index(cols); >>>> >>>>      return sdw_frame_shape(c, r); >>>> } >>>> >>>> The above may even be simplified into one-liner. >>> >>> This is a function used once on startup, there is no real need to >>> simplify further. The separate variables help add debug traces as needed >>> and keep the code readable while showing how the values are encoded into >>> a register. >> >> Eh, I've thought it's gonna be exposed to userspace (via uapi) so it can be >> fetched by tests or tools. > > Uapi? I dont see anything in this or other series posted, did I miss > something? Also I am not sure I like the idea of exposing these to > userland! Vinod, that was never the intent, and Cezary agreed, see following line > >> >> In such case - if there is a single usage only - guess function is fine as >> is. >