From 36c53b3cc3fac6952af68f43609b15ae050c9318 Mon Sep 17 00:00:00 2001 From: Federico Vaga Date: Tue, 2 Sep 2014 17:31:40 +0200 Subject: ipack: save carrier owner to allow device to get it There was not any kind of protection against carrier driver removal. In this way, device driver can 'get' the carrier driver when it is using it. Signed-off-by: Federico Vaga Acked-by: Samuel Iglesias Gonsalvez Signed-off-by: Greg Kroah-Hartman --- include/linux/ipack.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'include/linux/ipack.h') diff --git a/include/linux/ipack.h b/include/linux/ipack.h index 1888e06ddf64..8bddc3fbdddf 100644 --- a/include/linux/ipack.h +++ b/include/linux/ipack.h @@ -172,6 +172,7 @@ struct ipack_bus_ops { * @ops: bus operations for the mezzanine drivers */ struct ipack_bus_device { + struct module *owner; struct device *parent; int slots; int bus_nr; @@ -189,7 +190,8 @@ struct ipack_bus_device { * available bus device in ipack. */ struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots, - const struct ipack_bus_ops *ops); + const struct ipack_bus_ops *ops, + struct module *owner); /** * ipack_bus_unregister -- unregister an ipack bus @@ -265,3 +267,23 @@ void ipack_put_device(struct ipack_device *dev); .format = (_format), \ .vendor = (vend), \ .device = (dev) + +/** + * ipack_get_carrier - it increase the carrier ref. counter of + * the carrier module + * @dev: mezzanine device which wants to get the carrier + */ +static inline int ipack_get_carrier(struct ipack_device *dev) +{ + return try_module_get(dev->bus->owner); +} + +/** + * ipack_get_carrier - it decrease the carrier ref. counter of + * the carrier module + * @dev: mezzanine device which wants to get the carrier + */ +static inline void ipack_put_carrier(struct ipack_device *dev) +{ + module_put(dev->bus->owner); +} -- cgit v1.2.3-59-g8ed1b