From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42354C77B7C for ; Fri, 5 May 2023 20:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kf4pIVW/cUzKiciJynGNEgA8YtNou2LDOkoX2Frm0bI=; b=VTlqN4x/lKYASo LTrTti2iJZmGkN/T+kOhZBz4jYcfrbP/ORRf3dQeGDcwCCBtkKuw0S5TpIvaFE4afwOfxAoldg/ez T2JuNMm/owXchX2Ubb+p+Ykg+ZmuxOhTIi+IPCI84I00RGF8LBsDbcAoG0PiS8F3PPFQT/cCMmjLB DLftgnBaCWPsAmmszTHTNHFqgmhlOhwjmNkbUP1E/QWzXf9nXFpxVR1o2/GgE5MKOTCpZY/oX5zir sEsbO7eyrWmaiwphPCbxDXzc3AD6X9yTt+IKkFkSkCv22/f+El1tgHsIJEwCG4VIbbJZ59dBPHS3n iJlAoGQJ9VfdbSGjhQVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pv29J-00BkZS-1j; Fri, 05 May 2023 20:35:29 +0000 Received: from fgw20-7.mail.saunalahti.fi ([62.142.5.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pv29G-00BkYa-0f for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 20:35:28 +0000 Received: from localhost (88-113-26-95.elisa-laajakaista.fi [88.113.26.95]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id 5addbdeb-eb84-11ed-b3cf-005056bd6ce9; Fri, 05 May 2023 23:35:21 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Fri, 5 May 2023 23:35:21 +0300 To: Oleksii Moisieiev Cc: "sudeep.holla@arm.com" , Linus Walleij , Cristian Marussi , Peng Fan , Michal Simek , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-gpio@vger.kernel.org" Subject: Re: [RFC v2 2/3] pinctrl: Implementation of the generic scmi-pinctrl driver Message-ID: References: <812ae71d017b115c55648dbf0a4c3502715b1955.1682513390.git.oleksii_moisieiev@epam.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <812ae71d017b115c55648dbf0a4c3502715b1955.1682513390.git.oleksii_moisieiev@epam.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_133526_596238_E3EABD9F X-CRM114-Status: GOOD ( 21.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Wed, Apr 26, 2023 at 01:26:37PM +0000, Oleksii Moisieiev kirjoitti: > scmi-pinctrl driver implements pinctrl driver interface and using > SCMI protocol to redirect messages from pinctrl subsystem SDK to > SCP firmware, which does the changes in HW. > > This setup expects SCP firmware (or similar system, such as ATF) > to be installed on the platform, which implements pinctrl driver > for the specific platform. > > SCMI-Pinctrl driver should be configured from the device-tree and uses > generic device-tree mappings for the configuration. ... > +#include > +#include > +#include I do not see any user of this header. Do you? > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include Please, move these two to the upper group of the generic headers. > +struct scmi_pinctrl_funcs { > + unsigned int num_groups; > + const char **groups; > +}; Please, use struct pinfunction. ... > +struct scmi_pinctrl { > + struct scmi_pinctrl_funcs *functions; > + unsigned int nr_functions; > + char **groups; > + unsigned int nr_groups; I'm not sure what is the difference to what "functions" above represent. > +}; ... > +static void pinctrl_scmi_pin_dbg_show(struct pinctrl_dev *pctldev, > + struct seq_file *s, > + unsigned int offset) > +{ > + seq_puts(s, DRV_NAME); > +} What is the usefulness of this method? ... > +static int pinctrl_scmi_pinconf_group_get(struct pinctrl_dev *pctldev, > + unsigned int _pin, > + unsigned long *config) > +{ > + int ret; > + struct scmi_pinctrl *pmx; > + enum pin_config_param config_type; > + unsigned long config_value; > + > + if (!pctldev) > + return -EINVAL; > + > + pmx = pinctrl_dev_get_drvdata(pctldev); > + > + if (!pmx || !pmx->ph || !config) > + return -EINVAL; > + > + config_type = pinconf_to_config_param(*config); > + > + ret = pinctrl_ops->get_config(pmx->ph, _pin, GROUP_TYPE, > + config_type, (u32 *)&config_value); Endianess issue. This is, while likely working code, still ugly. > + if (ret) > + return ret; > + > + *config = pinconf_to_config_packed(config_type, config_value); > + > + return 0; > +} ... > + err: err_free. > + kfree(pmx->pins); > + pmx->nr_pins = 0; > + > + return ret; ... > +static const struct scmi_device_id scmi_id_table[] = { > + { SCMI_PROTOCOL_PINCTRL, "pinctrl" }, > + { }, No comma for the terminator entry. > +}; ... > + pinctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PINCTRL, > + &ph); Can be on one line. > + if (IS_ERR(pinctrl_ops)) > + return PTR_ERR(pinctrl_ops); ... > + if (pmx->nr_functions) { > + pmx->functions = > + devm_kcalloc(&sdev->dev, pmx->nr_functions, > + sizeof(*pmx->functions), > + GFP_KERNEL); > + if (!pmx->functions) { > + ret = -ENOMEM; > + goto clean; Interleaving devm_*() with non-devm_*() in such order is not a good idea. > + } > + } > + > + if (pmx->nr_groups) { > + pmx->groups = > + devm_kcalloc(&sdev->dev, pmx->nr_groups, > + sizeof(*pmx->groups), > + GFP_KERNEL); > + if (!pmx->groups) { > + ret = -ENOMEM; > + goto clean; > + } > + } > + > + return pinctrl_enable(pmx->pctldev); > + > +clean: err_free: > + if (pmx) { > + kfree(pmx->functions); > + kfree(pmx->groups); Ah, this is simply wrong. > + } > + > + kfree(pmx); -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel