Skip to contentSkip to conversation

PMU: replace information ioctls and schedule for removal

RFC Superseded Johannes Berg 3 participants 5 messages Nov 8, 2007 – Nov 13, 2007

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC 1/1 PMU: replace information ioctls and schedule for removal

This patch adds sysfs attributes to the PMU to allow getting the information on the PMU type and whether adb is present from there instead of via the ioctl. The ioctl is made optional and scheduled for removal.

Cc Benjamin Herrenschmidt <[email protected]>
---
 Documentation/feature-removal-schedule.txt |    8 ++++++
 drivers/macintosh/Kconfig                  |   11 ++++++++
 drivers/macintosh/via-pmu.c                |   36 +++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)
drivers/macintosh/via-pmu.c +36 -0
@@ -2533,10 +2533,12 @@ pmu_ioctl(struct inode * inode, struct f
 #endif /* CONFIG_INPUT_ADBHID */
 #endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */
 
+#ifdef CONFIG_DEPRECATED_PMU_INFO_IOCTLS
 	case PMU_IOC_GET_MODEL:
 	    	return put_user(pmu_kind, argp);
 	case PMU_IOC_HAS_ADB:
 		return put_user(pmu_has_adb, argp);
+#endif
 	}
 	return error;
 }
@@ -2680,6 +2682,39 @@ static int pmu_sys_resume(struct sys_dev
 
 #endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
 
+static ssize_t show_kind(struct sys_device *sysdev, char *buf)
+{
+	return sprintf(buf, "%d\n", pmu_kind);
+}
+
+static ssize_t show_has_adb(struct sys_device *sysdev, char *buf)
+{
+	return sprintf(buf, "%d\n", pmu_has_adb);
+}
+
+static SYSDEV_ATTR(kind, 0444, show_kind, NULL);
+static SYSDEV_ATTR(has_adb, 0444, show_has_adb, NULL);
+
+int pmu_sys_add(struct sys_device *sysdev)
+{
+	int err;
+
+	err = sysdev_create_file(sysdev, &attr_kind);
+	if (err)
+		goto out;
+
+	err = sysdev_create_file(sysdev, &attr_has_adb);
+	if (err)
+		goto out_remove_kind;
+
+	return 0;
+
+ out_remove_kind:
+	sysdev_remove_file(sysdev, &attr_kind);
+ out:
+	return err;
+}
+
 static struct sysdev_class pmu_sysclass = {
 	set_kset_name("pmu"),
 };
@@ -2693,6 +2728,7 @@ static struct sysdev_driver driver_pmu =
 	.suspend	= &pmu_sys_suspend,
 	.resume		= &pmu_sys_resume,
 #endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+	.add		= &pmu_sys_add,
 };
 
 static int __init init_pmu_sysfs(void)
Documentation/feature-removal-schedule.txt +8 -0
@@ -342,3 +342,11 @@ Why:	This driver has been marked obsolet
 Who:	Stephen Hemminger <[email protected]>
 
 ---------------------------
+
+What:	/dev/pmu information ioctls
+When:	January 2010
+Files:	drivers/macintosh/via-pmu.c
+Why:	The PMU information can be obtained from sysfs now.
+Who:	Johannes Berg <[email protected]>
+
+---------------------------
drivers/macintosh/Kconfig +11 -0
@@ -87,6 +87,17 @@ config ADB_PMU
 	  this device; you should do so if your machine is one of those
 	  mentioned above.
 
+config DEPRECATED_PMU_INFO_IOCTLS
+	bool "Support deprecated PMU information ioctl"
+	depends on ADB_PMU
+	default y
+	help
+	  The PMU ioctl supports getting information on the type of PMU and
+	  whether an ADB is present. This information is also available in
+	  sysfs so this ioctl is no longer needed.
+
+	  If in doubt, say Y even if you will not use the ioctl.
+
 config ADB_PMU_LED
 	bool "Support for the Power/iBook front LED"
 	depends on ADB_PMU
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Johannes Berg

This patch adds sysfs attributes to the PMU to allow getting the information on the PMU type and whether adb is present from there instead of via the ioctl. The ioctl is made optional and scheduled for removal.

---

While there, maybe also expose the PMU version ?

Quoted 106 lines
Cc Benjamin Herrenschmidt <[email protected]>
---
 Documentation/feature-removal-schedule.txt |    8 ++++++
 drivers/macintosh/Kconfig                  |   11 ++++++++
 drivers/macintosh/via-pmu.c                |   36 +++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)
drivers/macintosh/via-pmu.c +36 -0
@@ -2533,10 +2533,12 @@ pmu_ioctl(struct inode * inode, struct f
 #endif /* CONFIG_INPUT_ADBHID */
 #endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */
 
+#ifdef CONFIG_DEPRECATED_PMU_INFO_IOCTLS
 	case PMU_IOC_GET_MODEL:
 	    	return put_user(pmu_kind, argp);
 	case PMU_IOC_HAS_ADB:
 		return put_user(pmu_has_adb, argp);
+#endif
 	}
 	return error;
 }
@@ -2680,6 +2682,39 @@ static int pmu_sys_resume(struct sys_dev
 
 #endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
 
+static ssize_t show_kind(struct sys_device *sysdev, char *buf)
+{
+	return sprintf(buf, "%d\n", pmu_kind);
+}
+
+static ssize_t show_has_adb(struct sys_device *sysdev, char *buf)
+{
+	return sprintf(buf, "%d\n", pmu_has_adb);
+}
+
+static SYSDEV_ATTR(kind, 0444, show_kind, NULL);
+static SYSDEV_ATTR(has_adb, 0444, show_has_adb, NULL);
+
+int pmu_sys_add(struct sys_device *sysdev)
+{
+	int err;
+
+	err = sysdev_create_file(sysdev, &attr_kind);
+	if (err)
+		goto out;
+
+	err = sysdev_create_file(sysdev, &attr_has_adb);
+	if (err)
+		goto out_remove_kind;
+
+	return 0;
+
+ out_remove_kind:
+	sysdev_remove_file(sysdev, &attr_kind);
+ out:
+	return err;
+}
+
 static struct sysdev_class pmu_sysclass = {
 	set_kset_name("pmu"),
 };
@@ -2693,6 +2728,7 @@ static struct sysdev_driver driver_pmu =
 	.suspend	= &pmu_sys_suspend,
 	.resume		= &pmu_sys_resume,
 #endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+	.add		= &pmu_sys_add,
 };
 
 static int __init init_pmu_sysfs(void)
Documentation/feature-removal-schedule.txt +8 -0
@@ -342,3 +342,11 @@ Why:	This driver has been marked obsolet
 Who:	Stephen Hemminger <[email protected]>
 
 ---------------------------
+
+What:	/dev/pmu information ioctls
+When:	January 2010
+Files:	drivers/macintosh/via-pmu.c
+Why:	The PMU information can be obtained from sysfs now.
+Who:	Johannes Berg <[email protected]>
+
+---------------------------
drivers/macintosh/Kconfig +11 -0
@@ -87,6 +87,17 @@ config ADB_PMU
 	  this device; you should do so if your machine is one of those
 	  mentioned above.
 
+config DEPRECATED_PMU_INFO_IOCTLS
+	bool "Support deprecated PMU information ioctl"
+	depends on ADB_PMU
+	default y
+	help
+	  The PMU ioctl supports getting information on the type of PMU and
+	  whether an ADB is present. This information is also available in
+	  sysfs so this ioctl is no longer needed.
+
+	  If in doubt, say Y even if you will not use the ioctl.
+
 config ADB_PMU_LED
 	bool "Support for the Power/iBook front LED"
 	depends on ADB_PMU
#2 lore raw
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 4 lines · Johannes Berg

This patch adds sysfs attributes to the PMU to allow getting the information on the PMU type and whether adb is present from there instead of via the ioctl. The ioctl is made optional and scheduled for removal.

---

While there, maybe also expose the PMU version ?

Does anybody need that? I'm not against adding it but we never showed it and I haven't seen anyone ask for it.

johannes

#3 lore raw
Quoted 2 lines · Johannes Berg

Does anybody need that? I'm not against adding it but we never showed it and I haven't seen anyone ask for it.

pmud uses the PMU version, but I think it gets it by issuing a PMU command.

Paul.

#4 lore raw
Quoted 7 lines · Paul Mackerras
Quoted 2 lines · Johannes Berg

Does anybody need that? I'm not against adding it but we never showed it and I haven't seen anyone ask for it.

pmud uses the PMU version, but I think it gets it by issuing a PMU command.

Yeah, it probably has to since I don't see us exporting it anywhere. Do we want to change pmud to read it from elsewhere? I guess I'll just add it to sysfs and it can use it if it wants.

johannes