All fine, except one: you must release semaphore1 before second return:
if(down_interruptible(&semaphore1))
return -ERESTARTSYS;
if(down_interruptible(&semaphore2)) {
up(&semaphore1);
return -ERESTARTSYS;
}
critical code here!
up(&semaphore2);
up(&semaphore1);
Description about usage ERESTARTSYS see the answer.
In general, down_interruptible could be interrupted by signal to userspace application. Returning ERESTARTSYS you tell the kernel to handle signal and to call driver again. Unless you release semaphore1 second call to driver would block on semaphore1.