mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-30 05:06:44 +07:00
parport: check exclusive access before register
As of now we were starting the registration process and after the device is registered we were checking if the device can be used by the parport. Now lets check it first so that we do not need to go through the registration process only to fail at the end. The original exclusive access check at the end is still there so that we do not get any surprises if two different process registers its device with same parport and with exclusive access at the same time. Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0c6d5c89a1
commit
50566ac870
@ -708,6 +708,20 @@ parport_register_device(struct parport *port, const char *name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & PARPORT_DEV_EXCL) {
|
||||||
|
if (port->physport->devices) {
|
||||||
|
/*
|
||||||
|
* If a device is already registered and this new
|
||||||
|
* device wants exclusive access, then no need to
|
||||||
|
* continue as we can not grant exclusive access to
|
||||||
|
* this device.
|
||||||
|
*/
|
||||||
|
pr_err("%s: cannot grant exclusive access for device %s\n",
|
||||||
|
port->name, name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* We up our own module reference count, and that of the port
|
/* We up our own module reference count, and that of the port
|
||||||
on which a device is to be registered, to ensure that
|
on which a device is to be registered, to ensure that
|
||||||
neither of us gets unloaded while we sleep in (e.g.)
|
neither of us gets unloaded while we sleep in (e.g.)
|
||||||
@ -827,6 +841,20 @@ parport_register_dev_model(struct parport *port, const char *name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (par_dev_cb->flags & PARPORT_DEV_EXCL) {
|
||||||
|
if (port->physport->devices) {
|
||||||
|
/*
|
||||||
|
* If a device is already registered and this new
|
||||||
|
* device wants exclusive access, then no need to
|
||||||
|
* continue as we can not grant exclusive access to
|
||||||
|
* this device.
|
||||||
|
*/
|
||||||
|
pr_err("%s: cannot grant exclusive access for device %s\n",
|
||||||
|
port->name, name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!try_module_get(port->ops->owner))
|
if (!try_module_get(port->ops->owner))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user