Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 254be490 authored by Hendrik Brueckner's avatar Hendrik Brueckner Committed by Benjamin Herrenschmidt
Browse files

hvc_console: Provide (un)locked version for hvc_resize()



Rename the locking free hvc_resize() function to __hvc_resize() and
provide an inline function that locks the hvc_struct and calls
__hvc_resize().

The rationale for this patch is that virtio_console calls the hvc_resize()
function without locking the hvc_struct. So it needs to call the lock
itself.

According to naming rules, the unlocked version is renamed and
prefixed with "__".
References to unlocked function calls in hvc back-ends has been updated.

Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Acked-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 94a8d5ca
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -678,7 +678,7 @@ int hvc_poll(struct hvc_struct *hp)
EXPORT_SYMBOL_GPL(hvc_poll);
EXPORT_SYMBOL_GPL(hvc_poll);


/**
/**
 * hvc_resize() - Update terminal window size information.
 * __hvc_resize() - Update terminal window size information.
 * @hp:		HVC console pointer
 * @hp:		HVC console pointer
 * @ws:		Terminal window size structure
 * @ws:		Terminal window size structure
 *
 *
@@ -687,12 +687,12 @@ EXPORT_SYMBOL_GPL(hvc_poll);
 *
 *
 * Locking:	Locking free; the function MUST be called holding hp->lock
 * Locking:	Locking free; the function MUST be called holding hp->lock
 */
 */
void hvc_resize(struct hvc_struct *hp, struct winsize ws)
void __hvc_resize(struct hvc_struct *hp, struct winsize ws)
{
{
	hp->ws = ws;
	hp->ws = ws;
	schedule_work(&hp->tty_resize);
	schedule_work(&hp->tty_resize);
}
}
EXPORT_SYMBOL_GPL(hvc_resize);
EXPORT_SYMBOL_GPL(__hvc_resize);


/*
/*
 * This kthread is either polling or interrupt driven.  This is determined by
 * This kthread is either polling or interrupt driven.  This is determined by
+11 −1
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@
#define HVC_CONSOLE_H
#define HVC_CONSOLE_H
#include <linux/kref.h>
#include <linux/kref.h>
#include <linux/tty.h>
#include <linux/tty.h>
#include <linux/spinlock.h>


/*
/*
 * This is the max number of console adapters that can/will be found as
 * This is the max number of console adapters that can/will be found as
@@ -88,7 +89,16 @@ int hvc_poll(struct hvc_struct *hp);
void hvc_kick(void);
void hvc_kick(void);


/* Resize hvc tty terminal window */
/* Resize hvc tty terminal window */
extern void hvc_resize(struct hvc_struct *hp, struct winsize ws);
extern void __hvc_resize(struct hvc_struct *hp, struct winsize ws);

static inline void hvc_resize(struct hvc_struct *hp, struct winsize ws)
{
	unsigned long flags;

	spin_lock_irqsave(&hp->lock, flags);
	__hvc_resize(hp, ws);
	spin_unlock_irqrestore(&hp->lock, flags);
}


/* default notifier for irq based notification */
/* default notifier for irq based notification */
extern int notifier_add_irq(struct hvc_struct *hp, int data);
extern int notifier_add_irq(struct hvc_struct *hp, int data);
+3 −1
Original line number Original line Diff line number Diff line
@@ -273,7 +273,9 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv,
	case MSG_TYPE_WINSIZE:
	case MSG_TYPE_WINSIZE:
		if (rb->mbuf->datalen != sizeof(struct winsize))
		if (rb->mbuf->datalen != sizeof(struct winsize))
			break;
			break;
		hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data));
		/* The caller must ensure that the hvc is locked, which
		 * is the case when called from hvc_iucv_get_chars() */
		__hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data));
		break;
		break;


	case MSG_TYPE_ERROR:	/* ignored ... */
	case MSG_TYPE_ERROR:	/* ignored ... */