From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Subject: Re: [PATCH V2] net: phy: tja11xx: Add TJA11xx PHY driver Date: Sun, 23 Dec 2018 10:12:46 +0100 Message-ID: <76761bb4-2a4b-0785-cb73-b285a6444863@denx.de> References: <20181214161149.6493-1-marex@denx.de> <20181215170153.GA5922@lunn.ch> <42aad282-2100-87bc-7145-a19f8f46afa6@gmail.com> <80ec255b-ae2e-eb29-a6ea-dfa4b00ae0de@denx.de> <08d66ea6-481c-94d0-373b-a3f987232951@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, f.fainelli@gmail.com To: Heiner Kallweit , Andrew Lunn Return-path: Received: from mail-out.m-online.net ([212.18.0.10]:41469 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbeLWJ0C (ORCPT ); Sun, 23 Dec 2018 04:26:02 -0500 In-Reply-To: <08d66ea6-481c-94d0-373b-a3f987232951@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 12/22/18 6:24 PM, Heiner Kallweit wrote: > On 22.12.2018 00:22, Marek Vasut wrote: >> On 12/15/2018 06:38 PM, Heiner Kallweit wrote: >>> On 15.12.2018 18:01, Andrew Lunn wrote: >>>>> +static struct tja11xx_phy_stats tja11xx_hw_stats[] = { >>>>> + { "phy_symbol_error_count", 20, 0, 0xffff }, >>>>> + { "phy_overtemp_error", 21, 1, BIT(1) }, >>>>> + { "phy_undervolt_error", 21, 3, BIT(3) }, >>>>> + { "phy_polarity_detect", 25, 6, BIT(6) }, >>>>> + { "phy_open_detect", 25, 7, BIT(7) }, >>>>> + { "phy_short_detect", 25, 8, BIT(8) }, >>>> >>>> Hi Marek >>>> >>>> You have a number of one bit counters here, which is pretty unusual. >>>> The names also don't really suggest they are counters. >>>> >>> Apart from few counters the values seem to be flags. I just think >>> it could be done in a little bit more readable form, e.g. instead of >>> { "phy_short_detect", 25, 8, BIT(8) } use >>> { "phy_short_detect", 25, BIT(8) } and in tja11xx_get_stats() then >>> use FIELD_GET (see linux/bitfield.h). >> >> This doesn't work with the counters, it only works with flags. The array >> contains both. >> > Maybe we have a misunderstanding here, but FIELD_GET would work also > with the counters. FIELD_GET calculates the field offset, so you don't > need to specify it. Let's say you would have an entry in your array like > this: { "phy_xxx_error_count", 20, 4, 0xfff0 } > > Then you would do: > #define XXX_ERROR_CNT_MASK GENMASK(15, 4) > { "phy_xxx_error_count", 20, XXX_ERROR_CNT_MASK } > and access the value by > val = FIELD_GET(XXX_ERROR_CNT_MASK, reg) Ah, let's try that then. >>> The idea of HWMON attributes sounds good to me because it allows >>> to use the flags to trigger actions in a structured way. And I >>> assume in case of e.g. "PHY undervolt" some monitoring system >>> would like to be informed (especially because we talk about >>> automotive here). >> >> I added HWMON_T_CRIT_ALARM and HWMON_I_LCRIT_ALARM for >> phy_overtemp_error and phy_undervolt_error respectively. >> Are there any other hwmon attributes I can use to replace the flags in >> the tja11xx_hw_stats array ? >> > I think that's it. OK -- Best regards, Marek Vasut