@@ -131,6 +131,57 @@ static const struct hwmon_chip_info bnxt_hwmon_chip_info = {
131
131
.info = bnxt_hwmon_info ,
132
132
};
133
133
134
+ static ssize_t temp1_shutdown_show (struct device * dev ,
135
+ struct device_attribute * attr , char * buf )
136
+ {
137
+ struct bnxt * bp = dev_get_drvdata (dev );
138
+
139
+ return sysfs_emit (buf , "%u\n" , bp -> shutdown_thresh_temp * 1000 );
140
+ }
141
+
142
+ static ssize_t temp1_shutdown_alarm_show (struct device * dev ,
143
+ struct device_attribute * attr , char * buf )
144
+ {
145
+ struct bnxt * bp = dev_get_drvdata (dev );
146
+ u8 temp ;
147
+ int rc ;
148
+
149
+ rc = bnxt_hwrm_temp_query (bp , & temp );
150
+ if (rc )
151
+ return - EIO ;
152
+
153
+ return sysfs_emit (buf , "%u\n" , temp >= bp -> shutdown_thresh_temp );
154
+ }
155
+
156
+ static DEVICE_ATTR_RO (temp1_shutdown );
157
+ static DEVICE_ATTR_RO (temp1_shutdown_alarm );
158
+
159
+ static struct attribute * bnxt_temp_extra_attrs [] = {
160
+ & dev_attr_temp1_shutdown .attr ,
161
+ & dev_attr_temp1_shutdown_alarm .attr ,
162
+ NULL ,
163
+ };
164
+
165
+ static umode_t bnxt_temp_extra_attrs_visible (struct kobject * kobj ,
166
+ struct attribute * attr , int index )
167
+ {
168
+ struct device * dev = kobj_to_dev (kobj );
169
+ struct bnxt * bp = dev_get_drvdata (dev );
170
+
171
+ /* Shutdown temperature setting in NVM is optional */
172
+ if (!(bp -> fw_cap & BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED ) ||
173
+ !bp -> shutdown_thresh_temp )
174
+ return 0 ;
175
+
176
+ return attr -> mode ;
177
+ }
178
+
179
+ static const struct attribute_group bnxt_temp_extra_group = {
180
+ .attrs = bnxt_temp_extra_attrs ,
181
+ .is_visible = bnxt_temp_extra_attrs_visible ,
182
+ };
183
+ __ATTRIBUTE_GROUPS (bnxt_temp_extra );
184
+
134
185
void bnxt_hwmon_uninit (struct bnxt * bp )
135
186
{
136
187
if (bp -> hwmon_dev ) {
@@ -156,7 +207,8 @@ void bnxt_hwmon_init(struct bnxt *bp)
156
207
157
208
bp -> hwmon_dev = hwmon_device_register_with_info (& pdev -> dev ,
158
209
DRV_MODULE_NAME , bp ,
159
- & bnxt_hwmon_chip_info , NULL );
210
+ & bnxt_hwmon_chip_info ,
211
+ bnxt_temp_extra_groups );
160
212
if (IS_ERR (bp -> hwmon_dev )) {
161
213
bp -> hwmon_dev = NULL ;
162
214
dev_warn (& pdev -> dev , "Cannot register hwmon device\n" );
0 commit comments