Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2354105rdb; Sun, 3 Dec 2023 13:17:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IErTkBue023z7J0RWx+VDomDt7iJb740uLqi2Eeik4JXwEwnEjouF8xZnBaX+haVmtOkiBf X-Received: by 2002:a92:90f:0:b0:35d:57de:1e42 with SMTP id y15-20020a92090f000000b0035d57de1e42mr4131419ilg.6.1701638233111; Sun, 03 Dec 2023 13:17:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701638233; cv=none; d=google.com; s=arc-20160816; b=ZvD2cgWDSUkLpfbRnzgyztb6q5ak2EVrCwtuxNm1bmDv5Ft9KVUO5Au+VL5RILyR7y pS2lRZ4HygmEzWHNQOBFYuaTmC5UfE1jlLRzgmon/s9Ia6X+FVeswt3k+WmX2l8h7Uj+ eJBsMP1gwqjJHsbvhG0nCN7FiXxAYm/AVLysFSGtY0dlQ0Sf9qHX4PGYgrqe/ElbrKo1 jpHF7mJmk+l7jotus12/PoKgzC4sZldaOnMHI07ZxmwuNJDL/mvDqZMLg1oKTQmeoxbW AmBRS49OCf7n9yIakDo/BGAZQt7nQ/a12TPOs3HdAtgVfR2j1ywED9xxNXBc+J+xIg3P 0gJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=/iWSzUSCtFxSRa7nJPgd9T8NZlrqaIvJ6JJK7oUVfkU=; fh=dPl5WM8XW8g1Kvfeedn6YF6gTA9Jjfk9V7VVaNMBRew=; b=oCUAJvk9zOJFPpqjk4Q506Vr6YuexYwYhEA+9V4TDP55uFozRn+hnyVPcLHNR+TgPN FKBTNOykuzfELC42Z7K3nVo6nGtdJ3+BmDWb3durR2E+faKQVnhF4Zu9D5CulY2+SRyw 4xWXVxGJ854RRsbUvixQlVkgb279hWC42henqstm08VXnIG2wE+3IDbmIpncV/uKeUCs A0XA85Hzr7YUrHizFiFPckSS3bTi9ddvDee506+1iN8yY/OZ9hMzm2ueT9+Zlv9IbaLi MUKspDpPptsR//VrDKesF+c66kZ2C4M7E6ilOhS4TPk+QLSW2EtfLVFFc8hxkcxf3ej5 GCbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=lNeuh7iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x18-20020a170902ec9200b001ce5b9c6181si3210844plg.549.2023.12.03.13.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 13:17:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=lNeuh7iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5C0D7808A361; Sun, 3 Dec 2023 13:17:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233912AbjLCVLy (ORCPT + 99 others); Sun, 3 Dec 2023 16:11:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCVLw (ORCPT ); Sun, 3 Dec 2023 16:11:52 -0500 Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5AC7D0 for ; Sun, 3 Dec 2023 13:11:55 -0800 (PST) Received: from [192.168.1.18] ([92.140.202.140]) by smtp.orange.fr with ESMTPA id 9tkhrjQzbnYhw9tkhrWksH; Sun, 03 Dec 2023 22:11:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1701637913; bh=/iWSzUSCtFxSRa7nJPgd9T8NZlrqaIvJ6JJK7oUVfkU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=lNeuh7iw0dmLd7K5RcK/cw56GO34h3LHTskBM0f9tZZQQAx7Av1Z3uQFkqwpmbHsv ypXPbhrtsL5+vQMNPwbP+ckmaGZioLgfr9l2wIpMw6S+JRyytKA5+/YpijhJHnxHxf 08GD5f04SFs2kw12PjEc1BiU4IGkB9x+RVYu6X5hF3UyzNoZPX03B01rtFy6G3LA0l Gv1ytpLjnipBqwaO4IEl0/6VlQ6TRtDFAfsMlkGgcvZpXtIxG3E5mtzr+PipsrEPBV IgDH0dws3sqVBqjsRQM9aTxwb5bDhtzEthUKjTJ3sJq6Ywq4ROKvs4dDC/ep7/QTHg IXhysDhb5Q1hQ== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 03 Dec 2023 22:11:53 +0100 X-ME-IP: 92.140.202.140 Message-ID: <6eeead27-e1b1-48e4-8a3b-857e1c33496b@wanadoo.fr> Date: Sun, 3 Dec 2023 22:11:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2 8/8] net: pse-pd: Add PD692x0 PSE controller driver Content-Language: fr To: Kory Maincent , "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 , Oleksij Rempel Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, Dent Project References: <20231201-feature_poe-v2-0-56d8cac607fa@bootlin.com> <20231201-feature_poe-v2-8-56d8cac607fa@bootlin.com> From: Christophe JAILLET In-Reply-To: <20231201-feature_poe-v2-8-56d8cac607fa@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 fry.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 (fry.vger.email [0.0.0.0]); Sun, 03 Dec 2023 13:17:10 -0800 (PST) Le 01/12/2023 à 18:10, Kory Maincent a écrit : > Add a new driver for the PD692x0 I2C Power Sourcing Equipment controller. > This driver only support i2c communication for now. > > Sponsored-by: Dent Project > Signed-off-by: Kory Maincent > --- > > This driver is based on the patch merged in an immutable branch from Jakub > repo. It is Tagged at: > git://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git firmware_loader-add-upload-error > > Change in v2: > - Drop of_match_ptr > - Follow the "c33" PoE prefix naming change. > - Remove unused delay_recv variable. Then, remove struct pd692x0_msg_content > which is similar to struct pd692x0_msg. > - Fix a weird sleep loop. > - Improve pd692x0_recv_msg for better readability. > - Fix a warning reported by Simon on a pd692x0_fw_write_line call. > --- ... > +static int pd692x0_fw_get_next_line(const u8 *data, > + char *line, size_t size) > +{ > + size_t line_size; > + int i; > + > + line_size = min_t(size_t, size, (size_t)PD692X0_FW_LINE_MAX_SZ); Nit: useless size_t cast > + > + memset(line, 0, PD692X0_FW_LINE_MAX_SZ); > + for (i = 0; i < line_size - 1; i++) { > + if (*data == '\r' && *(data + 1) == '\n') { > + line[i] = '\r'; > + line[i + 1] = '\n'; > + return i + 2; > + } > + line[i] = *data; > + data++; > + } > + > + return 0; > +} ... > +static int pd692x0_i2c_probe(struct i2c_client *client) > +{ > + struct device *dev = &client->dev; > + struct pd692x0_msg buf = {0}; > + struct pd692x0_msg_ver ver; > + struct pd692x0_priv *priv; > + struct fw_upload *fwl; > + int ret; > + > + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { > + dev_err(dev, "i2c check functionality failed\n"); > + return -ENXIO; > + } > + > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + priv->client = client; > + i2c_set_clientdata(client, priv); > + > + priv->pcdev.owner = THIS_MODULE; > + priv->pcdev.ops = &pd692x0_ops; > + priv->pcdev.dev = dev; > + priv->pcdev.types = PSE_C33; > + priv->pcdev.of_pse_n_cells = 1; > + priv->pcdev.nr_lines = PD692X0_MAX_LOGICAL_PORTS; > + ret = devm_pse_controller_register(dev, &priv->pcdev); > + if (ret) { > + return dev_err_probe(dev, ret, > + "failed to register PSE controller\n"); > + } Nit: un-needed {} > + > + fwl = firmware_upload_register(THIS_MODULE, dev, dev_name(dev), > + &pd692x0_fw_ops, priv); > + if (IS_ERR(fwl)) { > + dev_err(dev, "Failed to register to the Firmware Upload API\n"); > + ret = PTR_ERR(fwl); > + return ret; Nit: return dev_err_probe()? > + } > + priv->fwl = fwl; > + > + ret = i2c_master_recv(client, (u8 *)&buf, sizeof(buf)); > + if (ret != sizeof(buf)) { > + dev_err(dev, "Failed to get device status\n"); > + ret = -EIO; > + goto err_fw_unregister; > + } > + > + if (buf.key != 0x03 || buf.echo != 0xff || buf.sub[0] & 0x01) { > + dev_err(dev, "PSE controller error\n"); > + ret = -EIO; > + goto err_fw_unregister; > + } > + > + if (buf.sub[0] & 0x02) { > + dev_err(dev, "PSE firmware error. Please update it.\n"); > + priv->fw_state = PD692X0_FW_BROKEN; > + return 0; > + } > + > + ver = pd692x0_get_sw_version(priv); > + dev_info(&client->dev, "Software version %d.%02d.%d.%d\n", ver.prod, > + ver.maj_sw_ver, ver.min_sw_ver, ver.pa_sw_ver); > + > + if (ver.maj_sw_ver != PD692X0_FW_MAJ_VER) { > + dev_err(dev, "Too old firmware version. Please update it\n"); > + priv->fw_state = PD692X0_FW_NEED_UPDATE; > + return 0; > + } > + > + ret = pd692x0_update_matrix(priv); > + if (ret < 0) { > + dev_err(dev, "Error configuring ports matrix (%pe)\n", > + ERR_PTR(ret)); > + goto err_fw_unregister; > + } > + > + priv->fw_state = PD692X0_FW_OK; > + return 0; > + > +err_fw_unregister: > + firmware_upload_unregister(priv->fwl); > + return ret; > +} ...