Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp215266lqe; Wed, 27 Mar 2024 03:50:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUKxLhPkzUXZV7QCRBI6eACDzlFdNYQyUnZs4SH6Hj2XEj0I0Ap4/zNSCdpWr0LKi8NILLKNOmmhWplTtsr2SZ0sN0TQWp/QnylbbJqFg== X-Google-Smtp-Source: AGHT+IG1SROff5VmCW0/vkNbt3sJ9i9gkX7ubhnDhgywxyuQAaR/ShaL3oiAev7nN0s3kM/krGsb X-Received: by 2002:a05:6870:96ac:b0:21e:e476:9170 with SMTP id o44-20020a05687096ac00b0021ee4769170mr6160960oaq.43.1711536608044; Wed, 27 Mar 2024 03:50:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711536608; cv=pass; d=google.com; s=arc-20160816; b=SGfb6NrW8pAfR1yeKx7VMm78sD/xuJ+EiLp+JFuGy1e6rjTozlnOiKpJMrXcKlD85b +2wpk0Ye7mG+IWUI6XracrObOsGlVexd8Dw/cWKTx+DxdN4wI9ieLA6jClXOwNeAYadq 2ssbrw3EJRtGzxWNSxm4yNUEiy1EAWi9AkbBNDb8+YnJwuaNjQWoGgKtKCk+pvNjUtrA 2R+S21u/f7HJLtgN/6fJ0FF8BN902MPAO2lS7C6Ktd3+ao0DUElOEJj75XWb+/K/9Lno CC7MEXDt+RVJVXWlq6fZK2VTGl/8+tJfksafMtdc4B9y5BV+1CqCou/L2Fv3G6h84l0O vrew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7bMAFuTzgkVK2W2ZWS18PceZ7VDbzSyIzk2OmuZlF/o=; fh=tl3/bPQ0QyUJd7XvoNPv8slu82zWiMPbfijbl3oJIV0=; b=pOLMLOWd6pd1bwSNTt1rhaCYEgiB3dkUgYZ+yySRgBSZ7qI2LPHO4TTU/1hkEnS5+Y L06yqS5g38TOkibEOESjADxmOpVYgSgDkWkAafS8PXRohOVp+RBkz5TjnWBPjsfvlXS+ aC58VCv67IJNvEisqQOxRXJold7vqmdxXhIND5tkIuveCv7nxZVOtuakKIgpl2WcS44E FSw7IXFO5G1y6M+tNmxyimTSc9WfA5JMIFE+DBltz/1kmPF/mN5nH/PksroyzoDAL1/8 p6dXHBk9NWey/zj1WCOHUsA9EZ8eM8JO7B7JudpCePsmE9BtQfjIkhAfTSGEad8nw9GF waxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lIYUd44L; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-120691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 6-20020a631546000000b005dc788f3767si11814743pgv.620.2024.03.27.03.50.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lIYUd44L; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-120691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0AB99B253A7 for ; Wed, 27 Mar 2024 10:46:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48C504F5F8; Wed, 27 Mar 2024 10:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lIYUd44L" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAF1E1D53C for ; Wed, 27 Mar 2024 10:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711536379; cv=none; b=XRoCwMyknqXsS24Urs5zJB0blIF9LVUDnOpQBAp8H6hTWRScI8z6sG24zqREylnExnxqilJx3hSfA8jtR9tLpHTb7GGldyB5MQFKlfZ1W1T6lF4K/NHJxOivUFKGxTo+xtX08mcREK7rsS4jJKFCfIo7Xp6dsW/rqlBX2T0fifo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711536379; c=relaxed/simple; bh=4qNhZd6In4W6BpD2cTnvRVSY7sZSE1eUcfTuvPhG4us=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pLlR4BXtVVwL1XKhRtBIh8Udbc3fkoaGRtnbEVL2rpVnm5N536NO95RzlylW1CJrVBCI0X/wc8XHKFZcOmhk1EEvPcNUwsdEuTAwwlE1ZARvOgLlzXSFlL9++ECHFyM1TYl2iWWyxxGv3X3RlV4Fa9JOtoYubNwrZaPmYIyBtPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=lIYUd44L; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a4751063318so440319166b.0 for ; Wed, 27 Mar 2024 03:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711536376; x=1712141176; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7bMAFuTzgkVK2W2ZWS18PceZ7VDbzSyIzk2OmuZlF/o=; b=lIYUd44L7tpV6w2WQj0VJu5eNTxXDSby2RebM/7tvaxpEipdXAO8TJqU+Qs6qHGpR4 nHHbj0yYmWHtSEh8ed6ZDeSa/NivDDhLCDvUkCRWj40WLGjtWS6WP643tTnQaZ/q1ge2 x3hsvWlDIRLi9p8vP4Jb29RUZK0YY5l8oEyT4Bwhyub9v9PBj8XKFCGeg/jH7XsYtZHE Xe961vDu+L9a+Yad/CJUwEtvtm+XebwWdl72AzV4BOFdwo6/1jdM8QwK0jkZSeylsuN3 PEGYkjIlVxKCQfRW4smy/dqT+bfGzHVTU0dRFOwCktlP6H0R+vH6iwDHVDoHaB2xS7lJ MmhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711536376; x=1712141176; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7bMAFuTzgkVK2W2ZWS18PceZ7VDbzSyIzk2OmuZlF/o=; b=BdpqbfYOSHG5z9I0fsOERXMQUSuRU/byTRBDr8Cz/L5sUhB/jiklD7ITR3kL1etPki xzkazkQsq9XG0PPv2jhS1yoWIQjOqUiYUzzJsN8DRqKdxmP6b9kTT7bhvh2vmu0lFDiH ZhSuxMtp6giPrHEPQWnBS0C5ky9JYkJQ8o/l8MOUcTW2P7/ycEnao8/8TZ7Rt8mFaAxc OXetTBiMn7s/4gMKf0g/AWko1m9K+osecf7VrPcpmghw2qcqRsMi3gIb1GxcDUiH+4CI P5RdOS8vRV0P2UVcVDLiWed1UQ07Wd9x2Cf7yzd4IsgpREHpAGnQntQGBuf0sNlU/GGm j3YA== X-Forwarded-Encrypted: i=1; AJvYcCXTV1nhUSvlNm82UtHw2AD7z/3cBSHgjxR+mwHpr2NrQQLsbIDYkxJrbX6ggVP533g/bNraHk/zu2LCEh3Y7a3IfKlD/IOxtGokauqe X-Gm-Message-State: AOJu0Yzk9BaYe/rrCAeEEHpgGIE0swSRmjy/LVoYH9NMFo7OlXwcmZFd X5Pbx5U/aiM+D/1sxK4Ym5Ch2r9pgnzr+wPHy4HhsvQN1whNEEPGdLrTGJQSaAM= X-Received: by 2002:a17:906:f594:b0:a4e:9d3:cc8b with SMTP id cm20-20020a170906f59400b00a4e09d3cc8bmr698757ejd.40.1711536375884; Wed, 27 Mar 2024 03:46:15 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id o9-20020a170906774900b00a46a2ac0dbasm5268238ejn.197.2024.03.27.03.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:46:15 -0700 (PDT) Date: Wed, 27 Mar 2024 13:46:11 +0300 From: Dan Carpenter To: "Peng Fan (OSS)" Cc: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Peng Fan , Oleksii Moisieiev Subject: Re: [PATCH v6 3/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Message-ID: <4879ad5d-165c-4118-81f7-8f6348a5a5d4@moroto.mountain> References: <20240323-pinctrl-scmi-v6-0-a895243257c0@nxp.com> <20240323-pinctrl-scmi-v6-3-a895243257c0@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240323-pinctrl-scmi-v6-3-a895243257c0@nxp.com> Looks really nice. Just a few small comments below. On Sat, Mar 23, 2024 at 08:15:16PM +0800, Peng Fan (OSS) wrote: > + > +struct scmi_msg_func_set { > + __le32 identifier; > + __le32 function_id; > + __le32 flags; > +}; This scmi_msg_func_set struct is unused. Delete. > +static void > +iter_pinctrl_settings_get_prepare_message(void *message, u32 desc_index, > + const void *priv) > +{ > + struct scmi_msg_settings_get *msg = message; > + const struct scmi_settings_get_ipriv *p = priv; > + u32 attributes; > + > + attributes = FIELD_PREP(CONFIG_FLAG_MASK, p->flag) | > + FIELD_PREP(SELECTOR_MASK, p->type); > + > + if (p->flag == 1) > + attributes |= FIELD_PREP(SKIP_CONFIGS_MASK, desc_index); > + else if (!p->flag) This is a nit-pick but could you change these !p->flag conditions to p->flag == 0? It's a number zero, not a bool. > + attributes |= FIELD_PREP(CONFIG_TYPE_MASK, p->config_types[0]); > + > + msg->attributes = cpu_to_le32(attributes); > + msg->identifier = cpu_to_le32(p->selector); > +} > + > +static int > +iter_pinctrl_settings_get_update_state(struct scmi_iterator_state *st, > + const void *response, void *priv) > +{ > + const struct scmi_resp_settings_get *r = response; > + struct scmi_settings_get_ipriv *p = priv; > + > + if (p->flag == 1) { > + st->num_returned = le32_get_bits(r->num_configs, GENMASK(7, 0)); > + st->num_remaining = le32_get_bits(r->num_configs, > + GENMASK(31, 24)); > + } else { > + st->num_returned = 1; > + st->num_remaining = 0; > + } > + > + return 0; > +} > + > +static int > +iter_pinctrl_settings_get_process_response(const struct scmi_protocol_handle *ph, > + const void *response, > + struct scmi_iterator_state *st, > + void *priv) > +{ > + const struct scmi_resp_settings_get *r = response; > + struct scmi_settings_get_ipriv *p = priv; > + > + if (!p->flag) { if (p->flag == 0) { > + if (p->config_types[0] != > + le32_get_bits(r->configs[st->loop_idx * 2], GENMASK(7, 0))) > + return -EINVAL; > + } else if (p->flag == 1) { > + p->config_types[st->desc_index + st->loop_idx] = > + le32_get_bits(r->configs[st->loop_idx * 2], > + GENMASK(7, 0)); > + } else if (p->flag == 2) { > + return 0; > + } > + > + p->config_values[st->desc_index + st->loop_idx] = > + le32_to_cpu(r->configs[st->loop_idx * 2 + 1]); > + > + return 0; > +} > + > +static int > +scmi_pinctrl_settings_get(const struct scmi_protocol_handle *ph, u32 selector, > + enum scmi_pinctrl_selector_type type, > + enum scmi_pinctrl_conf_type config_type, > + u32 *config_value) > +{ > + int ret; > + void *iter; > + struct scmi_iterator_ops ops = { > + .prepare_message = iter_pinctrl_settings_get_prepare_message, > + .update_state = iter_pinctrl_settings_get_update_state, > + .process_response = iter_pinctrl_settings_get_process_response, > + }; > + struct scmi_settings_get_ipriv ipriv = { > + .selector = selector, > + .type = type, > + .flag = 0, ->flag should be 0-2. > + .config_types = &config_type, > + .config_values = config_value, > + }; > + > + if (!config_value || type == FUNCTION_TYPE) ^^^^^^^^^^^^ config_value should be optional for flag == 2. regards, dan carpenter > + return -EINVAL; > + > + ret = scmi_pinctrl_validate_id(ph, selector, type); > + if (ret) > + return ret; > + > + iter = ph->hops->iter_response_init(ph, &ops, 1, PINCTRL_SETTINGS_GET, > + sizeof(struct scmi_msg_settings_get), > + &ipriv); > + > + if (IS_ERR(iter)) > + return PTR_ERR(iter); > + > + return ph->hops->iter_response_run(iter); > +} > +