On Tue, May 5, 2009 at 1:16 PM, Pavel Machek <pavel@xxxxxx> wrote: > On Tue 2009-05-05 21:18:42, Arve Hj??nnev??g wrote: >> Add a misc device, "suspend_blocker", that allows user-space processes >> to block auto suspend. The device has ioctls to create a suspend_blocker, >> and to block and unblock suspend. To delete the suspend_blocker, close >> the device. >> > >> +static int create_user_suspend_blocker(struct file *file, void __user *name, >> + size_t name_len) >> +{ >> + struct user_suspend_blocker *bl; >> + if (file->private_data) >> + return -EBUSY; >> + bl = kzalloc(sizeof(*bl) + name_len + 1, GFP_KERNEL); > ... >> +static long user_suspend_blocker_ioctl(struct file *file, unsigned int cmd, >> + unsigned long _arg) >> +{ >> + void __user *arg = (void __user *)_arg; >> + struct user_suspend_blocker *bl; >> + long ret; >> + >> + mutex_lock(&ioctl_lock); >> + if ((cmd & ~IOCSIZE_MASK) == SUSPEND_BLOCKER_IOCTL_INIT(0)) { >> + ret = create_user_suspend_blocker(file, arg, _IOC_SIZE(cmd)); >> + goto done; >> + } > > Wait a moment, wtf is this? Not one ioctl but one ioctl per length of > string?! This is not uncommon. _IOC encodes the size of the argument, and if this is not a fixed size, then the raw ioctl number change based on the size passed in. Look at input.h is you want other examples of this. -- Arve Hjønnevåg _______________________________________________ linux-pm mailing list linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/linux-pm