From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 E3F872D94AF for ; Fri, 28 Nov 2025 08:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764317449; cv=none; b=GjCxp8SkKXpUM9XSgwQ4/ifIXlox1hwSNDibAURR808wgiSUp6Y249tt56vhBM7yJiMzk1aDQHDLx4ij84r4P9LAxubHAXv7Lcv0RCVvgr+cHErg2qS30om4pl2Zc5BWWJ5YQCaAjYpwjO2xaFMTsVhn2YZ4nn/5T5QYWZM9IoM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764317449; c=relaxed/simple; bh=BI6d5r9H0oVhcgY7hqM0ujL/0z2q9c72cR3/Pq4ycVA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WmgLqIqnefC/ZcKjdlRouSoVNOfpw0iAikiSDXGz+HmALhMV3zORaovJgt31Jt8ZRoamGMyKPBBveDSmVFEAU0IIbUiP4AupRy6CYSCjkWfKPq13OHbZVKJh0BAaqARwiSSthMZ84z5ZvAj7PhffuUaYz5Ap3JhTecLoFOAKm5E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SiVskeq6; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SiVskeq6" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4775e891b5eso6357395e9.2 for ; Fri, 28 Nov 2025 00:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764317445; x=1764922245; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+2bFlIh8I9NZQcRpDPD+Djsorg8bRceb3xQr+grKSRk=; b=SiVskeq6fS1FHwAMamNK5PYuedSA93M5Bzg0yrtGs3Vr5Llc40P2NzcfRmz5J66o1k m84N4iWTxOtr5b+x3qLpUlRBHt63gzQeDCIGj5jYZgRCLb5RSMFZmIzCasHW4NyPJ+8w qy9SeOQrTLcZEfLvmgF2A7uUDuw14KblgaXULzw7pyaOMl9AApiYAmtpQaX9wFf2/IgA go9jqHKAiaHvocJYzxJnrhfIdZMaGqmhfahg/7qCKuvy78e/qW2hMB+jdJh1CRvn3+up 7ynNV8oJz3Ruq+ZLVcJh9as3+qkkL1seDWmmo+gl2x00y7kjuANKol0ocDQVguNQM2fc 6ung== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764317445; x=1764922245; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+2bFlIh8I9NZQcRpDPD+Djsorg8bRceb3xQr+grKSRk=; b=FaxcBpmjNtvoMXHcLzRTcBf1uyn0hiO6eO2hR+txMU8aeWeOD0j7W6mKalUKIQkeGL WiX7tzc4voxwAJbbQCZ0MCik+9WIg6ZQt2pdHXs6+zlg3+U2KP7D09HGZ5sbIH6b/e6l 7yQPA2hMBjflpeVdJBC7DANuL2BPlfuQHzRI5Gs2DZvBVridSECfZgpHLxzzpo+JzIX6 k2u/YAx2fMhKsRwTztwlyrJzP2gW33m3ZGobPnNfc8ccaB2yOcrnqwAf7FP6fL8lZKRy oo6cJf92d8Q/BxFiG8f1IuweGqxGSe5D7vRogZDvZz3uM6hgCyDUBPeZCFvsyEF70Df5 8BSA== X-Forwarded-Encrypted: i=1; AJvYcCXW/jFXmSQ983T1hWDBk/i+tyMDLpaflp7gO2FqbTOwVWwOARhgGf/ZHMebib3v6ZWzkAoYa3MD+H4=@vger.kernel.org X-Gm-Message-State: AOJu0Yywt/HE7Y8dLCOfIfsGmJe9wO8XL2sYesoahAoH1QyqTebb6o5h hnTg6xOG8oGHR3fxIr95J6nzLJCSST679F/Mq4Vbg/gfTf/9//qVibS7hbwxEh1FGaE= X-Gm-Gg: ASbGnctWAP4Znbcw4TxQhIweDzdvPB/Sqm2H/xQub5c8ZvTlAu/hm+HajwPQ1k7Cw3m /xPI+LJCQmqSs/S0d7u9gEupJOivMiwHC0eCgxANZN+TRxCft4qgw1JntXB3xN6uE7dRlptknUr wfstQTaCETshOPa8VntjFpzOZ4OEzdGvP5zS6BDcOndWwmtJhI2SZyU33iPpNLkJF0txHA5RP7Y 4LNQJQ8ieDEgGSmGf1EIUfhPfBS39VE07Acn/uheRKjAfTdU3J3eRXZDjTBZPbwEl9Rz3+pTFr3 kXrspQaEuiVBx6hkcrRs6kan8iJNdV6gaiyRNbiwAB1HTSazvGsqzac0FZ0q6m2kb2jyGPsK42x Ym2sMwBv6YWqFsI28b1CH5XKPyfxSfZjr2TINDKDnuc7f/SyNCU9Cd4Y0mTonfwbua+hjRH0b5S DpgO3OrxYOOnT8SPV7 X-Google-Smtp-Source: AGHT+IHVNGxLHdQSfNonRBBq78f347/I8I+ulkCPlaTONnGVXYiUFj038obXmFsDqBT8iAGXzvuP8A== X-Received: by 2002:a05:600c:1d1d:b0:477:7c7d:d9b7 with SMTP id 5b1f17b1804b1-477c01ec3f5mr247354265e9.33.1764317445111; Fri, 28 Nov 2025 00:10:45 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-47911143bb6sm83247115e9.3.2025.11.28.00.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 00:10:43 -0800 (PST) Date: Fri, 28 Nov 2025 11:10:39 +0300 From: Dan Carpenter To: James Calligeros Cc: Sven Peter , Janne Grunau , Alyssa Rosenzweig , Neal Gompa , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni , Jean Delvare , Guenter Roeck , Dmitry Torokhov , Jonathan Corbet , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v5 06/11] hwmon: Add Apple Silicon SMC hwmon driver Message-ID: References: <20251112-macsmc-subdevs-v5-0-728e4b91fe81@gmail.com> <20251112-macsmc-subdevs-v5-6-728e4b91fe81@gmail.com> Precedence: bulk X-Mailing-List: linux-rtc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251112-macsmc-subdevs-v5-6-728e4b91fe81@gmail.com> On Wed, Nov 12, 2025 at 09:16:52PM +1000, James Calligeros wrote: > +static int macsmc_hwmon_populate_sensors(struct macsmc_hwmon *hwmon, > + struct device_node *hwmon_node) > +{ > + struct device_node *key_node __maybe_unused; The for_each_child_of_node_with_prefix() macros declare key_node so this declaration is never used so far as I can see. I thought Sparse had a warning where we declared shadow variables where two variables have the same name but it doesn't complain here. #strange > + struct macsmc_hwmon_sensor *sensor; > + u32 n_current = 0, n_fan = 0, n_power = 0, n_temperature = 0, n_voltage = 0; > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "current-") { ^^^^^^^^ regards, dan carpenter > + n_current++; > + } > + > + if (n_current) { > + hwmon->curr.sensors = devm_kcalloc(hwmon->dev, n_current, > + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); > + if (!hwmon->curr.sensors) > + return -ENOMEM; > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "current-") { > + sensor = &hwmon->curr.sensors[hwmon->curr.count]; > + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { > + sensor->attrs = HWMON_C_INPUT; > + > + if (*sensor->label) > + sensor->attrs |= HWMON_C_LABEL; > + > + hwmon->curr.count++; > + } > + } > + } > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "fan-") { > + n_fan++; > + } > + > + if (n_fan) { > + hwmon->fan.fans = devm_kcalloc(hwmon->dev, n_fan, > + sizeof(struct macsmc_hwmon_fan), GFP_KERNEL); > + if (!hwmon->fan.fans) > + return -ENOMEM; > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "fan-") { > + if (!macsmc_hwmon_create_fan(hwmon->dev, hwmon->smc, key_node, > + &hwmon->fan.fans[hwmon->fan.count])) > + hwmon->fan.count++; > + } > + } > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "power-") { > + n_power++; > + } > + > + if (n_power) { > + hwmon->power.sensors = devm_kcalloc(hwmon->dev, n_power, > + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); > + if (!hwmon->power.sensors) > + return -ENOMEM; > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "power-") { > + sensor = &hwmon->power.sensors[hwmon->power.count]; > + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { > + sensor->attrs = HWMON_P_INPUT; > + > + if (*sensor->label) > + sensor->attrs |= HWMON_P_LABEL; > + > + hwmon->power.count++; > + } > + } > + } > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "temperature-") { > + n_temperature++; > + } > + > + if (n_temperature) { > + hwmon->temp.sensors = devm_kcalloc(hwmon->dev, n_temperature, > + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); > + if (!hwmon->temp.sensors) > + return -ENOMEM; > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "temperature-") { > + sensor = &hwmon->temp.sensors[hwmon->temp.count]; > + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { > + sensor->attrs = HWMON_T_INPUT; > + > + if (*sensor->label) > + sensor->attrs |= HWMON_T_LABEL; > + > + hwmon->temp.count++; > + } > + } > + } > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "voltage-") { > + n_voltage++; > + } > + > + if (n_voltage) { > + hwmon->volt.sensors = devm_kcalloc(hwmon->dev, n_voltage, > + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL); > + if (!hwmon->volt.sensors) > + return -ENOMEM; > + > + for_each_child_of_node_with_prefix(hwmon_node, key_node, "volt-") { > + sensor = &hwmon->temp.sensors[hwmon->temp.count]; > + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { > + sensor->attrs = HWMON_I_INPUT; > + > + if (*sensor->label) > + sensor->attrs |= HWMON_I_LABEL; > + > + hwmon->volt.count++; > + } > + } > + } > + > + return 0; > +}