Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1266677rdh; Fri, 24 Nov 2023 08:31:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9kGqK6jqaCvbPQzZqcpd3De1YZ7O7KB4L+tSJZUwdHLN1DeC0AiWAXjizSLDQ4+FrttqI X-Received: by 2002:a05:6830:12c5:b0:6d6:4720:fd29 with SMTP id a5-20020a05683012c500b006d64720fd29mr3554380otq.3.1700843480896; Fri, 24 Nov 2023 08:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700843480; cv=none; d=google.com; s=arc-20160816; b=BgAbqG4ZxITNKg+zzhEKF3m4EFccXXAUMOp/y4QfZLLr3RGhgfnXwDLoZZllMToUxx bcaQKZqPBmApCOA6I9gQzhv19KCavCx/LGmkowTyTwcWu3GBn2mxAa9r3aAkv/2uKU85 n79xsvPBYnu0JNeWtqjabyLTzFngQ6nUR6J9RQXIhSfoPkPrUSDAkwfBmdTBrY2wDHX0 WgEMDLHblq+7txbctqY7lIItrnp7OlnBwlYCToZ4nzZVMF8Z/7qKbT2K7qcR8HwJONKi n/6Hsw+PxlEBfi6O4sDc13y2XtlR6iL87jV6rJSgMudwaYo6yCDBi88Tg4PmLBFIaOTA rrzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hkhHI7akSytfsrBzcAx3Dlb/veTfDjFKGxEq8b6MC04=; fh=dBSj1Anongxm3AqEVsAoqej2eyguUa3eeydsriREnjo=; b=XzUv1HHQztOzl9+W9KFhYoQp1SA7twoiwo1pVcXz88CHIG2aX2OX7GKYlEp+ZIw//x VQQxSB+quqMDyG6uZY2QT/icicu8Ncb4+ojI0x3/Erlt+05GltE1FmBdph5c6b+9HDrm omcaEQFh6q5GZ72tlXjViGOUiU46oi1whRHZDq3LgDDyLRs49DSHqPWCpRMcdGqbpxNJ lcb3HxkjTMAbCToyZRn3G7gprympy8Se9KgIj9K3giq0GAzIWLAQ/a2wKoMpqwxU/qGg ZFq0hpoqQiAwttazcONKHF+jZZOU6fOdQS55rOuiSE8v+4IQGO4nNv5O4Z7f+tnMWNoJ IlzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qpW2GhNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k19-20020a9d7dd3000000b006d6569c41d2si1562408otn.97.2023.11.24.08.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:31:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qpW2GhNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6DFD680B02B9; Fri, 24 Nov 2023 08:31:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbjKXQa5 (ORCPT + 99 others); Fri, 24 Nov 2023 11:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbjKXQaz (ORCPT ); Fri, 24 Nov 2023 11:30:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C15019A3 for ; Fri, 24 Nov 2023 08:31:01 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DCD0C433C7; Fri, 24 Nov 2023 16:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700843460; bh=0m2/cMBcTydjmRWM2kg9Xg3sXuhlmH0zFa0ospNDRBM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qpW2GhNg4EblHnxfauyUbT06NCJY/KQePisvrxpj3Bb0hqiZ9OQAqj2ZX10vIPnm/ 7fV725jNxjWCkDAK8WFoBG2ZCuoLURtPDbWYV97BoU1PL61sGBZ/Npasvffl+In+Bo 53GGEWDwJjZVJFpoiPVZv99XLTZtb9VXFJATxD5/+ufBGwCkrH8PJOnUYqsXWHvwEQ aOjF8HzHhMyBjUAosqaZ+rK96Mif55NMadoGV/ppGVZfcd/VN/XVDEMQdulju5PSGu 9/Mmq2SqYGQpY1LOEM4kFJaw1p6TBIUSEgQv7RpwNNv1Vkw1BzUGU5D362A/BvomHp 7v/HdYqIjRx3Q== Date: Fri, 24 Nov 2023 16:30:54 +0000 From: Simon Horman To: Kory Maincent Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH net-next 9/9] net: pse-pd: Add PD692x0 PSE controller driver Message-ID: <20231124163054.GQ50352@kernel.org> References: <20231116-feature_poe-v1-0-be48044bf249@bootlin.com> <20231116-feature_poe-v1-9-be48044bf249@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231116-feature_poe-v1-9-be48044bf249@bootlin.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 24 Nov 2023 08:31:18 -0800 (PST) On Thu, Nov 16, 2023 at 03:01:41PM +0100, Kory Maincent wrote: > Add a new driver for the PD692x0 I2C Power Sourcing Equipment controller. > This driver only support i2c communication for now. > > Signed-off-by: Kory Maincent Hi Kory, some minor feedback from my side. ... > diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c ... > +static int > +pd692x0_get_of_matrix(struct device *dev, > + struct matrix port_matrix[PD692X0_MAX_LOGICAL_PORTS]) > +{ > + int ret, i, ports_matrix_size; > + u32 val[PD692X0_MAX_LOGICAL_PORTS * 3]; nit: reverse xmas tree please. ... > +static int pd692x0_fw_write_line(const struct i2c_client *client, > + const char line[PD692X0_FW_LINE_MAX_SZ], > + const bool last_line) > +{ > + int ret; > + > + while (*line != 0) { > + ret = i2c_master_send(client, line, 1); > + if (ret < 0) > + return FW_UPLOAD_ERR_RW_ERROR; > + line++; > + } > + > + if (last_line) { > + ret = pd692x0_fw_recv_resp(client, 100, "TP\r\n", > + sizeof("TP\r\n") - 1); > + if (ret) > + return ret; > + } else { > + ret = pd692x0_fw_recv_resp(client, 100, "T*\r\n", > + sizeof("T*\r\n") - 1); > + if (ret) > + return ret; > + } > + > + return FW_UPLOAD_ERR_NONE; > +} ... > +static enum fw_upload_err pd692x0_fw_write(struct fw_upload *fwl, > + const u8 *data, u32 offset, > + u32 size, u32 *written) > +{ > + struct pd692x0_priv *priv = fwl->dd_handle; > + char line[PD692X0_FW_LINE_MAX_SZ]; > + const struct i2c_client *client; > + int ret, i; > + char cmd; > + > + client = priv->client; > + priv->fw_state = PD692X0_FW_WRITE; > + > + /* Erase */ > + cmd = 'E'; > + ret = i2c_master_send(client, &cmd, 1); > + if (ret < 0) { > + dev_err(&client->dev, > + "Failed to boot programming mode (%pe)\n", > + ERR_PTR(ret)); > + return FW_UPLOAD_ERR_RW_ERROR; > + } > + > + ret = pd692x0_fw_recv_resp(client, 100, "TOE\r\n", sizeof("TOE\r\n") - 1); > + if (ret) > + return ret; > + > + ret = pd692x0_fw_recv_resp(client, 5000, "TE\r\n", sizeof("TE\r\n") - 1); > + if (ret) > + dev_warn(&client->dev, > + "Failed to erase internal memory, however still try to write Firmware\n"); > + > + ret = pd692x0_fw_recv_resp(client, 100, "TPE\r\n", sizeof("TPE\r\n") - 1); > + if (ret) > + dev_warn(&client->dev, > + "Failed to erase internal memory, however still try to write Firmware\n"); > + > + if (priv->cancel_request) > + return FW_UPLOAD_ERR_CANCELED; > + > + /* Program */ > + cmd = 'P'; > + ret = i2c_master_send(client, &cmd, sizeof(char)); > + if (ret < 0) { > + dev_err(&client->dev, > + "Failed to boot programming mode (%pe)\n", > + ERR_PTR(ret)); > + return ret; > + } > + > + ret = pd692x0_fw_recv_resp(client, 100, "TOP\r\n", sizeof("TOP\r\n") - 1); > + if (ret) > + return ret; > + > + i = 0; > + while (i < size) { > + ret = pd692x0_fw_get_next_line(data, line, size - i); > + if (!ret) { > + ret = FW_UPLOAD_ERR_FW_INVALID; > + goto err; > + } > + > + i += ret; > + data += ret; > + if (line[0] == 'S' && line[1] == '0') { > + continue; > + } else if (line[0] == 'S' && line[1] == '7') { > + ret = pd692x0_fw_write_line(client, line, true); > + if (ret) > + goto err; > + } else { > + ret = pd692x0_fw_write_line(client, line, false); > + if (ret) > + goto err; > + } > + > + if (priv->cancel_request) { > + ret = FW_UPLOAD_ERR_CANCELED; > + goto err; > + } > + } > + *written = i; > + > + msleep(400); > + > + return FW_UPLOAD_ERR_NONE; > + > +err: > + pd692x0_fw_write_line(client, "S7\r\n", true); gcc-13 (W=1) seems a bit upset about this. drivers/net/pse-pd/pd692x0.c: In function 'pd692x0_fw_write': drivers/net/pse-pd/pd692x0.c:861:9: warning: 'pd692x0_fw_write_line' reading 128 bytes from a region of size 5 [-Wstringop-overread] 861 | pd692x0_fw_write_line(client, "S7\r\n", true); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/pse-pd/pd692x0.c:861:9: note: referencing argument 2 of type 'const char[128]' drivers/net/pse-pd/pd692x0.c:642:12: note: in a call to function 'pd692x0_fw_write_line' 642 | static int pd692x0_fw_write_line(const struct i2c_client *client, | ^~~~~~~~~~~~~~~~~~~~~ > + return ret; > +} ...