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 9B2A6C6FD1F for ; Fri, 29 Mar 2024 19:10:44 +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=Dy5JP5+n0xj9OGqN0jxZRiH8+y96BEfGXVnxDdQozo4=; b=IH6kPxeeUCcLtS I1zr0ycK234h09EYlVTMzNt6LOOhbuYAPRZJl15AnPDJ8JIw/d24LOsqoUp17YhibKkquQd2/fJ67 S6DDDMoi7cW7Diz2gYkmG+jxaZwNqBykeTMYEJKi2eCcwKEcIWcmOKusBNdkrHiQCRx6OhCfzQzjQ CG+bcBDXATRNBJzW4BJDPQOZWnK/TTiFxHd2WiEQBk0weR/nv+6mLwPmghcX8E/t4Jp1NeasscwkU r4uhICZE0enFpBayWF0b0sON/PXReFd93TBxNV2zuQvZRPdLD9pZJmHLt/8QaAPAGKbAyypGBXD0z R7LRFlLpGTFeNFe8U2fA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rqHcW-00000001iZ8-1lsu; Fri, 29 Mar 2024 19:10:32 +0000 Received: from fgw21-7.mail.saunalahti.fi ([62.142.5.82]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rqHcS-00000001iYI-1Vwx for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 19:10:30 +0000 Received: from localhost (88-113-26-217.elisa-laajakaista.fi [88.113.26.217]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id ff602b77-edff-11ee-abf4-005056bdd08f; Fri, 29 Mar 2024 21:10:25 +0200 (EET) From: Andy Shevchenko Date: Fri, 29 Mar 2024 21:10:25 +0200 To: "Peng Fan (OSS)" Cc: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Dan Carpenter , 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 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Message-ID: References: <20240323-pinctrl-scmi-v6-0-a895243257c0@nxp.com> <20240323-pinctrl-scmi-v6-4-a895243257c0@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240323-pinctrl-scmi-v6-4-a895243257c0@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_121028_592457_8A543614 X-CRM114-Status: GOOD ( 15.96 ) 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 Sat, Mar 23, 2024 at 08:15:17PM +0800, Peng Fan (OSS) kirjoitti: > From: Peng Fan > > scmi-pinctrl driver implements pinctrl driver interface and using > SCMI protocol to redirect messages from pinctrl subsystem SDK to > SCMI platform firmware, which does the changes in HW. ... > +#include > +#include > +#include > +#include > +#include > +#include Use IWYU principle. There are missing header inclusions and/or forward declarations. ... > +struct scmi_pinctrl_funcs { > + unsigned int num_groups; > + const char **groups; > +}; This is repeating struct pinfunction. Why can't the latter be used? ... > +err_free: > + devm_kfree(pmx->dev, groups); Why?! This is 99.9% that the initial allocation must not be devm. ... > + *p_config_value = kcalloc(num_configs, sizeof(u32), GFP_KERNEL); sizeof(**p_config_value)? > + *p_config_type = kcalloc(num_configs, > + sizeof(enum scmi_pinctrl_conf_type), sizeof(**p_config_type)? > + GFP_KERNEL); > + > + if (!*p_config_value || !*p_config_type) { > + kfree(*p_config_value); > + kfree(*p_config_type); > + return -ENOMEM; Why to allocate / free memory in the case when you know that the first one failed? > + } ... > +static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx, > + struct pinctrl_desc *desc) > +{ > + struct pinctrl_pin_desc *pins; > + unsigned int npins; > + int ret, i; > + > + npins = pinctrl_ops->count_get(pmx->ph, PIN_TYPE); > + pins = devm_kmalloc_array(pmx->dev, npins, sizeof(*pins), GFP_KERNEL); > + if (!pins) > + return -ENOMEM; > + > + for (i = 0; i < npins; i++) { > + pins[i].number = i; > + ret = pinctrl_ops->name_get(pmx->ph, i, PIN_TYPE, &pins[i].name); > + if (ret) > + return dev_err_probe(pmx->dev, ret, > + "Can't get name for pin %d", i); > + } > + > + desc->npins = npins; > + desc->pins = pins; > + dev_dbg(pmx->dev, "got pins %d", npins); %u > + return 0; > +} ... > + pinctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PINCTRL, > + &ph); One line. > + if (IS_ERR(pinctrl_ops)) > + return PTR_ERR(pinctrl_ops); -- 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