Message ID | 20231214154906.29436-4-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-202-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8897222dys; Thu, 14 Dec 2023 14:40:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfKHX0OPKEm3bMTYOP7EcvrN21N//8frQD2LOD5O25jtOzsFv1sUNU/ZENjyC2TQ5XpI6Y X-Received: by 2002:ac8:5994:0:b0:423:7614:fbe8 with SMTP id e20-20020ac85994000000b004237614fbe8mr15950534qte.2.1702593623533; Thu, 14 Dec 2023 14:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702593623; cv=none; d=google.com; s=arc-20160816; b=Ov5X6vF/eYaGKrxGe3Av05nOesZh/5lOIKMcdnHLC8Z9gCJ/0JdXC3rX0187sZOQiV V9xS1uWh8w2SEjSglk8b3+v+7n/n2caNZ6vX5aWpL23XcWmxbHOHS4B7H1nf9M15ugt0 lo5GAEMoZ6qL4Cwqesinj/BtNHx2UC1LhZ9aGdApdZl3rxzE3YNNMRlfl+cLvLTmhWlj dYz2kFSZYUdF52QlioOfAlr9LO1SLrtpb4sUbg/6tFM2VJpek84ehdrOx6CM5EPEFris rK+IzVD4ckrWeMS400nca6YMJ+f87nKYEIF6RZME3oQ2QDElDOdS5ZEN5vxWdHvIppR8 LdCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tI12aCWJQCHdnL9tpy1TZqFUoLiTbzcedlrkIrXRyzo=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=u9QhZ+kt6AupYCt7EVD3CrTG0LMIXKHlE1XbAl49WR4Bd56nhZioVQy9Zn5KC224mR AK8gySGBt9xZK4r2WDFRCGeM+cMwFBhEJkMJAOwGiB8h1cIteW5JF91fg3eqf5rRnlBm nxCszc2jfX2egGGS+8Ef1dz1cR67J1Pdq0631//dwQL5EV/LvJo6nNqZ1rlV52Tri25A ZZ41TrbnU1i7Y7xlXeCLMmMzn12lqHRKEL/HdP9psVJJsWMEW2YJ8hE5Uhk3s+2SDpYM xRpD1v1RDaBAs6r5QhyD6nhpOAlyWEdCIGbzIE6LaBI6VmyJh6M9f2y6Gvs2IS/c1hJu 8qSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gaM6CsDX; spf=pass (google.com: domain of linux-kernel+bounces-202-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ew14-20020a05622a514e00b00423a25dd052si16644592qtb.87.2023.12.14.14.40.23 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 14:40:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gaM6CsDX; spf=pass (google.com: domain of linux-kernel+bounces-202-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 556681C21E0C for <ouuuleilei@gmail.com>; Thu, 14 Dec 2023 22:40:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6B976EB59; Thu, 14 Dec 2023 22:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gaM6CsDX" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08DDE6A34D; Thu, 14 Dec 2023 22:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-40c38de1ee4so720065e9.0; Thu, 14 Dec 2023 14:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702593516; x=1703198316; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tI12aCWJQCHdnL9tpy1TZqFUoLiTbzcedlrkIrXRyzo=; b=gaM6CsDXN9QTmZ+6tuMHtvQBtsZyL+6jo0kQtDGBFUdLQsHYspNnvIucVWR2cYaX9q 9BMSfEKtMMhg+cBnjZBzJ/vnLiiaXoIEYOGLQVYqFo0FcWbZphwQlvnih5TjuoYFf/ZF suyMFPhZHnTwYxft20sAb2hSkEebwkhHEKW0lBdKFcoVPyw/CSCdAzwoS64KvOqESTYR 8S1Lt9AvRaUvMbNHxWfVupBFDYBKCuQT21RW6D1K3c188LSe7vr6e2STNY8DNsFRsQOS uL06OXcXIH/30wN5WXFsh6nupeBNUgraWgX+HW/4RjbALScpIJPMAEvghrYCh1s2lmgk lzcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702593516; x=1703198316; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tI12aCWJQCHdnL9tpy1TZqFUoLiTbzcedlrkIrXRyzo=; b=jYCSJ5BmWj831aV+KylsBg6YH96KpPalN12AdU8BRbszXyGQuW4m/1SBUVz7IKulN4 C6wWxe4avsVJigSyaNbasgcPFhBJrrVk9G/FXVRfOboFLwb9bBPT9KqHXfTy20yEwF6J /hb5qQH400W3JVCliDFnWYke7x3sdVu/M0vTGAbJ0Gsrs5h9qfJl/JzTOfLP1lXA66zN 4NCkhYemF3GwfjSUr2u9SyQlNlVioOSXv7b8u6LAZfyQuOx/QfiS7mvpXXk2VF4QvQa8 lRUHS7+eays/zpagMfFZTcnd7i/2wG+mpxAx9YbcLv/Zc7ZK+t+udolOeC4o70dBm6bd Jb3g== X-Gm-Message-State: AOJu0YyEch4sL7Z7Ynd2rEm5tagj16eKR3L+VlIpY7vBmmd8Qq7IYTZ6 JxMhGMpVaPa8snRhcTzgxD4MTFlbGOE= X-Received: by 2002:a05:600c:1f1a:b0:40c:31f1:145c with SMTP id bd26-20020a05600c1f1a00b0040c31f1145cmr5011868wmb.169.1702593515923; Thu, 14 Dec 2023 14:38:35 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id n41-20020a05600c3ba900b0040c61ee0816sm54746wms.0.2023.12.14.14.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 14:38:35 -0800 (PST) From: Christian Marangi <ansuelsmth@gmail.com> To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi <ansuelsmth@gmail.com> Subject: [net-next PATCH v2 3/3] net: phy: led: dynamically allocate speed modes array Date: Thu, 14 Dec 2023 16:49:06 +0100 Message-Id: <20231214154906.29436-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231214154906.29436-1-ansuelsmth@gmail.com> References: <20231214154906.29436-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785298810944128475 X-GMAIL-MSGID: 1785298810944128475 |
Series |
net: add define to describe link speed modes
|
|
Commit Message
Christian Marangi
Dec. 14, 2023, 3:49 p.m. UTC
Instead of defining a big enough array for speed modes use the newly
introduced API to get the actual number of supported speed modes and
dynamically allocate them.
Allocated space is freed at the end of the LED register loop.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/phy/phy_led_triggers.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
Comments
Hi Christian, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-refactor-and-better-document-phy_speeds-function/20231215-064112 base: net-next/main patch link: https://lore.kernel.org/r/20231214154906.29436-4-ansuelsmth%40gmail.com patch subject: [net-next PATCH v2 3/3] net: phy: led: dynamically allocate speed modes array config: arm-randconfig-002-20231215 (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312152038.v9NZyBxd-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/net/phy/phy_led_triggers.c:89:30: error: call to undeclared function 'phy_supported_speeds_num'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 89 | phy->phy_num_led_triggers = phy_supported_speeds_num(phy); | ^ drivers/net/phy/phy_led_triggers.c:89:30: note: did you mean 'phy_supported_speeds'? include/linux/phy.h:208:14: note: 'phy_supported_speeds' declared here 208 | unsigned int phy_supported_speeds(struct phy_device *phy, | ^ >> drivers/net/phy/phy_led_triggers.c:133:2: error: call to undeclared library function 'free' with type 'void (void *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 133 | free(speeds); | ^ drivers/net/phy/phy_led_triggers.c:133:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'free' 2 errors generated. vim +/phy_supported_speeds_num +89 drivers/net/phy/phy_led_triggers.c 83 84 int phy_led_triggers_register(struct phy_device *phy) 85 { 86 unsigned int *speeds; 87 int i, err; 88 > 89 phy->phy_num_led_triggers = phy_supported_speeds_num(phy); 90 if (!phy->phy_num_led_triggers) 91 return 0; 92 93 speeds = kmalloc_array(phy->phy_num_led_triggers, sizeof(*speeds), 94 GFP_KERNEL); 95 if (!speeds) 96 return -ENOMEM; 97 98 /* Presence of speed modes already checked up */ 99 phy_supported_speeds(phy, speeds, phy->phy_num_led_triggers); 100 101 phy->led_link_trigger = devm_kzalloc(&phy->mdio.dev, 102 sizeof(*phy->led_link_trigger), 103 GFP_KERNEL); 104 if (!phy->led_link_trigger) { 105 err = -ENOMEM; 106 goto out_clear; 107 } 108 109 err = phy_led_trigger_register(phy, phy->led_link_trigger, 0, "link"); 110 if (err) 111 goto out_free_link; 112 113 phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, 114 phy->phy_num_led_triggers, 115 sizeof(struct phy_led_trigger), 116 GFP_KERNEL); 117 if (!phy->phy_led_triggers) { 118 err = -ENOMEM; 119 goto out_unreg_link; 120 } 121 122 for (i = 0; i < phy->phy_num_led_triggers; i++) { 123 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], 124 speeds[i], 125 phy_speed_to_str(speeds[i])); 126 if (err) 127 goto out_unreg; 128 } 129 130 phy->last_triggered = NULL; 131 phy_led_trigger_change_speed(phy); 132 > 133 free(speeds); 134 135 return 0; 136 out_unreg: 137 while (i--) 138 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); 139 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); 140 out_unreg_link: 141 phy_led_trigger_unregister(phy->led_link_trigger); 142 out_free_link: 143 devm_kfree(&phy->mdio.dev, phy->led_link_trigger); 144 phy->led_link_trigger = NULL; 145 out_clear: 146 free(speeds); 147 phy->phy_num_led_triggers = 0; 148 return err; 149 } 150 EXPORT_SYMBOL_GPL(phy_led_triggers_register); 151
Hi Christian, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-refactor-and-better-document-phy_speeds-function/20231215-064112 base: net-next/main patch link: https://lore.kernel.org/r/20231214154906.29436-4-ansuelsmth%40gmail.com patch subject: [net-next PATCH v2 3/3] net: phy: led: dynamically allocate speed modes array config: arm-randconfig-003-20231215 (https://download.01.org/0day-ci/archive/20231215/202312152044.iRWfyQXJ-lkp@intel.com/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231215/202312152044.iRWfyQXJ-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312152044.iRWfyQXJ-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/net/phy/phy_led_triggers.c:89:30: error: implicit declaration of function 'phy_supported_speeds_num' is invalid in C99 [-Werror,-Wimplicit-function-declaration] phy->phy_num_led_triggers = phy_supported_speeds_num(phy); ^ drivers/net/phy/phy_led_triggers.c:89:30: note: did you mean 'phy_supported_speeds'? include/linux/phy.h:208:14: note: 'phy_supported_speeds' declared here unsigned int phy_supported_speeds(struct phy_device *phy, ^ >> drivers/net/phy/phy_led_triggers.c:133:2: error: implicitly declaring library function 'free' with type 'void (void *)' [-Werror,-Wimplicit-function-declaration] free(speeds); ^ drivers/net/phy/phy_led_triggers.c:133:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'free' 2 errors generated. vim +/phy_supported_speeds_num +89 drivers/net/phy/phy_led_triggers.c 83 84 int phy_led_triggers_register(struct phy_device *phy) 85 { 86 unsigned int *speeds; 87 int i, err; 88 > 89 phy->phy_num_led_triggers = phy_supported_speeds_num(phy); 90 if (!phy->phy_num_led_triggers) 91 return 0; 92 93 speeds = kmalloc_array(phy->phy_num_led_triggers, sizeof(*speeds), 94 GFP_KERNEL); 95 if (!speeds) 96 return -ENOMEM; 97 98 /* Presence of speed modes already checked up */ 99 phy_supported_speeds(phy, speeds, phy->phy_num_led_triggers); 100 101 phy->led_link_trigger = devm_kzalloc(&phy->mdio.dev, 102 sizeof(*phy->led_link_trigger), 103 GFP_KERNEL); 104 if (!phy->led_link_trigger) { 105 err = -ENOMEM; 106 goto out_clear; 107 } 108 109 err = phy_led_trigger_register(phy, phy->led_link_trigger, 0, "link"); 110 if (err) 111 goto out_free_link; 112 113 phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, 114 phy->phy_num_led_triggers, 115 sizeof(struct phy_led_trigger), 116 GFP_KERNEL); 117 if (!phy->phy_led_triggers) { 118 err = -ENOMEM; 119 goto out_unreg_link; 120 } 121 122 for (i = 0; i < phy->phy_num_led_triggers; i++) { 123 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], 124 speeds[i], 125 phy_speed_to_str(speeds[i])); 126 if (err) 127 goto out_unreg; 128 } 129 130 phy->last_triggered = NULL; 131 phy_led_trigger_change_speed(phy); 132 > 133 free(speeds); 134 135 return 0; 136 out_unreg: 137 while (i--) 138 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); 139 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); 140 out_unreg_link: 141 phy_led_trigger_unregister(phy->led_link_trigger); 142 out_free_link: 143 devm_kfree(&phy->mdio.dev, phy->led_link_trigger); 144 phy->led_link_trigger = NULL; 145 out_clear: 146 free(speeds); 147 phy->phy_num_led_triggers = 0; 148 return err; 149 } 150 EXPORT_SYMBOL_GPL(phy_led_triggers_register); 151
On Fri, Dec 15, 2023 at 08:50:28PM +0800, kernel test robot wrote: > Hi Christian, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on net-next/main] > > url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-refactor-and-better-document-phy_speeds-function/20231215-064112 > base: net-next/main > patch link: https://lore.kernel.org/r/20231214154906.29436-4-ansuelsmth%40gmail.com > patch subject: [net-next PATCH v2 3/3] net: phy: led: dynamically allocate speed modes array > config: arm-randconfig-002-20231215 (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/config) > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202312152038.v9NZyBxd-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > >> drivers/net/phy/phy_led_triggers.c:89:30: error: call to undeclared function 'phy_supported_speeds_num'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > 89 | phy->phy_num_led_triggers = phy_supported_speeds_num(phy); > | ^ > drivers/net/phy/phy_led_triggers.c:89:30: note: did you mean 'phy_supported_speeds'? > include/linux/phy.h:208:14: note: 'phy_supported_speeds' declared here > 208 | unsigned int phy_supported_speeds(struct phy_device *phy, > | ^ > >> drivers/net/phy/phy_led_triggers.c:133:2: error: call to undeclared library function 'free' with type 'void (void *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > 133 | free(speeds); > | ^ > drivers/net/phy/phy_led_triggers.c:133:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'free' > 2 errors generated. > > > vim +/phy_supported_speeds_num +89 drivers/net/phy/phy_led_triggers.c > > 83 > 84 int phy_led_triggers_register(struct phy_device *phy) > 85 { > 86 unsigned int *speeds; > 87 int i, err; > 88 > > 89 phy->phy_num_led_triggers = phy_supported_speeds_num(phy); > 90 if (!phy->phy_num_led_triggers) > 91 return 0; > 92 > 93 speeds = kmalloc_array(phy->phy_num_led_triggers, sizeof(*speeds), > 94 GFP_KERNEL); > 95 if (!speeds) > 96 return -ENOMEM; > 97 > 98 /* Presence of speed modes already checked up */ > 99 phy_supported_speeds(phy, speeds, phy->phy_num_led_triggers); > 100 > 101 phy->led_link_trigger = devm_kzalloc(&phy->mdio.dev, > 102 sizeof(*phy->led_link_trigger), > 103 GFP_KERNEL); > 104 if (!phy->led_link_trigger) { > 105 err = -ENOMEM; > 106 goto out_clear; > 107 } > 108 > 109 err = phy_led_trigger_register(phy, phy->led_link_trigger, 0, "link"); > 110 if (err) > 111 goto out_free_link; > 112 > 113 phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, > 114 phy->phy_num_led_triggers, > 115 sizeof(struct phy_led_trigger), > 116 GFP_KERNEL); > 117 if (!phy->phy_led_triggers) { > 118 err = -ENOMEM; > 119 goto out_unreg_link; > 120 } > 121 > 122 for (i = 0; i < phy->phy_num_led_triggers; i++) { > 123 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], > 124 speeds[i], > 125 phy_speed_to_str(speeds[i])); > 126 if (err) > 127 goto out_unreg; > 128 } > 129 > 130 phy->last_triggered = NULL; > 131 phy_led_trigger_change_speed(phy); > 132 > > 133 free(speeds); > 134 > 135 return 0; > 136 out_unreg: > 137 while (i--) > 138 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); > 139 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); > 140 out_unreg_link: > 141 phy_led_trigger_unregister(phy->led_link_trigger); > 142 out_free_link: > 143 devm_kfree(&phy->mdio.dev, phy->led_link_trigger); > 144 phy->led_link_trigger = NULL; > 145 out_clear: > 146 free(speeds); > 147 phy->phy_num_led_triggers = 0; > 148 return err; > 149 } > 150 EXPORT_SYMBOL_GPL(phy_led_triggers_register); > 151 > Ugh didn't think that LEDs netdev trigger doesn't have a dependency on PHY... Andrew any idea about this? I can see 2 solution (or maybe 3???): - Add the dependency for PHY - Move phy_speeds net_utils.c (with the settings table moved there) - Implement a custom function in ledtrig-netdev.c It's sad since the phy_speed was just what we needed to implement this ins a ""clean way"".
On Sun, Dec 17, 2023 at 02:12:58AM +0100, Christian Marangi wrote: > On Fri, Dec 15, 2023 at 08:50:28PM +0800, kernel test robot wrote: > > Hi Christian, > > > > kernel test robot noticed the following build errors: > > > > [auto build test ERROR on net-next/main] > > > > url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-refactor-and-better-document-phy_speeds-function/20231215-064112 > > base: net-next/main > > patch link: https://lore.kernel.org/r/20231214154906.29436-4-ansuelsmth%40gmail.com > > patch subject: [net-next PATCH v2 3/3] net: phy: led: dynamically allocate speed modes array > > config: arm-randconfig-002-20231215 (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/config) > > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/reproduce) > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > the same patch/commit), kindly add following tags > > | Reported-by: kernel test robot <lkp@intel.com> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202312152038.v9NZyBxd-lkp@intel.com/ > > > > All errors (new ones prefixed by >>): > > > > >> drivers/net/phy/phy_led_triggers.c:89:30: error: call to undeclared function 'phy_supported_speeds_num'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > > 89 | phy->phy_num_led_triggers = phy_supported_speeds_num(phy); > > | ^ > > drivers/net/phy/phy_led_triggers.c:89:30: note: did you mean 'phy_supported_speeds'? > > include/linux/phy.h:208:14: note: 'phy_supported_speeds' declared here > > 208 | unsigned int phy_supported_speeds(struct phy_device *phy, > > | ^ > > >> drivers/net/phy/phy_led_triggers.c:133:2: error: call to undeclared library function 'free' with type 'void (void *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > > 133 | free(speeds); > > | ^ > > drivers/net/phy/phy_led_triggers.c:133:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'free' > > 2 errors generated. > > > > > > vim +/phy_supported_speeds_num +89 drivers/net/phy/phy_led_triggers.c > > > > 83 > > 84 int phy_led_triggers_register(struct phy_device *phy) > > 85 { > > 86 unsigned int *speeds; > > 87 int i, err; > > 88 > > > 89 phy->phy_num_led_triggers = phy_supported_speeds_num(phy); > > 90 if (!phy->phy_num_led_triggers) > > 91 return 0; > > 92 > > 93 speeds = kmalloc_array(phy->phy_num_led_triggers, sizeof(*speeds), > > 94 GFP_KERNEL); > > 95 if (!speeds) > > 96 return -ENOMEM; > > 97 > > 98 /* Presence of speed modes already checked up */ > > 99 phy_supported_speeds(phy, speeds, phy->phy_num_led_triggers); > > 100 > > 101 phy->led_link_trigger = devm_kzalloc(&phy->mdio.dev, > > 102 sizeof(*phy->led_link_trigger), > > 103 GFP_KERNEL); > > 104 if (!phy->led_link_trigger) { > > 105 err = -ENOMEM; > > 106 goto out_clear; > > 107 } > > 108 > > 109 err = phy_led_trigger_register(phy, phy->led_link_trigger, 0, "link"); > > 110 if (err) > > 111 goto out_free_link; > > 112 > > 113 phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, > > 114 phy->phy_num_led_triggers, > > 115 sizeof(struct phy_led_trigger), > > 116 GFP_KERNEL); > > 117 if (!phy->phy_led_triggers) { > > 118 err = -ENOMEM; > > 119 goto out_unreg_link; > > 120 } > > 121 > > 122 for (i = 0; i < phy->phy_num_led_triggers; i++) { > > 123 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], > > 124 speeds[i], > > 125 phy_speed_to_str(speeds[i])); > > 126 if (err) > > 127 goto out_unreg; > > 128 } > > 129 > > 130 phy->last_triggered = NULL; > > 131 phy_led_trigger_change_speed(phy); > > 132 > > > 133 free(speeds); > > 134 > > 135 return 0; > > 136 out_unreg: > > 137 while (i--) > > 138 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); > > 139 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); > > 140 out_unreg_link: > > 141 phy_led_trigger_unregister(phy->led_link_trigger); > > 142 out_free_link: > > 143 devm_kfree(&phy->mdio.dev, phy->led_link_trigger); > > 144 phy->led_link_trigger = NULL; > > 145 out_clear: > > 146 free(speeds); > > 147 phy->phy_num_led_triggers = 0; > > 148 return err; > > 149 } > > 150 EXPORT_SYMBOL_GPL(phy_led_triggers_register); > > 151 > > > > Ugh didn't think that LEDs netdev trigger doesn't have a dependency on > PHY... I don't think you've read and comprehended the kernel build bot message. It's complaining that: 1) phy_supported_speeds_num() is not declared in a header file. We can see this plainly in patch 2, where you introduce this new function, but don't add a function prototype to *any* header file. 2) the function "free" doesn't exist (which is absolutely correct, this isn't userspace code). Obviously, this could not have been build-tested prior to sending it out either of these would cause a build error. Maybe you built a kernel with a config that had LEDs support disabled?
On Sun, Dec 17, 2023 at 10:38:41AM +0000, Russell King (Oracle) wrote: > On Sun, Dec 17, 2023 at 02:12:58AM +0100, Christian Marangi wrote: > > On Fri, Dec 15, 2023 at 08:50:28PM +0800, kernel test robot wrote: > > > Hi Christian, > > > > > > kernel test robot noticed the following build errors: > > > > > > [auto build test ERROR on net-next/main] > > > > > > url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-refactor-and-better-document-phy_speeds-function/20231215-064112 > > > base: net-next/main > > > patch link: https://lore.kernel.org/r/20231214154906.29436-4-ansuelsmth%40gmail.com > > > patch subject: [net-next PATCH v2 3/3] net: phy: led: dynamically allocate speed modes array > > > config: arm-randconfig-002-20231215 (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/config) > > > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231215/202312152038.v9NZyBxd-lkp@intel.com/reproduce) > > > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > > the same patch/commit), kindly add following tags > > > | Reported-by: kernel test robot <lkp@intel.com> > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202312152038.v9NZyBxd-lkp@intel.com/ > > > > > > All errors (new ones prefixed by >>): > > > > > > >> drivers/net/phy/phy_led_triggers.c:89:30: error: call to undeclared function 'phy_supported_speeds_num'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > > > 89 | phy->phy_num_led_triggers = phy_supported_speeds_num(phy); > > > | ^ > > > drivers/net/phy/phy_led_triggers.c:89:30: note: did you mean 'phy_supported_speeds'? > > > include/linux/phy.h:208:14: note: 'phy_supported_speeds' declared here > > > 208 | unsigned int phy_supported_speeds(struct phy_device *phy, > > > | ^ > > > >> drivers/net/phy/phy_led_triggers.c:133:2: error: call to undeclared library function 'free' with type 'void (void *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > > > 133 | free(speeds); > > > | ^ > > > drivers/net/phy/phy_led_triggers.c:133:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'free' > > > 2 errors generated. > > > > > > > > > vim +/phy_supported_speeds_num +89 drivers/net/phy/phy_led_triggers.c > > > > > > 83 > > > 84 int phy_led_triggers_register(struct phy_device *phy) > > > 85 { > > > 86 unsigned int *speeds; > > > 87 int i, err; > > > 88 > > > > 89 phy->phy_num_led_triggers = phy_supported_speeds_num(phy); > > > 90 if (!phy->phy_num_led_triggers) > > > 91 return 0; > > > 92 > > > 93 speeds = kmalloc_array(phy->phy_num_led_triggers, sizeof(*speeds), > > > 94 GFP_KERNEL); > > > 95 if (!speeds) > > > 96 return -ENOMEM; > > > 97 > > > 98 /* Presence of speed modes already checked up */ > > > 99 phy_supported_speeds(phy, speeds, phy->phy_num_led_triggers); > > > 100 > > > 101 phy->led_link_trigger = devm_kzalloc(&phy->mdio.dev, > > > 102 sizeof(*phy->led_link_trigger), > > > 103 GFP_KERNEL); > > > 104 if (!phy->led_link_trigger) { > > > 105 err = -ENOMEM; > > > 106 goto out_clear; > > > 107 } > > > 108 > > > 109 err = phy_led_trigger_register(phy, phy->led_link_trigger, 0, "link"); > > > 110 if (err) > > > 111 goto out_free_link; > > > 112 > > > 113 phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, > > > 114 phy->phy_num_led_triggers, > > > 115 sizeof(struct phy_led_trigger), > > > 116 GFP_KERNEL); > > > 117 if (!phy->phy_led_triggers) { > > > 118 err = -ENOMEM; > > > 119 goto out_unreg_link; > > > 120 } > > > 121 > > > 122 for (i = 0; i < phy->phy_num_led_triggers; i++) { > > > 123 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], > > > 124 speeds[i], > > > 125 phy_speed_to_str(speeds[i])); > > > 126 if (err) > > > 127 goto out_unreg; > > > 128 } > > > 129 > > > 130 phy->last_triggered = NULL; > > > 131 phy_led_trigger_change_speed(phy); > > > 132 > > > > 133 free(speeds); > > > 134 > > > 135 return 0; > > > 136 out_unreg: > > > 137 while (i--) > > > 138 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); > > > 139 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); > > > 140 out_unreg_link: > > > 141 phy_led_trigger_unregister(phy->led_link_trigger); > > > 142 out_free_link: > > > 143 devm_kfree(&phy->mdio.dev, phy->led_link_trigger); > > > 144 phy->led_link_trigger = NULL; > > > 145 out_clear: > > > 146 free(speeds); > > > 147 phy->phy_num_led_triggers = 0; > > > 148 return err; > > > 149 } > > > 150 EXPORT_SYMBOL_GPL(phy_led_triggers_register); > > > 151 > > > > > > > Ugh didn't think that LEDs netdev trigger doesn't have a dependency on > > PHY... > > I don't think you've read and comprehended the kernel build bot > message. > > It's complaining that: > > 1) phy_supported_speeds_num() is not declared in a header file. We can > see this plainly in patch 2, where you introduce this new function, > but don't add a function prototype to *any* header file. > > 2) the function "free" doesn't exist (which is absolutely correct, > this isn't userspace code). > > Obviously, this could not have been build-tested prior to sending it out > either of these would cause a build error. Maybe you built a kernel with > a config that had LEDs support disabled? > Yes you are correct and I have sent this revision by mistake. (already sent other revision that have this corrected) Anyway I have sent the question to the wrong series... Resending it to the correct one, sorry for the noise. (anyway thanks for answering. Yes the problem in that series is that with a kernel randconfig PHY kconfig is not built and LED trigger doesn't depend on it, so it's a matter of decide it worth to add an additional dependency or move functions)
diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c index f550576eb9da..2e41d10e323c 100644 --- a/drivers/net/phy/phy_led_triggers.c +++ b/drivers/net/phy/phy_led_triggers.c @@ -83,14 +83,21 @@ static void phy_led_trigger_unregister(struct phy_led_trigger *plt) int phy_led_triggers_register(struct phy_device *phy) { + unsigned int *speeds; int i, err; - unsigned int speeds[50]; - phy->phy_num_led_triggers = phy_supported_speeds(phy, speeds, - ARRAY_SIZE(speeds)); + phy->phy_num_led_triggers = phy_supported_speeds_num(phy); if (!phy->phy_num_led_triggers) return 0; + speeds = kmalloc_array(phy->phy_num_led_triggers, sizeof(*speeds), + GFP_KERNEL); + if (!speeds) + return -ENOMEM; + + /* Presence of speed modes already checked up */ + phy_supported_speeds(phy, speeds, phy->phy_num_led_triggers); + phy->led_link_trigger = devm_kzalloc(&phy->mdio.dev, sizeof(*phy->led_link_trigger), GFP_KERNEL); @@ -123,6 +130,8 @@ int phy_led_triggers_register(struct phy_device *phy) phy->last_triggered = NULL; phy_led_trigger_change_speed(phy); + free(speeds); + return 0; out_unreg: while (i--) @@ -134,6 +143,7 @@ int phy_led_triggers_register(struct phy_device *phy) devm_kfree(&phy->mdio.dev, phy->led_link_trigger); phy->led_link_trigger = NULL; out_clear: + free(speeds); phy->phy_num_led_triggers = 0; return err; }