Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2397388rdb; Mon, 11 Sep 2023 23:51:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHih86qApvS/J+GNOCBZ7DQ4xOy2VqSNg8t1NLwGgi0S5CyPxw3iNWytFQIYIMJIy5ZGGCc X-Received: by 2002:a17:902:ecc5:b0:1b9:ebe9:5f01 with SMTP id a5-20020a170902ecc500b001b9ebe95f01mr15235515plh.19.1694501482329; Mon, 11 Sep 2023 23:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694501482; cv=none; d=google.com; s=arc-20160816; b=OiYaxegGgkH6++M5HXf5mtjl9dG2TlvE1vmXv9SyJSWmcDIWICJy6CuBNh/7/t9tpn wwHPrzXnxSQ5EGWJNhSvGZgSOiWhPQPEaRP/I5PtxAPGy5DhlenocLCZSOOTnTXIOemA HgzCdK5knJivQjKT36Vt3OXQ2sJYF5FdfJdJatiOIs5aMtqjd+RzviT79x7IHPvWlvmi /m73Zu3qJbznlzv02zXJ+AlQQlbyspLpLnkQ7ljfiYbn42A8o5UVdGz6wLefPS2vlgPP J/gMYsCyy4vdxj4/gUqJXHggV1+owhP084oQG6P+PPmVa+hI4gpPxCZeF/QjvlGKw9jr YP4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=BW2ZvCb4ELH18UpR0Xph3fou+5wDtMncQBnhd0a43Co=; fh=HZ2fk3h/A3ZTAhRMhhiLZfS71YvlUKKA6i56ZnaV31k=; b=dFPkFnX0Q1u8Ok0gFohxu1xuZO9RoBSFtPkSOQTprSa0jU4tx6UL52GfOCOOQE21Bs AxVLzxFinsCiilMEm6aTV31zyiUWj9SiKpqSmNI5AMA11MEkcji20UkXHxG/OUjgVrAn xvdpN7NdvIFnEKk+xCCB4t9bhi/IS932vUm8Z1C0dTuFR/VA5PV+IyupOCETibCQ6ruC oCokaAd4RxmmeYa6R2475pCh3JjcF5kAcA1OoZMagnYUdXZhyrkxkeYrqLem7rjQD8Gn 78+FpXCe/MCSx1/1qVJ98bb54VTo37cZxSzBqC9sUyyCZxPpUCL+F54pje43yXAcFqB/ Atzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id la5-20020a170902fa0500b001bf5753e0ccsi7408686plb.119.2023.09.11.23.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 23:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 15ED780AFEAF; Mon, 11 Sep 2023 23:47:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbjILGrb (ORCPT + 99 others); Tue, 12 Sep 2023 02:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230041AbjILGra (ORCPT ); Tue, 12 Sep 2023 02:47:30 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CC90E75 for ; Mon, 11 Sep 2023 23:47:26 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qfxB3-0007Ur-9J; Tue, 12 Sep 2023 08:47:13 +0200 Received: from [2a0a:edc0:2:b01:1d::c0] (helo=ptx.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qfxB2-005ibv-6e; Tue, 12 Sep 2023 08:47:12 +0200 Received: from ore by ptx.whiteo.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qfxB1-005VFP-Ih; Tue, 12 Sep 2023 08:47:11 +0200 Date: Tue, 12 Sep 2023 08:47:11 +0200 From: Oleksij Rempel To: Christophe JAILLET Cc: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , Arun Ramadoss , Conor Dooley , Krzysztof Kozlowski , Rob Herring , devicetree@vger.kernel.org, netdev@vger.kernel.org, "Russell King (Oracle)" , linux-kernel@vger.kernel.org, kernel@pengutronix.de, UNGLinuxDriver@microchip.com Subject: Re: [PATCH net-next v4 2/2] net: dsa: microchip: Add drive strength configuration Message-ID: <20230912064711.GE780075@pengutronix.de> References: <20230912045459.1864085-1-o.rempel@pengutronix.de> <20230912045459.1864085-3-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org 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]); Mon, 11 Sep 2023 23:47:41 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=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 morse.vger.email On Tue, Sep 12, 2023 at 07:22:21AM +0200, Christophe JAILLET wrote: ... > > +static void ksz_drive_strength_error(struct ksz_device *dev, > > + const struct ksz_drive_strength *array, > > + size_t array_size, int milliamp) > > +{ > > + char supported_values[100]; > > + size_t remaining_size; > > + int added_len; > > + char *ptr; > > + int i; > > + > > + remaining_size = sizeof(supported_values); > > + ptr = supported_values; > > + > > + for (i = 0; i < array_size; i++) { > > + added_len = snprintf(ptr, remaining_size, > > + i == 0 ? "%d" : ", %d", array[i].milliamp); > > + > > + if (added_len < 0 || added_len >= remaining_size) > > Nit: snprintf() does not return negatives value. thx! will fix it ... > > +static int ksz_parse_drive_strength(struct ksz_device *dev) > > +{ > > + struct ksz_driver_strength_prop of_props[] = { > > + [KSZ_DRIVER_STRENGTH_HI] = { > > + .name = "microchip,hi-drive-strength-microamp", > > + .offset = SW_HI_SPEED_DRIVE_STRENGTH_S, > > + .value = -1 > > + }, > > + [KSZ_DRIVER_STRENGTH_LO] = { > > + .name = "microchip,lo-drive-strength-microamp", > > + .offset = SW_LO_SPEED_DRIVE_STRENGTH_S, > > + .value = -1 > > + }, > > + [KSZ_DRIVER_STRENGTH_IO] = { > > + .name = "microchip,io-drive-strength-microamp", > > + .offset = 0, /* don't care */ > > + .value = -1 > > + }, > > + }; > > + struct device_node *np = dev->dev->of_node; > > + bool found = false; > > + int i, ret; > > + > > + for (i = 0; i < ARRAY_SIZE(of_props); i++) { > > + ret = of_property_read_u32(np, of_props[i].name, > > + &of_props[i].value); > > + if (ret && ret != -EINVAL) > > + dev_warn(dev->dev, "Failed to read %s\n", > > + of_props[i].name); > > + if (ret) > > + continue; > > + > > + found = true; > > Nit: break? No, we may have more then one property. Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |