Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp307143pxy; Wed, 21 Apr 2021 03:35:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6sf7XMEJghxmXpAnSk1q2ikGHBJkGoRPZItYI/BgpyHB7XKIcR3mFIsRvnkqV8RI1tJjP X-Received: by 2002:a17:906:af94:: with SMTP id mj20mr32427149ejb.279.1619001333892; Wed, 21 Apr 2021 03:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619001333; cv=none; d=google.com; s=arc-20160816; b=vAtFOZ6aXUjmTrHsMa4ltfrjDdk8xeW0iqyr35qjw/irXiVC6FdomrOZo4eJc+T8P6 Yv9RYrZ1F7ANzCZKXO7gcbXlfSmYWvT8wnhUtApPKZWucbBd6VD3kj2K/WtywD3MpLTh G8tWOf/8hQ/r8C39kr5DMjeZiu+e4Uwk7rh/0ClMgY5mkHQEPi00/MNzp7bqmWtZZU5S +oWkggeAodJmoI0WNPcLgN3x4XFvmswEhCPzSf1ZCj1EG7p4ohQ3Y7FfA9VvP2yOYHRL xn5RZaLJ0DEZhHC6vo+5Da1NMKsT6LD1bFM1NAkOKa34Htuwkpv8GL7rV+TX246YqePl pB7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=mapYpz4d6B2un+rQqE+/GsrGdYsL1RzUyIJiwD8K17I=; b=qxOao3Lb5STgN6RI6KVAEhLKdhzEMJ/ln4Go1MddgAp5rTUfajXFUYW+RgvE2EM8Ri A+ZIJS4Pec6mfrDJFqUlTBo/eRl6Mpd57j+yG1JNuLF2zcu/H5+iywimSkDdljC0J6Ji zkXsWluSVgtBUGtqFMYyTbuMBL72B5Dzm/F65VquJB+JP+pS91qnGCk7ZfRzu10iSpcq SP7l/WCa+18cm/q3x98byyUHKoCXO+UZykQDch1m5qwf2zqE/mTOyiwCAGv6dAmIBHHI mpRkPAd1/+douEtSNxdSFDTEERMWpNWe4ok6IApo1IDbCrhdBUMebn8CwM6XMaiK1ezI Susg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=Qis7ukCn; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si1538132edv.493.2021.04.21.03.35.11; Wed, 21 Apr 2021 03:35:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=Qis7ukCn; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235185AbhDUKcy (ORCPT + 99 others); Wed, 21 Apr 2021 06:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235335AbhDUKcv (ORCPT ); Wed, 21 Apr 2021 06:32:51 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987B9C061342 for ; Wed, 21 Apr 2021 03:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mapYpz4d6B2un+rQqE+/GsrGdYsL1RzUyIJiwD8K17I=; b=Qis7ukCntEWog18vRSVMyepPzN aaxMyq1XSdkt6P0FPGyVkk0lYaZvgmOJOnTaFCD3tiH5BuungameU89mMzPsdAB2HADCLm4OTjcOq 3PfCyjAVIL0VpD6JDcms+nn+gqrM+vIp9B9M7ReqgacxQH19F9QUzoqwy9bnJPDkQtpk=; Received: from p4ff13bc6.dip0.t-ipconnect.de ([79.241.59.198] helo=nf.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1lZA9U-0002VE-AG; Wed, 21 Apr 2021 12:32:12 +0200 Subject: Re: [PATCH 2/2] mt76: mt7615: add thermal sensor device support To: Ryder Lee , Lorenzo Bianconi Cc: Shayne Chen , linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org References: From: Felix Fietkau Message-ID: <57888c9e-f66c-3922-9979-9d24e3e7d07f@nbd.name> Date: Wed, 21 Apr 2021 12:32:11 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2021-04-17 22:42, Ryder Lee wrote: > Similar to mt7915, switching to use standard hwmon sysfs. > For reading temperature, cat /sys/class/ieee80211/phy*/hwmon*/temp1_input > > Signed-off-by: Ryder Lee > --- > .../wireless/mediatek/mt76/mt7615/debugfs.c | 20 -------- > .../net/wireless/mediatek/mt76/mt7615/init.c | 50 +++++++++++++++++++ > .../net/wireless/mediatek/mt76/mt7615/mcu.c | 6 +-- > .../wireless/mediatek/mt76/mt7615/mt7615.h | 3 +- > .../wireless/mediatek/mt76/mt7615/pci_init.c | 4 ++ > 5 files changed, 58 insertions(+), 25 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c > index d84662fb0304..22ccad43a13e 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c > @@ -8,11 +8,61 @@ > */ > > #include > +#include > +#include > #include "mt7615.h" > #include "mac.h" > #include "mcu.h" > #include "eeprom.h" > > +static ssize_t mt7615_thermal_show_temp(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct mt7615_dev *mdev = dev_get_drvdata(dev); > + int temperature; > + > + if (!mt7615_wait_for_mcu_init(mdev)) > + return 0; > + > + mt7615_mutex_acquire(mdev); > + temperature = mt7615_mcu_get_temperature(mdev); > + mt7615_mutex_release(mdev); > + > + if (temperature < 0) > + return temperature; > + > + /* display in millidegree celcius */ > + return sprintf(buf, "%u\n", temperature * 1000); > +} > + > +static SENSOR_DEVICE_ATTR(temp1_input, 0444, mt7615_thermal_show_temp, > + NULL, 0); > + > +static struct attribute *mt7615_hwmon_attrs[] = { > + &sensor_dev_attr_temp1_input.dev_attr.attr, > + NULL, > +}; > +ATTRIBUTE_GROUPS(mt7615_hwmon); > + > +int mt7615_thermal_init(struct mt7615_dev *dev) > +{ > + struct wiphy *wiphy = mt76_hw(dev)->wiphy; > + struct device *hwmon; > + > + if (!IS_REACHABLE(CONFIG_HWMON)) > + return 0; > + > + hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, > + wiphy_name(wiphy), phy, This does not compile (wrong variable name). - Felix