From patchwork Mon Jan 6 18:01:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13927732 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 AE543149DF4 for ; Mon, 6 Jan 2025 18:01:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736186482; cv=none; b=ZRBclzlxv8qdqzKARdU8YIn1giGoDU4AJ+Xy3S4U3y6WG0hfNxQ5391ZRqm7XOosS4e6U1VzlHxKPJ988f3ICtUpclzp7Ho6dgdUtWlQPWqPJtmESY5lK1ZJA3/HO9KHkLSBwgR1TnSWM4kriRAlINKv9slc2tnpLOCebtUD71g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736186482; c=relaxed/simple; bh=7QzdicXnjjuTIyXb1zMBJs2HlUeDsmxbl2AcTpILjp8=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=KQL60WaBmqTqH6kQXkL5GKoENuzdbXCpkAsAx3Jn1la7VhI4oCCHPJBvmAwg6lC2Zm4WswL3qqd0YoErZirwkc5dQ9KLzkzcQF2noeL+M9Knbc6BQai7Ta0ULibtt5buubKXFhFwA308OuR+mDbDVKuDa/STQGNU5L9sIKfly7I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WnMEvK8e; arc=none smtp.client-ip=209.85.218.54 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WnMEvK8e" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-aaf60d85238so882645066b.0 for ; Mon, 06 Jan 2025 10:01:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736186479; x=1736791279; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=dNFtSUL4p2xdptt92FS+EcD3qvXkvVtb4RKnVyliZfM=; b=WnMEvK8eX/xeKGCVgt1GY/SdxlNrKOq0CfWW+3BSHm2XCi8ExEyH8A97sRhdP1WrgL 9rkaF+FlSJ66AABRR1aFoN9KrodvJ+eelnKsDJOPqczlU5SHjwAHbjl8X1Okz1G2n7Mt mUpgkSo4a7/ITGJpolTDw6aREFE1p9jrCR2sRIOkuVGXzoMjY1DYnBbxBdIOGIpkHTv6 +nxlwWkxm+XeDOCRYlmCCkExf3SR3mShN8OuUCriJZAYBaWLnR+xvU4k5HzwqwJ6tE1D 7Af7fBXOZajxOyyFR7NgFWo9rbS7CthJSG2wqeJAURahWfppDzirrS7IcP7nKgRn0caG LPyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736186479; x=1736791279; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dNFtSUL4p2xdptt92FS+EcD3qvXkvVtb4RKnVyliZfM=; b=bjhd6MIJ0EBSm932BhUhJK2ZMoPMiWuWurUC8+qog23Taf6OGf834YAlkaqEaT4pRq 4bMW/9KdUrXXfRkoBWQ6Xmlyjfl3pZmd9gSSCS5pB5jJqiB8n87otP+adBKBBXHOvNCk Cy+P5tnv0geDIlj3tFxi90UAFRv/rs3KmiEKfrq8/Q75nVFUfAQ4tFHbfsYnrv3iJM/c wZHpxSvC58hynn7MfL9PSDorkNqdW4lw6s8cEfIFbVqASGC1/f7SvddvyDKAWU4SXU6O 5qK4q41Kqv0kMurMU6wuzx7NDGMA0QZFaPJgsuHYCePkUEhbM7EDOTs/RCsz5qMK3pje HF2g== X-Gm-Message-State: AOJu0Ywot/KuCXZBoE5Z1WY86encu2X51ik9X5ghRNw4Ke6q6/n1PuZM OJRhlBeUk5eNO8Ofnf1OAticms0bm7wRcDHNG2kksntM0+XYI30N X-Gm-Gg: ASbGncsJfmC1+3LQLv9M0cQlT84WWG2aGO5BUijE1gbUIlrdmXyAnUzBX2sNJ49UhNZ XzkLswiO1cB1/0eH2epZsgQ2XFpNgkRbiKgklRk8gkySbbywlqYPbKavc/ITwZdjQJS53HmCIVN oIFe8vnNIgDf18S/aJyG8HFqftgH5SuYxT8+HpkomYpb9W4hFou+EpvMMvVWXAILthR5WaKM2Up vpu79p0jK4qXpNCQ7FGIoELdKCRAK0D+UsJuOY/oWJyP+/hZ9czE6aDUHAygDuW8o0ERWqIRS75 hyBGql+OrCtqgir4MLcJ2sFZXslrur8gC50WZ7tOO/DmC+wJ2CwtqvqXjxFuwF0UMjwoBwifohi iyrXWRJFeaYh67I4vZ6EN7y6EUskTWPM37rtMc00I X-Google-Smtp-Source: AGHT+IEdxVtAsvCKsZwDlrNYKWGc/RwCIEKrXFQkdmDRihW204mkuBZfDiQNddh4RvtRhbSVC9GoLA== X-Received: by 2002:a17:907:3f89:b0:aa6:9624:78fd with SMTP id a640c23a62f3a-aac3444eb22mr5945428366b.48.1736186478849; Mon, 06 Jan 2025 10:01:18 -0800 (PST) Received: from ?IPV6:2a02:3100:ad97:900:c87:b717:6cf:e370? (dynamic-2a02-3100-ad97-0900-0c87-b717-06cf-e370.310.pool.telefonica.de. [2a02:3100:ad97:900:c87:b717:6cf:e370]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aac0efe48ecsm2305674866b.126.2025.01.06.10.01.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Jan 2025 10:01:17 -0800 (PST) Message-ID: Date: Mon, 6 Jan 2025 19:01:16 +0100 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH net-next 1/2] r8169: prepare for extending hwmon support From: Heiner Kallweit To: Realtek linux nic maintainers , Jakub Kicinski , Paolo Abeni , Eric Dumazet , David Miller , Andrew Lunn , Simon Horman Cc: "netdev@vger.kernel.org" References: <97bc1a93-d5d5-4444-86f2-a0b9cc89b0c8@gmail.com> Content-Language: en-US Autocrypt: addr=hkallweit1@gmail.com; keydata= xsFNBF/0ZFUBEAC0eZyktSE7ZNO1SFXL6cQ4i4g6Ah3mOUIXSB4pCY5kQ6OLKHh0FlOD5/5/ sY7IoIouzOjyFdFPnz4Bl3927ClT567hUJJ+SNaFEiJ9vadI6vZm2gcY4ExdIevYHWe1msJF MVE4yNwdS+UsPeCF/6CQQTzHc+n7DomE7fjJD5J1hOJjqz2XWe71fTvYXzxCFLwXXbBiqDC9 dNqOe5odPsa4TsWZ09T33g5n2nzTJs4Zw8fCy8rLqix/raVsqr8fw5qM66MVtdmEljFaJ9N8 /W56qGCp+H8Igk/F7CjlbWXiOlKHA25mPTmbVp7VlFsvsmMokr/imQr+0nXtmvYVaKEUwY2g 86IU6RAOuA8E0J5bD/BeyZdMyVEtX1kT404UJZekFytJZrDZetwxM/cAH+1fMx4z751WJmxQ J7mIXSPuDfeJhRDt9sGM6aRVfXbZt+wBogxyXepmnlv9K4A13z9DVLdKLrYUiu9/5QEl6fgI kPaXlAZmJsQfoKbmPqCHVRYj1lpQtDM/2/BO6gH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2ijEWm7Nrf52YMD7hL6rXXuis7R6zY8WnnBhW0uCfhajx q+KuARXC0sDLztcjaS3ayXonpoCPZep2Bd5xqE4Ln8/COCslP7E92W1uf1EcdXXIrx1acg21 H/0Z53okMykVs3a8tECPHIxnre2UxKdTbCEkjkR4V6JyplTS47oWMw3zyI7zkaadfzVFBxk2 lo/Tny+FX1Azea3Ce7oOnRUEZtWSsUidtIjmL8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <97bc1a93-d5d5-4444-86f2-a0b9cc89b0c8@gmail.com> X-Patchwork-Delegate: kuba@kernel.org This factors out the temperature value calculation and prepares for adding further temperature attributes. Signed-off-by: Heiner Kallweit Reviewed-by: Andrew Lunn --- drivers/net/ethernet/realtek/r8169_main.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 5724f650f..38f915956 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -5338,17 +5338,28 @@ static bool rtl_aspm_is_safe(struct rtl8169_private *tp) return false; } +static int r8169_hwmon_get_temp(int raw) +{ + if (raw >= 512) + raw -= 1024; + + return 1000 * raw / 2; +} + static int r8169_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { struct rtl8169_private *tp = dev_get_drvdata(dev); - int val_raw; - - val_raw = phy_read_paged(tp->phydev, 0xbd8, 0x12) & 0x3ff; - if (val_raw >= 512) - val_raw -= 1024; + int raw; - *val = 1000 * val_raw / 2; + switch (attr) { + case hwmon_temp_input: + raw = phy_read_paged(tp->phydev, 0xbd8, 0x12) & 0x3ff; + *val = r8169_hwmon_get_temp(raw); + break; + default: + return -EINVAL; + } return 0; } From patchwork Mon Jan 6 18:05:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13927734 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 2810F1DE4F1 for ; Mon, 6 Jan 2025 18:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736186718; cv=none; b=BYbDBiCibMvA1XHjM2qwhqRAmGmlppHJcYNSJRE/WFg5fSjhRdZCw0CTDYZhB7E8W4BIWgUIQXtxGlh8s5KvxlIXEyAY+hhx8b4MBXZhoD+4otS3RAD14pdUkvgBqegGV8UsTUkeFzjZO1DEC7NWwGVfkG5S6Mz2GskLlmLGaPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736186718; c=relaxed/simple; bh=2ofS9WWOmW9q9dpjY/gybK/HLt+BRsJhtacfxZeZlFQ=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=pIqCFb0B5tTehjwlVoGhkhM5Qk2XB/hNOqgogmuKd0l/SpwJ8eqaI6G/ybusYQ0FuAheXi8B62mWIrmPzhgJQ7B1QzJF7idcpMY2Z5cAm7/LwRJwT+5Et8rCVfE4yn4z9FfYBbVU2nGZ1pHGPWVXS5ogd6OT+tn8ccqCV8k+tW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CQ43H9rk; arc=none smtp.client-ip=209.85.218.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CQ43H9rk" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-aaeecbb7309so115757866b.0 for ; Mon, 06 Jan 2025 10:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736186715; x=1736791515; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=UpGfN9yA5rtjygyZCZr0AAJc1kLEkTiuNusRLw8EH+k=; b=CQ43H9rk5oENbLxfy3XI4lI8SFTEuqpcuflGLPPoMIr3V5fvb/QTc0/b8/RjYR3pD+ YtbglNC/mDSH+4KX1LAV1P0+76hJIzKhKw7k4TlZSGtb39u3zjeW3oZwYlzC4G7L24Nh slCQrRDas0hEk8QpWN9JE7LHI+swLbtKQLVljXnFwbaprLgsJG245ufjpIdLFHLfG7zi FWr3utKETaeIS8ryJENHQTEBcj5s57V2fWB4CIFrMaGLwHtzEhPlcfdbSmF8NhNlnx/i E8rtnsb+YzAyKXQjCClI+Gmez46VC7KKnDIqz6VF9ZIFVPWW9oHjP8OxxWJ0cTTjJzqD 7aOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736186715; x=1736791515; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UpGfN9yA5rtjygyZCZr0AAJc1kLEkTiuNusRLw8EH+k=; b=MbLzBv6YcFGiL6UwkkAHkwZVb1Yz/AIaqH/vTr7lyoF8k1BCTpbFDgWr9Y95uaEv0v Mbdz3Mr2LHVKt6wWYGKoCIS6uvdevad3pUk011A/OdAwuQxekoilrTbn4bnaXAl6w9OV hponmS4GMEV3pfsZh0EfWtvl/bC920+Oxv0xegFDrXd8jnUMeeNlP4VJHbe1nZHtTzPi dFxGJnRHFePILe2ZKvKEo5imvKmbliRVu5z2/+JTzM3RFobNolWDaUNFg/e3tybrRLSI 9p5EPIJ2mBp1/ft9blrIBAbY4N2ad8GtFYHDC3mLycVvUFsot+C1fwqLwRfRhVn+62Fe ALPA== X-Gm-Message-State: AOJu0Yym12U+Ve5i4AFaC6Yhrr94e5Bd6wKaXDledlj6bquWko1YHiMF +BffYY57VBux1Emds0oaxOp1z2+tlDdOQfHVXa6yJ1gMGsC8ZErX X-Gm-Gg: ASbGncvmDXv4gy48SseO9AbHH48WImX2EvO3q2Sl0/GU1TDJKTG+rVh5nNuVP5lEEBy kZOUmxwsiyJbMy00Re5CkkYELwyZoYLs1Zb02YzEOy99R8TmhQ4S0Q+9pwDKlrYA69Ox9dYbxpT ACBPQpKJEAfTrWOhT65J6TCKriiCGQwW6EHPKPB1szkN1CRwDc/TwBBBuUZv29jNcHmtY07wmpi BiaFvHZu87tl/T2l6/J8Tm+ZgJmnK3QOuWYnRBrdwYVwcQpcqOT2GeafvWoWbHAPlCVI8TmIkXZ UowvWJKUdMgnq4SYVsxRigPT4aVFoglrAmhvgGIVeXvynw6SlWSvDmBxmRDmR2yTxeupb8F2kaN f6e5CTWwD9c8EM2Td9LSkp+JxS/56L+LijEaLYUCN X-Google-Smtp-Source: AGHT+IHzIPNIVUbZU+Gg5/kO87Lp9x8AvDtEdLh2MiOCd796Jzbbxus3NkEVhwwtLbYF4Y3ShgYPoQ== X-Received: by 2002:a17:907:da4:b0:aa6:8bb4:5030 with SMTP id a640c23a62f3a-aac269598damr5512941866b.0.1736186715306; Mon, 06 Jan 2025 10:05:15 -0800 (PST) Received: from ?IPV6:2a02:3100:ad97:900:c87:b717:6cf:e370? (dynamic-2a02-3100-ad97-0900-0c87-b717-06cf-e370.310.pool.telefonica.de. [2a02:3100:ad97:900:c87:b717:6cf:e370]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aac0e89887csm2283658266b.80.2025.01.06.10.05.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Jan 2025 10:05:14 -0800 (PST) Message-ID: Date: Mon, 6 Jan 2025 19:05:13 +0100 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH net-next 2/2] r8169: add support for reading over-temp threshold From: Heiner Kallweit To: Realtek linux nic maintainers , Jakub Kicinski , Paolo Abeni , Eric Dumazet , David Miller , Andrew Lunn , Simon Horman Cc: "netdev@vger.kernel.org" References: <97bc1a93-d5d5-4444-86f2-a0b9cc89b0c8@gmail.com> Content-Language: en-US Autocrypt: addr=hkallweit1@gmail.com; keydata= xsFNBF/0ZFUBEAC0eZyktSE7ZNO1SFXL6cQ4i4g6Ah3mOUIXSB4pCY5kQ6OLKHh0FlOD5/5/ sY7IoIouzOjyFdFPnz4Bl3927ClT567hUJJ+SNaFEiJ9vadI6vZm2gcY4ExdIevYHWe1msJF MVE4yNwdS+UsPeCF/6CQQTzHc+n7DomE7fjJD5J1hOJjqz2XWe71fTvYXzxCFLwXXbBiqDC9 dNqOe5odPsa4TsWZ09T33g5n2nzTJs4Zw8fCy8rLqix/raVsqr8fw5qM66MVtdmEljFaJ9N8 /W56qGCp+H8Igk/F7CjlbWXiOlKHA25mPTmbVp7VlFsvsmMokr/imQr+0nXtmvYVaKEUwY2g 86IU6RAOuA8E0J5bD/BeyZdMyVEtX1kT404UJZekFytJZrDZetwxM/cAH+1fMx4z751WJmxQ J7mIXSPuDfeJhRDt9sGM6aRVfXbZt+wBogxyXepmnlv9K4A13z9DVLdKLrYUiu9/5QEl6fgI kPaXlAZmJsQfoKbmPqCHVRYj1lpQtDM/2/BO6gHAS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ijEWm7Nrf52YMD7hL6rXXuis7R6zY8WnnBhW0uCfhajx q+KuARXC0sDLztcjaS3ayXonpoCPZep2Bd5xqE4Ln8/COCslP7E92W1uf1EcdXXIrx1acg21 H/0Z53okMykVs3a8tECPHIxnre2UxKdTbCEkjkR4V6JyplTS47oWMw3zyI7zkaadfzVFBxk2 lo/Tny+FX1Azea3Ce7oOnRUEZtWSsUidtIjmL8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <97bc1a93-d5d5-4444-86f2-a0b9cc89b0c8@gmail.com> X-Patchwork-Delegate: kuba@kernel.org Add support for reading the over-temp threshold. If the chip temperature exceeds this value, the chip will reduce the speed to 1Gbps (by disabling 2.5G/5G advertisement and triggering a renegotiation). Signed-off-by: Heiner Kallweit Reviewed-by: Andrew Lunn --- drivers/net/ethernet/realtek/r8169_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 38f915956..fd6ff77e8 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -5357,6 +5357,11 @@ static int r8169_hwmon_read(struct device *dev, enum hwmon_sensor_types type, raw = phy_read_paged(tp->phydev, 0xbd8, 0x12) & 0x3ff; *val = r8169_hwmon_get_temp(raw); break; + case hwmon_temp_max: + /* Chip reduces speed to 1G if threshold is exceeded */ + raw = phy_read_paged(tp->phydev, 0xb54, 0x16) >> 6; + *val = r8169_hwmon_get_temp(raw); + break; default: return -EINVAL; } @@ -5370,7 +5375,7 @@ static const struct hwmon_ops r8169_hwmon_ops = { }; static const struct hwmon_channel_info * const r8169_hwmon_info[] = { - HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX), NULL };