acpi: Add a function to deregister all ioctl commands using the same function
This simplifies detach/cleanup for drivers that add multiple ACPI ioctls. Reviewed by: imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D54420
This commit is contained in:
@@ -4334,6 +4334,21 @@ acpi_deregister_ioctl(u_long cmd, acpi_ioctl_fn fn)
|
||||
ACPI_UNLOCK(acpi);
|
||||
}
|
||||
|
||||
void
|
||||
acpi_deregister_ioctls(acpi_ioctl_fn fn)
|
||||
{
|
||||
struct acpi_ioctl_hook *hp, *thp;
|
||||
|
||||
ACPI_LOCK(acpi);
|
||||
TAILQ_FOREACH_SAFE(hp, &acpi_ioctl_hooks, link, thp) {
|
||||
if (hp->fn == fn) {
|
||||
TAILQ_REMOVE(&acpi_ioctl_hooks, hp, link);
|
||||
free(hp, M_ACPIDEV);
|
||||
}
|
||||
}
|
||||
ACPI_UNLOCK(acpi);
|
||||
}
|
||||
|
||||
static int
|
||||
acpiopen(struct cdev *dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
|
||||
@@ -531,13 +531,7 @@ acpi_battery_init(void)
|
||||
|
||||
out:
|
||||
if (error) {
|
||||
acpi_deregister_ioctl(ACPIIO_BATT_GET_UNITS, acpi_battery_ioctl);
|
||||
acpi_deregister_ioctl(ACPIIO_BATT_GET_BATTINFO, acpi_battery_ioctl);
|
||||
acpi_deregister_ioctl(ACPIIO_BATT_GET_BATTINFO_V1, acpi_battery_ioctl);
|
||||
acpi_deregister_ioctl(ACPIIO_BATT_GET_BIF, acpi_battery_ioctl);
|
||||
acpi_deregister_ioctl(ACPIIO_BATT_GET_BIX, acpi_battery_ioctl);
|
||||
acpi_deregister_ioctl(ACPIIO_BATT_GET_BST, acpi_battery_ioctl);
|
||||
acpi_deregister_ioctl(ACPIIO_BATT_GET_BST_V1, acpi_battery_ioctl);
|
||||
acpi_deregister_ioctls(acpi_battery_ioctl);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
@@ -205,6 +205,7 @@ union acpi_battery_ioctl_arg {
|
||||
typedef int (*acpi_ioctl_fn)(u_long cmd, caddr_t addr, void *arg);
|
||||
extern int acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg);
|
||||
extern void acpi_deregister_ioctl(u_long cmd, acpi_ioctl_fn fn);
|
||||
extern void acpi_deregister_ioctls(acpi_ioctl_fn fn);
|
||||
#endif
|
||||
|
||||
#endif /* !_ACPIIO_H_ */
|
||||
|
||||
Reference in New Issue
Block a user