Skip to contentSkip to conversation

sfc: Convert to use hwmon_device_register_with_groups

PATCH Superseded Guenter Roeck 2 participants 3 messages Nov 27, 2013 – Nov 28, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sfc: Convert to use hwmon_device_register_with_groups

Simplify the code. Avoid race conditions caused by attributes being created after hwmon device registration. Implicitly (through hwmon API) add mandatory 'name' sysfs attribute.

---
Compile tested only.

 drivers/net/ethernet/sfc/mcdi.h     |    2 +
 drivers/net/ethernet/sfc/mcdi_mon.c |   76 +++++++++++++----------------------
 2 files changed, 31 insertions(+), 47 deletions(-)
drivers/net/ethernet/sfc/mcdi.h +2 -0
index 656a327..15816ca 100644
@@ -75,6 +75,8 @@ struct efx_mcdi_mon {
 	unsigned long last_update;
 	struct device *device;
 	struct efx_mcdi_mon_attribute *attrs;
+	struct attribute_group group;
+	const struct attribute_group *groups[2];
 	unsigned int n_attrs;
 };
 
drivers/net/ethernet/sfc/mcdi_mon.c +29 -47

173 lines not on this page · raw message

Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 7 lines · Guenter Roeck

Simplify the code. Avoid race conditions caused by attributes being created after hwmon device registration. Implicitly (through hwmon API) add mandatory 'name' sysfs attribute.

---
Compile tested only.

[...]

Very close, but you missed this bit:

drivers/net/ethernet/sfc/mcdi_mon.c +1 -1
@@ -142,7 +142,7 @@ static int efx_mcdi_mon_update(struct efx_nic *efx)
 static int efx_mcdi_mon_get_entry(struct device *dev, unsigned int index,
 				  efx_dword_t *entry)
 {
-	struct efx_nic *efx = dev_get_drvdata(dev);
+	struct efx_nic *efx = dev_get_drvdata(dev->parent);
 	struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
 	int rc;
 

---

With that addition, it works for me, and you can add my Reviewed-by.

Ben.

Signature · 9 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
Quoted 25 lines · Ben Hutchings
Quoted 7 lines · Guenter Roeck

Simplify the code. Avoid race conditions caused by attributes being created after hwmon device registration. Implicitly (through hwmon API) add mandatory 'name' sysfs attribute.

---
Compile tested only.

[...]

Very close, but you missed this bit:

drivers/net/ethernet/sfc/mcdi_mon.c +1 -2
@@ -142,7 +142,7 @@ static int efx_mcdi_mon_update(struct efx_nic *efx)
  static int efx_mcdi_mon_get_entry(struct device *dev, unsigned int index,
  				  efx_dword_t *entry)
  {
-	struct efx_nic *efx = dev_get_drvdata(dev);
+	struct efx_nic *efx = dev_get_drvdata(dev->parent);
  	struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
  	int rc;
 
---
Quoted 2 lines

With that addition, it works for me, and you can add my Reviewed-by.

Thanks a lot!

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors