From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn Subject: Re: [patch net-next RFC 11/12] mlxsw: core: Extend hwmon interface with FAN fault attribute Date: Tue, 26 Jun 2018 16:28:38 +0200 Message-ID: <20180626142838.GC5064@lunn.ch> References: <1530015037-67361-1-git-send-email-vadimp@mellanox.com> <1530015037-67361-12-git-send-email-vadimp@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: davem@davemloft.net, netdev@vger.kernel.org, linux@roeck-us.net, rui.zhang@intel.com, edubezval@gmail.com, jiri@resnulli.us, mlxsw@mellanox.com, michaelsh@mellanox.com To: Vadim Pasternak Return-path: Received: from vps0.lunn.ch ([185.16.172.187]:43251 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935339AbeFZO2l (ORCPT ); Tue, 26 Jun 2018 10:28:41 -0400 Content-Disposition: inline In-Reply-To: <1530015037-67361-12-git-send-email-vadimp@mellanox.com> Sender: netdev-owner@vger.kernel.org List-ID: > +static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct mlxsw_hwmon_attr *mlwsw_hwmon_attr = > + container_of(attr, struct mlxsw_hwmon_attr, dev_attr); > + struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon; > + char mfsm_pl[MLXSW_REG_MFSM_LEN]; > + u16 tach; > + int err; > + > + mlxsw_reg_mfsm_pack(mfsm_pl, mlwsw_hwmon_attr->type_index); > + err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsm), mfsm_pl); > + if (err) { > + dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n"); > + return err; > + } > + tach = mlxsw_reg_mfsm_rpm_get(mfsm_pl); > + > + return sprintf(buf, "%u\n", (tach < mlxsw_hwmon->tach_min) ? 1 : 0); > +} Documentation/hwmon/sysfs-interface says: Alarms are direct indications read from the chips. The drivers do NOT make comparisons of readings to thresholds. This allows violations between readings to be caught and alarmed. The exact definition of an alarm (for example, whether a threshold must be met or must be exceeded to cause an alarm) is chip-dependent. Now, this is a fault, not an alarm. But does the same apply? Andrew