4086 } else if (evt.erase == 0xfe) {
4087 gdth_clear_events();
4088 } else if (evt.erase == 0) {
4089 evt.handle = gdth_read_event(ha, evt.handle, &evt.event);
4090 } else {
4091 gdth_readapp_event(ha, evt.erase, &evt.event);
4092 }
4093 if (copy_to_user(arg, &evt, sizeof(gdth_ioctl_event)))
4094 return -EFAULT;
4095 return 0;
4096}
4097
4098static int ioc_lockdrv(void __user *arg)
4099{
4100 gdth_ioctl_lockdrv ldrv;
4101 unchar i, j;
4102 ulong flags;
4103 gdth_ha_str *ha;
4104
4105 if (copy_from_user(&ldrv, arg, sizeof(gdth_ioctl_lockdrv)))
4106 return -EFAULT;
4107 ha = gdth_find_ha(ldrv.ionode);
4108 if (!ha)
4109 return -EFAULT;
4110
4111 for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) {
4112 j = ldrv.drives[i];
4113 if (j >= MAX_HDRIVES || !ha->hdr[j].present)
4114 continue;
4115 if (ldrv.lock) {
4116 spin_lock_irqsave(&ha->smp_lock, flags);
4117 ha->hdr[j].lock = 1;
4118 spin_unlock_irqrestore(&ha->smp_lock, flags);
4119 gdth_wait_completion(ha, ha->bus_cnt, j);
4120 } else {
4121 spin_lock_irqsave(&ha->smp_lock, flags);
4122 ha->hdr[j].lock = 0;
4123 spin_unlock_irqrestore(&ha->smp_lock, flags);
4124 gdth_next(ha);
4125 }
4126 }