Commit 881e18f9 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: tty3270, get rid of ugly aliasing

Blah, do not assume that raw3270_view is at the beginning of tty3270.
Use proper types and container_of wherever needed.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9d2ae233
...@@ -324,9 +324,8 @@ tty3270_blank_line(struct tty3270 *tp) ...@@ -324,9 +324,8 @@ tty3270_blank_line(struct tty3270 *tp)
static void static void
tty3270_write_callback(struct raw3270_request *rq, void *data) tty3270_write_callback(struct raw3270_request *rq, void *data)
{ {
struct tty3270 *tp; struct tty3270 *tp = container_of(rq->view, struct tty3270, view);
tp = (struct tty3270 *) rq->view;
if (rq->rc != 0) { if (rq->rc != 0) {
/* Write wasn't successful. Refresh all. */ /* Write wasn't successful. Refresh all. */
tp->update_flags = TTY_UPDATE_ALL; tp->update_flags = TTY_UPDATE_ALL;
...@@ -537,11 +536,10 @@ static void ...@@ -537,11 +536,10 @@ static void
tty3270_read_tasklet(struct raw3270_request *rrq) tty3270_read_tasklet(struct raw3270_request *rrq)
{ {
static char kreset_data = TW_KR; static char kreset_data = TW_KR;
struct tty3270 *tp; struct tty3270 *tp = container_of(rrq->view, struct tty3270, view);
char *input; char *input;
int len; int len;
tp = (struct tty3270 *) rrq->view;
spin_lock_bh(&tp->view.lock); spin_lock_bh(&tp->view.lock);
/* /*
* Two AID keys are special: For 0x7d (enter) the input line * Two AID keys are special: For 0x7d (enter) the input line
...@@ -596,9 +594,10 @@ tty3270_read_tasklet(struct raw3270_request *rrq) ...@@ -596,9 +594,10 @@ tty3270_read_tasklet(struct raw3270_request *rrq)
static void static void
tty3270_read_callback(struct raw3270_request *rq, void *data) tty3270_read_callback(struct raw3270_request *rq, void *data)
{ {
struct tty3270 *tp = container_of(rq->view, struct tty3270, view);
raw3270_get_view(rq->view); raw3270_get_view(rq->view);
/* Schedule tasklet to pass input to tty. */ /* Schedule tasklet to pass input to tty. */
tasklet_schedule(&((struct tty3270 *) rq->view)->readlet); tasklet_schedule(&tp->readlet);
} }
/* /*
...@@ -635,9 +634,8 @@ tty3270_issue_read(struct tty3270 *tp, int lock) ...@@ -635,9 +634,8 @@ tty3270_issue_read(struct tty3270 *tp, int lock)
static int static int
tty3270_activate(struct raw3270_view *view) tty3270_activate(struct raw3270_view *view)
{ {
struct tty3270 *tp; struct tty3270 *tp = container_of(view, struct tty3270, view);
tp = (struct tty3270 *) view;
tp->update_flags = TTY_UPDATE_ALL; tp->update_flags = TTY_UPDATE_ALL;
tty3270_set_timer(tp, 1); tty3270_set_timer(tp, 1);
return 0; return 0;
...@@ -646,9 +644,8 @@ tty3270_activate(struct raw3270_view *view) ...@@ -646,9 +644,8 @@ tty3270_activate(struct raw3270_view *view)
static void static void
tty3270_deactivate(struct raw3270_view *view) tty3270_deactivate(struct raw3270_view *view)
{ {
struct tty3270 *tp; struct tty3270 *tp = container_of(view, struct tty3270, view);
tp = (struct tty3270 *) view;
del_timer(&tp->timer); del_timer(&tp->timer);
} }
...@@ -804,10 +801,9 @@ tty3270_free_screen(struct tty3270 *tp) ...@@ -804,10 +801,9 @@ tty3270_free_screen(struct tty3270 *tp)
static void static void
tty3270_release(struct raw3270_view *view) tty3270_release(struct raw3270_view *view)
{ {
struct tty3270 *tp; struct tty3270 *tp = container_of(view, struct tty3270, view);
struct tty_struct *tty; struct tty_struct *tty;
tp = (struct tty3270 *) view;
tty = tp->tty; tty = tp->tty;
if (tty) { if (tty) {
tty->driver_data = NULL; tty->driver_data = NULL;
...@@ -823,8 +819,9 @@ tty3270_release(struct raw3270_view *view) ...@@ -823,8 +819,9 @@ tty3270_release(struct raw3270_view *view)
static void static void
tty3270_free(struct raw3270_view *view) tty3270_free(struct raw3270_view *view)
{ {
tty3270_free_screen((struct tty3270 *) view); struct tty3270 *tp = container_of(view, struct tty3270, view);
tty3270_free_view((struct tty3270 *) view); tty3270_free_screen(tp);
tty3270_free_view(tp);
} }
/* /*
...@@ -833,14 +830,13 @@ tty3270_free(struct raw3270_view *view) ...@@ -833,14 +830,13 @@ tty3270_free(struct raw3270_view *view)
static void static void
tty3270_del_views(void) tty3270_del_views(void)
{ {
struct tty3270 *tp;
int i; int i;
for (i = 0; i < tty3270_max_index; i++) { for (i = 0; i < tty3270_max_index; i++) {
tp = (struct tty3270 *) struct raw3270_view *view =
raw3270_find_view(&tty3270_fn, i + RAW3270_FIRSTMINOR); raw3270_find_view(&tty3270_fn, i + RAW3270_FIRSTMINOR);
if (!IS_ERR(tp)) if (!IS_ERR(view))
raw3270_del_view(&tp->view); raw3270_del_view(view);
} }
} }
...@@ -858,16 +854,17 @@ static struct raw3270_fn tty3270_fn = { ...@@ -858,16 +854,17 @@ static struct raw3270_fn tty3270_fn = {
static int static int
tty3270_open(struct tty_struct *tty, struct file * filp) tty3270_open(struct tty_struct *tty, struct file * filp)
{ {
struct raw3270_view *view;
struct tty3270 *tp; struct tty3270 *tp;
int i, rc; int i, rc;
if (tty->count > 1) if (tty->count > 1)
return 0; return 0;
/* Check if the tty3270 is already there. */ /* Check if the tty3270 is already there. */
tp = (struct tty3270 *) view = raw3270_find_view(&tty3270_fn,
raw3270_find_view(&tty3270_fn,
tty->index + RAW3270_FIRSTMINOR); tty->index + RAW3270_FIRSTMINOR);
if (!IS_ERR(tp)) { if (!IS_ERR(view)) {
tp = container_of(view, struct tty3270, view);
tty->driver_data = tp; tty->driver_data = tp;
tty->winsize.ws_row = tp->view.rows - 2; tty->winsize.ws_row = tp->view.rows - 2;
tty->winsize.ws_col = tp->view.cols; tty->winsize.ws_col = tp->view.cols;
...@@ -881,7 +878,7 @@ tty3270_open(struct tty_struct *tty, struct file * filp) ...@@ -881,7 +878,7 @@ tty3270_open(struct tty_struct *tty, struct file * filp)
tty3270_max_index = tty->index + 1; tty3270_max_index = tty->index + 1;
/* Quick exit if there is no device for tty->index. */ /* Quick exit if there is no device for tty->index. */
if (PTR_ERR(tp) == -ENODEV) if (PTR_ERR(view) == -ENODEV)
return -ENODEV; return -ENODEV;
/* Allocate tty3270 structure on first open. */ /* Allocate tty3270 structure on first open. */
...@@ -935,11 +932,10 @@ tty3270_open(struct tty_struct *tty, struct file * filp) ...@@ -935,11 +932,10 @@ tty3270_open(struct tty_struct *tty, struct file * filp)
static void static void
tty3270_close(struct tty_struct *tty, struct file * filp) tty3270_close(struct tty_struct *tty, struct file * filp)
{ {
struct tty3270 *tp; struct tty3270 *tp = tty->driver_data;
if (tty->count > 1) if (tty->count > 1)
return; return;
tp = (struct tty3270 *) tty->driver_data;
if (tp) { if (tp) {
tty->driver_data = NULL; tty->driver_data = NULL;
tp->tty = tp->kbd->tty = NULL; tp->tty = tp->kbd->tty = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment