All of lore.kernel.org
 help / color / mirror / Atom feed
* IPACK - ipack and ipoctal improvements
@ 2014-09-02 15:31 Federico Vaga
  2014-09-02 15:31 ` [PATCH 1/3] ipoctal: reset function istead of duplicate code Federico Vaga
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Federico Vaga @ 2014-09-02 15:31 UTC (permalink / raw)
  To: Samuel Iglesias Gonsalvez, Jens Taprogge, Greg Kroah-Hartman
  Cc: industrypack-devel, linux-kernel

I tested these patches only on kernel 3.2 and 3.6 because I cannot easly
test them on the next branch. I think that there are not important
modification in the kernel that can affect the behave of these patches.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] ipoctal: reset function istead of duplicate code
  2014-09-02 15:31 IPACK - ipack and ipoctal improvements Federico Vaga
@ 2014-09-02 15:31 ` Federico Vaga
  2014-09-03  7:52   ` Samuel Iglesias Gonsálvez
  2014-09-02 15:31 ` [PATCH 2/3] ipack: save carrier owner to allow device to get it Federico Vaga
  2014-09-02 15:31 ` [PATCH 3/3] ipoctal: get carrier driver to avoid rmmod Federico Vaga
  2 siblings, 1 reply; 7+ messages in thread
From: Federico Vaga @ 2014-09-02 15:31 UTC (permalink / raw)
  To: Samuel Iglesias Gonsalvez, Jens Taprogge, Greg Kroah-Hartman
  Cc: industrypack-devel, linux-kernel, Federico Vaga

Signed-off-by: Federico Vaga <federico.vaga@cern.ch>
---
 drivers/ipack/devices/ipoctal.c |   35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index 90b96a1b..e531379 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -55,6 +55,16 @@ struct ipoctal {
 	u8 __iomem			*int_space;
 };
 
+static void ipoctal_reset_channel(struct ipoctal_channel *channel)
+{
+	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
+	channel->rx_enable = 0;
+	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
+	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
+	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
+	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
+}
+
 static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
 {
 	struct ipoctal_channel *channel;
@@ -306,10 +316,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
 			channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A;
 		}
 
-		iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
-		channel->rx_enable = 0;
-		iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
-		iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
+		ipoctal_reset_channel(channel);
 		iowrite8(MR1_CHRL_8_BITS | MR1_ERROR_CHAR | MR1_RxINT_RxRDY,
 			 &channel->regs->w.mr); /* mr1 */
 		iowrite8(0, &channel->regs->w.mr); /* mr2 */
@@ -469,11 +476,7 @@ static void ipoctal_set_termios(struct tty_struct *tty,
 	cflag = tty->termios.c_cflag;
 
 	/* Disable and reset everything before change the setup */
-	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
+	ipoctal_reset_channel(channel);
 
 	/* Set Bits per chars */
 	switch (cflag & CSIZE) {
@@ -611,12 +614,7 @@ static void ipoctal_hangup(struct tty_struct *tty)
 
 	tty_port_hangup(&channel->tty_port);
 
-	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
-	channel->rx_enable = 0;
-	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
+	ipoctal_reset_channel(channel);
 
 	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
 	wake_up_interruptible(&channel->tty_port.open_wait);
@@ -629,12 +627,7 @@ static void ipoctal_shutdown(struct tty_struct *tty)
 	if (channel == NULL)
 		return;
 
-	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
-	channel->rx_enable = 0;
-	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
-	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
+	ipoctal_reset_channel(channel);
 	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] ipack: save carrier owner to allow device to get it
  2014-09-02 15:31 IPACK - ipack and ipoctal improvements Federico Vaga
  2014-09-02 15:31 ` [PATCH 1/3] ipoctal: reset function istead of duplicate code Federico Vaga
@ 2014-09-02 15:31 ` Federico Vaga
  2014-09-03  7:52   ` Samuel Iglesias Gonsálvez
  2014-09-02 15:31 ` [PATCH 3/3] ipoctal: get carrier driver to avoid rmmod Federico Vaga
  2 siblings, 1 reply; 7+ messages in thread
From: Federico Vaga @ 2014-09-02 15:31 UTC (permalink / raw)
  To: Samuel Iglesias Gonsalvez, Jens Taprogge, Greg Kroah-Hartman
  Cc: industrypack-devel, linux-kernel, Federico Vaga

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 <federico.vaga@cern.ch>
---
 drivers/ipack/carriers/tpci200.c |    3 ++-
 drivers/ipack/ipack.c            |    4 +++-
 include/linux/ipack.h            |   24 +++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c
index de5e321..9b23843 100644
--- a/drivers/ipack/carriers/tpci200.c
+++ b/drivers/ipack/carriers/tpci200.c
@@ -572,7 +572,8 @@ static int tpci200_pci_probe(struct pci_dev *pdev,
 	/* Register the carrier in the industry pack bus driver */
 	tpci200->info->ipack_bus = ipack_bus_register(&pdev->dev,
 						      TPCI200_NB_SLOT,
-						      &tpci200_bus_ops);
+						      &tpci200_bus_ops,
+						      THIS_MODULE);
 	if (!tpci200->info->ipack_bus) {
 		dev_err(&pdev->dev,
 			"error registering the carrier on ipack driver\n");
diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c
index d0016ba..c0e7b62 100644
--- a/drivers/ipack/ipack.c
+++ b/drivers/ipack/ipack.c
@@ -206,7 +206,8 @@ static struct bus_type ipack_bus_type = {
 };
 
 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)
 {
 	int bus_nr;
 	struct ipack_bus_device *bus;
@@ -225,6 +226,7 @@ struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
 	bus->parent = parent;
 	bus->slots = slots;
 	bus->ops = ops;
+	bus->owner = owner;
 	return bus;
 }
 EXPORT_SYMBOL_GPL(ipack_bus_register);
diff --git a/include/linux/ipack.h b/include/linux/ipack.h
index 1888e06..8bddc3f 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);
+}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ipoctal: get carrier driver to avoid rmmod
  2014-09-02 15:31 IPACK - ipack and ipoctal improvements Federico Vaga
  2014-09-02 15:31 ` [PATCH 1/3] ipoctal: reset function istead of duplicate code Federico Vaga
  2014-09-02 15:31 ` [PATCH 2/3] ipack: save carrier owner to allow device to get it Federico Vaga
@ 2014-09-02 15:31 ` Federico Vaga
  2014-09-03  7:53   ` Samuel Iglesias Gonsálvez
  2 siblings, 1 reply; 7+ messages in thread
From: Federico Vaga @ 2014-09-02 15:31 UTC (permalink / raw)
  To: Samuel Iglesias Gonsalvez, Jens Taprogge, Greg Kroah-Hartman
  Cc: industrypack-devel, linux-kernel, Federico Vaga

Signed-off-by: Federico Vaga <federico.vaga@cern.ch>
---
 drivers/ipack/devices/ipoctal.c |   30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index e531379..035d544 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -55,6 +55,12 @@ struct ipoctal {
 	u8 __iomem			*int_space;
 };
 
+static inline struct ipoctal *chan_to_ipoctal(struct ipoctal_channel *chan,
+					      unsigned int index)
+{
+	return container_of(chan, struct ipoctal, channel[index]);
+}
+
 static void ipoctal_reset_channel(struct ipoctal_channel *channel)
 {
 	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
@@ -82,12 +88,20 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
 
 static int ipoctal_open(struct tty_struct *tty, struct file *file)
 {
-	struct ipoctal_channel *channel;
+	struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
+	struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
+	int err;
 
-	channel = dev_get_drvdata(tty->dev);
 	tty->driver_data = channel;
 
-	return tty_port_open(&channel->tty_port, tty, file);
+	if (!ipack_get_carrier(ipoctal->dev))
+		return -EBUSY;
+
+	err = tty_port_open(&channel->tty_port, tty, file);
+	if (err)
+		ipack_put_carrier(ipoctal->dev);
+
+	return err;
 }
 
 static void ipoctal_reset_stats(struct ipoctal_stats *stats)
@@ -631,6 +645,15 @@ static void ipoctal_shutdown(struct tty_struct *tty)
 	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
 }
 
+static void ipoctal_cleanup(struct tty_struct *tty)
+{
+	struct ipoctal_channel *channel = tty->driver_data;
+	struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
+
+	/* release the carrier driver */
+	ipack_put_carrier(ipoctal->dev);
+}
+
 static const struct tty_operations ipoctal_fops = {
 	.ioctl =		NULL,
 	.open =			ipoctal_open,
@@ -642,6 +665,7 @@ static const struct tty_operations ipoctal_fops = {
 	.get_icount =		ipoctal_get_icount,
 	.hangup =		ipoctal_hangup,
 	.shutdown =		ipoctal_shutdown,
+	.cleanup =              ipoctal_cleanup,
 };
 
 static int ipoctal_probe(struct ipack_device *dev)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] ipoctal: reset function istead of duplicate code
  2014-09-02 15:31 ` [PATCH 1/3] ipoctal: reset function istead of duplicate code Federico Vaga
@ 2014-09-03  7:52   ` Samuel Iglesias Gonsálvez
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Iglesias Gonsálvez @ 2014-09-03  7:52 UTC (permalink / raw)
  To: Federico Vaga
  Cc: Jens Taprogge, Greg Kroah-Hartman, industrypack-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3458 bytes --]

On Tue, 2014-09-02 at 17:31 +0200, Federico Vaga wrote:
> Signed-off-by: Federico Vaga <federico.vaga@cern.ch>
> ---
>  drivers/ipack/devices/ipoctal.c |   35 ++++++++++++++---------------------
>  1 file changed, 14 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
> index 90b96a1b..e531379 100644
> --- a/drivers/ipack/devices/ipoctal.c
> +++ b/drivers/ipack/devices/ipoctal.c
> @@ -55,6 +55,16 @@ struct ipoctal {
>  	u8 __iomem			*int_space;
>  };
>  
> +static void ipoctal_reset_channel(struct ipoctal_channel *channel)
> +{
> +	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
> +	channel->rx_enable = 0;
> +	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
> +	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
> +	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
> +	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
> +}
> +
>  static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
>  {
>  	struct ipoctal_channel *channel;
> @@ -306,10 +316,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
>  			channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A;
>  		}
>  
> -		iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
> -		channel->rx_enable = 0;
> -		iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
> -		iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
> +		ipoctal_reset_channel(channel);
>  		iowrite8(MR1_CHRL_8_BITS | MR1_ERROR_CHAR | MR1_RxINT_RxRDY,
>  			 &channel->regs->w.mr); /* mr1 */
>  		iowrite8(0, &channel->regs->w.mr); /* mr2 */
> @@ -469,11 +476,7 @@ static void ipoctal_set_termios(struct tty_struct *tty,
>  	cflag = tty->termios.c_cflag;
>  
>  	/* Disable and reset everything before change the setup */
> -	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
> +	ipoctal_reset_channel(channel);
>  
>  	/* Set Bits per chars */
>  	switch (cflag & CSIZE) {
> @@ -611,12 +614,7 @@ static void ipoctal_hangup(struct tty_struct *tty)
>  
>  	tty_port_hangup(&channel->tty_port);
>  
> -	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
> -	channel->rx_enable = 0;
> -	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
> +	ipoctal_reset_channel(channel);
>  
>  	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
>  	wake_up_interruptible(&channel->tty_port.open_wait);
> @@ -629,12 +627,7 @@ static void ipoctal_shutdown(struct tty_struct *tty)
>  	if (channel == NULL)
>  		return;
>  
> -	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
> -	channel->rx_enable = 0;
> -	iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
> -	iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
> +	ipoctal_reset_channel(channel);
>  	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
>  }
>  

Acked-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>

Sam



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] ipack: save carrier owner to allow device to get it
  2014-09-02 15:31 ` [PATCH 2/3] ipack: save carrier owner to allow device to get it Federico Vaga
@ 2014-09-03  7:52   ` Samuel Iglesias Gonsálvez
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Iglesias Gonsálvez @ 2014-09-03  7:52 UTC (permalink / raw)
  To: Federico Vaga
  Cc: Jens Taprogge, Greg Kroah-Hartman, industrypack-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3532 bytes --]


On Tue, 2014-09-02 at 17:31 +0200, Federico Vaga wrote:
> 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 <federico.vaga@cern.ch>
> ---
>  drivers/ipack/carriers/tpci200.c |    3 ++-
>  drivers/ipack/ipack.c            |    4 +++-
>  include/linux/ipack.h            |   24 +++++++++++++++++++++++-
>  3 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c
> index de5e321..9b23843 100644
> --- a/drivers/ipack/carriers/tpci200.c
> +++ b/drivers/ipack/carriers/tpci200.c
> @@ -572,7 +572,8 @@ static int tpci200_pci_probe(struct pci_dev *pdev,
>  	/* Register the carrier in the industry pack bus driver */
>  	tpci200->info->ipack_bus = ipack_bus_register(&pdev->dev,
>  						      TPCI200_NB_SLOT,
> -						      &tpci200_bus_ops);
> +						      &tpci200_bus_ops,
> +						      THIS_MODULE);
>  	if (!tpci200->info->ipack_bus) {
>  		dev_err(&pdev->dev,
>  			"error registering the carrier on ipack driver\n");
> diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c
> index d0016ba..c0e7b62 100644
> --- a/drivers/ipack/ipack.c
> +++ b/drivers/ipack/ipack.c
> @@ -206,7 +206,8 @@ static struct bus_type ipack_bus_type = {
>  };
>  
>  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)
>  {
>  	int bus_nr;
>  	struct ipack_bus_device *bus;
> @@ -225,6 +226,7 @@ struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
>  	bus->parent = parent;
>  	bus->slots = slots;
>  	bus->ops = ops;
> +	bus->owner = owner;
>  	return bus;
>  }
>  EXPORT_SYMBOL_GPL(ipack_bus_register);
> diff --git a/include/linux/ipack.h b/include/linux/ipack.h
> index 1888e06..8bddc3f 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);
> +}

Acked-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>

Sam


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] ipoctal: get carrier driver to avoid rmmod
  2014-09-02 15:31 ` [PATCH 3/3] ipoctal: get carrier driver to avoid rmmod Federico Vaga
@ 2014-09-03  7:53   ` Samuel Iglesias Gonsálvez
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Iglesias Gonsálvez @ 2014-09-03  7:53 UTC (permalink / raw)
  To: Federico Vaga
  Cc: Jens Taprogge, Greg Kroah-Hartman, industrypack-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2627 bytes --]


On Tue, 2014-09-02 at 17:31 +0200, Federico Vaga wrote:
> Signed-off-by: Federico Vaga <federico.vaga@cern.ch>
> ---
>  drivers/ipack/devices/ipoctal.c |   30 +++++++++++++++++++++++++++---
>  1 file changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
> index e531379..035d544 100644
> --- a/drivers/ipack/devices/ipoctal.c
> +++ b/drivers/ipack/devices/ipoctal.c
> @@ -55,6 +55,12 @@ struct ipoctal {
>  	u8 __iomem			*int_space;
>  };
>  
> +static inline struct ipoctal *chan_to_ipoctal(struct ipoctal_channel *chan,
> +					      unsigned int index)
> +{
> +	return container_of(chan, struct ipoctal, channel[index]);
> +}
> +
>  static void ipoctal_reset_channel(struct ipoctal_channel *channel)
>  {
>  	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
> @@ -82,12 +88,20 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
>  
>  static int ipoctal_open(struct tty_struct *tty, struct file *file)
>  {
> -	struct ipoctal_channel *channel;
> +	struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
> +	struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
> +	int err;
>  
> -	channel = dev_get_drvdata(tty->dev);
>  	tty->driver_data = channel;
>  
> -	return tty_port_open(&channel->tty_port, tty, file);
> +	if (!ipack_get_carrier(ipoctal->dev))
> +		return -EBUSY;
> +
> +	err = tty_port_open(&channel->tty_port, tty, file);
> +	if (err)
> +		ipack_put_carrier(ipoctal->dev);
> +
> +	return err;
>  }
>  
>  static void ipoctal_reset_stats(struct ipoctal_stats *stats)
> @@ -631,6 +645,15 @@ static void ipoctal_shutdown(struct tty_struct *tty)
>  	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
>  }
>  
> +static void ipoctal_cleanup(struct tty_struct *tty)
> +{
> +	struct ipoctal_channel *channel = tty->driver_data;
> +	struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
> +
> +	/* release the carrier driver */
> +	ipack_put_carrier(ipoctal->dev);
> +}
> +
>  static const struct tty_operations ipoctal_fops = {
>  	.ioctl =		NULL,
>  	.open =			ipoctal_open,
> @@ -642,6 +665,7 @@ static const struct tty_operations ipoctal_fops = {
>  	.get_icount =		ipoctal_get_icount,
>  	.hangup =		ipoctal_hangup,
>  	.shutdown =		ipoctal_shutdown,
> +	.cleanup =              ipoctal_cleanup,
>  };
>  
>  static int ipoctal_probe(struct ipack_device *dev)

Acked-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>

Greg, Can you this series through your char-misc tree?

Sam



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-03  7:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 15:31 IPACK - ipack and ipoctal improvements Federico Vaga
2014-09-02 15:31 ` [PATCH 1/3] ipoctal: reset function istead of duplicate code Federico Vaga
2014-09-03  7:52   ` Samuel Iglesias Gonsálvez
2014-09-02 15:31 ` [PATCH 2/3] ipack: save carrier owner to allow device to get it Federico Vaga
2014-09-03  7:52   ` Samuel Iglesias Gonsálvez
2014-09-02 15:31 ` [PATCH 3/3] ipoctal: get carrier driver to avoid rmmod Federico Vaga
2014-09-03  7:53   ` Samuel Iglesias Gonsálvez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.