From eb98630ba02f6a23a2d202be082757a9e9940b2b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 18 May 2008 20:47:17 +0200 Subject: m68k: Some input drivers do not check the platform Some input drivers do not check whether they're actually running on the correct platform, causing multi-platform kernels to crash if they are not. Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/input/keyboard/hilkbd.c | 4 ++++ drivers/input/misc/hp_sdc_rtc.c | 5 +++++ drivers/input/serio/hp_sdc_mlc.c | 5 +++++ 3 files changed, 14 insertions(+) (limited to 'drivers/input') diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c index 50d80ecf0b8..aacf71f3cd4 100644 --- a/drivers/input/keyboard/hilkbd.c +++ b/drivers/input/keyboard/hilkbd.c @@ -217,6 +217,10 @@ hil_keyb_init(void) return -ENOMEM; #if defined(CONFIG_HP300) + if (!MACH_IS_HP300) { + err = -ENODEV; + goto err1; + } if (!hwreg_present((void *)(HILBASE + HIL_DATA))) { printk(KERN_ERR "HIL: hardware register was not found\n"); err = -ENODEV; diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index ab76ea442fa..45e5d05b01d 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c @@ -691,6 +691,11 @@ static int __init hp_sdc_rtc_init(void) { int ret; +#ifdef __mc68000__ + if (!MACH_IS_HP300) + return -ENODEV; +#endif + init_MUTEX(&i8042tregs); if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c index f1fd3b638a3..587398f5c9d 100644 --- a/drivers/input/serio/hp_sdc_mlc.c +++ b/drivers/input/serio/hp_sdc_mlc.c @@ -306,6 +306,11 @@ static int __init hp_sdc_mlc_init(void) { hil_mlc *mlc = &hp_sdc_mlc; +#ifdef __mc68000__ + if (!MACH_IS_HP300) + return -ENODEV; +#endif + printk(KERN_INFO PREFIX "Registering the System Domain Controller's HIL MLC.\n"); hp_sdc_mlc_priv.emtestmode = 0; -- cgit v1.2.3-70-g09d2 From fd5b462f0b3ae641e39966d1c6cd0dd66100cda5 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 18 May 2008 20:47:18 +0200 Subject: m68k: Return -ENODEV if no device is found According to the tests in do_initcalls(), the proper error code in case no device is found is -ENODEV, not -ENXIO or -EIO. Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/block/amiflop.c | 6 +++--- drivers/block/z2ram.c | 2 +- drivers/input/serio/q40kbd.c | 2 +- drivers/video/amifb.c | 4 ++-- drivers/video/hpfb.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/input') diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index c9751b2b57e..7516baff3bb 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1714,10 +1714,10 @@ static int __init amiga_floppy_init(void) int i, ret; if (!MACH_IS_AMIGA) - return -ENXIO; + return -ENODEV; if (!AMIGAHW_PRESENT(AMI_FLOPPY)) - return -ENXIO; + return -ENODEV; if (register_blkdev(FLOPPY_MAJOR,"fd")) return -EBUSY; @@ -1755,7 +1755,7 @@ static int __init amiga_floppy_init(void) if (!floppy_queue) goto out_queue; - ret = -ENXIO; + ret = -ENODEV; if (fd_probe_drives() < 1) /* No usable drives */ goto out_probe; diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 2d5853cbd4b..be20a67f1fa 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -332,7 +332,7 @@ z2_init(void) int ret; if (!MACH_IS_AMIGA) - return -ENXIO; + return -ENODEV; ret = -EBUSY; if (register_blkdev(Z2RAM_MAJOR, DEVICE_NAME)) diff --git a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c index cb89aff2e16..d962a8d78b1 100644 --- a/drivers/input/serio/q40kbd.c +++ b/drivers/input/serio/q40kbd.c @@ -156,7 +156,7 @@ static int __init q40kbd_init(void) int error; if (!MACH_IS_Q40) - return -EIO; + return -ENODEV; error = platform_driver_register(&q40kbd_driver); if (error) diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c index e6492c1048b..05a328c11a8 100644 --- a/drivers/video/amifb.c +++ b/drivers/video/amifb.c @@ -2261,7 +2261,7 @@ int __init amifb_init(void) amifb_setup(option); #endif if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_VIDEO)) - return -ENXIO; + return -ENODEV; /* * We request all registers starting from bplpt[0] @@ -2333,7 +2333,7 @@ default_chipset: strcat(fb_info.fix.id, "Unknown"); goto default_chipset; #else /* CONFIG_FB_AMIGA_OCS */ - err = -ENXIO; + err = -ENODEV; goto amifb_error; #endif /* CONFIG_FB_AMIGA_OCS */ break; diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c index 2eb4fb15908..b8ebff1e849 100644 --- a/drivers/video/hpfb.c +++ b/drivers/video/hpfb.c @@ -382,7 +382,7 @@ int __init hpfb_init(void) #define INTFBPADDR 0x560000 if (!MACH_IS_HP300) - return -ENXIO; + return -ENODEV; if (fb_get_options("hpfb", NULL)) return -ENODEV; -- cgit v1.2.3-70-g09d2 From 839cd31050096c88d929cc7c790c80cae87e2d85 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 21 May 2008 06:32:11 +0100 Subject: MODULE_LICENSE expects "GPL v2", not "GPLv2" ... and we have few enough places using the latter to make it simpler to do search and replace... Signed-off-by: Al Viro Signed-off-by: Linus Torvalds --- arch/sh/drivers/heartbeat.c | 2 +- drivers/input/keyboard/aaed2000_kbd.c | 2 +- drivers/input/keyboard/corgikbd.c | 2 +- drivers/input/keyboard/jornada680_kbd.c | 2 +- drivers/input/keyboard/jornada720_kbd.c | 2 +- drivers/input/keyboard/spitzkbd.c | 2 +- drivers/input/touchscreen/jornada720_ts.c | 2 +- drivers/scsi/mac_esp.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/input') diff --git a/arch/sh/drivers/heartbeat.c b/arch/sh/drivers/heartbeat.c index ab77b0e0fa0..938817e34e2 100644 --- a/arch/sh/drivers/heartbeat.c +++ b/arch/sh/drivers/heartbeat.c @@ -154,4 +154,4 @@ module_exit(heartbeat_exit); MODULE_VERSION(DRV_VERSION); MODULE_AUTHOR("Paul Mundt"); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/input/keyboard/aaed2000_kbd.c b/drivers/input/keyboard/aaed2000_kbd.c index a293e8b3f50..8a77bfcd05b 100644 --- a/drivers/input/keyboard/aaed2000_kbd.c +++ b/drivers/input/keyboard/aaed2000_kbd.c @@ -183,4 +183,4 @@ module_exit(aaedkbd_exit); MODULE_AUTHOR("Nicolas Bellido Y Ortega"); MODULE_DESCRIPTION("AAED-2000 Keyboard Driver"); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 29fbec6218b..1aa46ae1263 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -412,5 +412,5 @@ module_exit(corgikbd_exit); MODULE_AUTHOR("Richard Purdie "); MODULE_DESCRIPTION("Corgi Keyboard Driver"); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:corgi-keyboard"); diff --git a/drivers/input/keyboard/jornada680_kbd.c b/drivers/input/keyboard/jornada680_kbd.c index 9387da343f9..781fc610286 100644 --- a/drivers/input/keyboard/jornada680_kbd.c +++ b/drivers/input/keyboard/jornada680_kbd.c @@ -275,5 +275,5 @@ module_exit(jornada680kbd_exit); MODULE_AUTHOR("Kristoffer Ericson "); MODULE_DESCRIPTION("HP Jornada 620/660/680/690 Keyboard Driver"); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:jornada680_kbd"); diff --git a/drivers/input/keyboard/jornada720_kbd.c b/drivers/input/keyboard/jornada720_kbd.c index a1164a0c773..ce650af6d64 100644 --- a/drivers/input/keyboard/jornada720_kbd.c +++ b/drivers/input/keyboard/jornada720_kbd.c @@ -29,7 +29,7 @@ MODULE_AUTHOR("Kristoffer Ericson "); MODULE_DESCRIPTION("HP Jornada 710/720/728 keyboard driver"); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); static unsigned short jornada_std_keymap[128] = { /* ROW */ 0, KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, /* #1 */ diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index 61e401bc910..1aa37181c40 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c @@ -494,5 +494,5 @@ module_exit(spitzkbd_exit); MODULE_AUTHOR("Richard Purdie "); MODULE_DESCRIPTION("Spitz Keyboard Driver"); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:spitz-keyboard"); diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c index 742242111bf..1aca108b103 100644 --- a/drivers/input/touchscreen/jornada720_ts.c +++ b/drivers/input/touchscreen/jornada720_ts.c @@ -24,7 +24,7 @@ MODULE_AUTHOR("Kristoffer Ericson "); MODULE_DESCRIPTION("HP Jornada 710/720/728 touchscreen driver"); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); struct jornada_ts { struct input_dev *dev; diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c index cd37bd69a11..887682a24e3 100644 --- a/drivers/scsi/mac_esp.c +++ b/drivers/scsi/mac_esp.c @@ -650,7 +650,7 @@ static void __exit mac_esp_exit(void) MODULE_DESCRIPTION("Mac ESP SCSI driver"); MODULE_AUTHOR("Finn Thain "); -MODULE_LICENSE("GPLv2"); +MODULE_LICENSE("GPL v2"); MODULE_VERSION(DRV_VERSION); module_init(mac_esp_init); -- cgit v1.2.3-70-g09d2 From 6ba0e7b36c7cc1745b3cbeda244d14edae3ad058 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 May 2008 23:31:08 +0100 Subject: xen pvfb: Pointer z-axis (mouse wheel) support Add z-axis motion to pointer events. Backward compatible, because there's space for the z-axis in union xenkbd_in_event, and old backends zero it. Derived from http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/57dfe0098000 http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/1edfea26a2a9 http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/c3ff0b26f664 Signed-off-by: Pat Campbell Signed-off-by: Markus Armbruster Signed-off-by: Jeremy Fitzhardinge Signed-off-by: Thomas Gleixner --- drivers/input/xen-kbdfront.c | 8 +++++++- include/xen/interface/io/kbdif.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c index 0f47f4697cd..9da4452786f 100644 --- a/drivers/input/xen-kbdfront.c +++ b/drivers/input/xen-kbdfront.c @@ -66,6 +66,9 @@ static irqreturn_t input_handler(int rq, void *dev_id) case XENKBD_TYPE_MOTION: input_report_rel(dev, REL_X, event->motion.rel_x); input_report_rel(dev, REL_Y, event->motion.rel_y); + if (event->motion.rel_z) + input_report_rel(dev, REL_WHEEL, + -event->motion.rel_z); break; case XENKBD_TYPE_KEY: dev = NULL; @@ -84,6 +87,9 @@ static irqreturn_t input_handler(int rq, void *dev_id) case XENKBD_TYPE_POS: input_report_abs(dev, ABS_X, event->pos.abs_x); input_report_abs(dev, ABS_Y, event->pos.abs_y); + if (event->pos.rel_z) + input_report_rel(dev, REL_WHEEL, + -event->pos.rel_z); break; } if (dev) @@ -152,7 +158,7 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev, ptr->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS); for (i = BTN_LEFT; i <= BTN_TASK; i++) set_bit(i, ptr->keybit); - ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y); + ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0); input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0); diff --git a/include/xen/interface/io/kbdif.h b/include/xen/interface/io/kbdif.h index fb97f4284ff..8066c7849fb 100644 --- a/include/xen/interface/io/kbdif.h +++ b/include/xen/interface/io/kbdif.h @@ -49,6 +49,7 @@ struct xenkbd_motion { uint8_t type; /* XENKBD_TYPE_MOTION */ int32_t rel_x; /* relative X motion */ int32_t rel_y; /* relative Y motion */ + int32_t rel_z; /* relative Z motion (wheel) */ }; struct xenkbd_key { @@ -61,6 +62,7 @@ struct xenkbd_position { uint8_t type; /* XENKBD_TYPE_POS */ int32_t abs_x; /* absolute X position (in FB pixels) */ int32_t abs_y; /* absolute Y position (in FB pixels) */ + int32_t rel_z; /* relative Z motion (wheel) */ }; #define XENKBD_IN_EVENT_SIZE 40 -- cgit v1.2.3-70-g09d2 From 1e892c959da42278e60b21f5ecfd6fba0efff313 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 May 2008 23:31:09 +0100 Subject: xen pvfb: Module aliases to support module autoloading These are mostly for completeness and consistency with the other frontends, as PVFB is typically compiled in rather than a module. Derived from http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/5e294e29a43e While there, add module descriptions. Signed-off-by: Markus Armbruster Signed-off-by: Jeremy Fitzhardinge Signed-off-by: Thomas Gleixner --- drivers/input/xen-kbdfront.c | 2 ++ drivers/video/xen-fbfront.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'drivers/input') diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c index 9da4452786f..eaf69cf5b44 100644 --- a/drivers/input/xen-kbdfront.c +++ b/drivers/input/xen-kbdfront.c @@ -343,4 +343,6 @@ static void __exit xenkbd_cleanup(void) module_init(xenkbd_init); module_exit(xenkbd_cleanup); +MODULE_DESCRIPTION("Xen virtual keyboard/pointer device frontend"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("xen:vkbd"); diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c index 4e10876e62f..5553e517563 100644 --- a/drivers/video/xen-fbfront.c +++ b/drivers/video/xen-fbfront.c @@ -572,4 +572,6 @@ static void __exit xenfb_cleanup(void) module_init(xenfb_init); module_exit(xenfb_cleanup); +MODULE_DESCRIPTION("Xen virtual framebuffer device frontend"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("xen:vfb"); -- cgit v1.2.3-70-g09d2 From e4dcff1f6e7582f76c2c9990b1d9111bbc8e26ef Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 May 2008 23:31:11 +0100 Subject: xen pvfb: Dynamic mode support (screen resizing) The pvfb backend indicates dynamic mode support by creating node feature_resize with a non-zero value in its xenstore directory. xen-fbfront sends a resize notification event on mode change. Fully backwards compatible both ways. Framebuffer size and initial resolution can be controlled through kernel parameter xen_fbfront.video. The backend enforces a separate size limit, which it advertises in node videoram in its xenstore directory. xen-kbdfront gets the maximum screen resolution from nodes width and height in the backend's xenstore directory instead of hardcoding it. Additional goodie: support for larger framebuffers (512M on a 64-bit system with 4K pages). Changing the number of bits per pixels dynamically is not supported, yet. Ported from http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/92f7b3144f41 http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/bfc040135633 Signed-off-by: Pat Campbell Signed-off-by: Markus Armbruster Signed-off-by: Jeremy Fitzhardinge Signed-off-by: Thomas Gleixner --- drivers/input/xen-kbdfront.c | 10 +++ drivers/video/xen-fbfront.c | 183 +++++++++++++++++++++++++++++++++------- include/xen/interface/io/fbif.h | 29 +++++-- 3 files changed, 188 insertions(+), 34 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c index eaf69cf5b44..9ce3b3baf3a 100644 --- a/drivers/input/xen-kbdfront.c +++ b/drivers/input/xen-kbdfront.c @@ -300,6 +300,16 @@ InitWait: */ if (dev->state != XenbusStateConnected) goto InitWait; /* no InitWait seen yet, fudge it */ + + /* Set input abs params to match backend screen res */ + if (xenbus_scanf(XBT_NIL, info->xbdev->otherend, + "width", "%d", &val) > 0) + input_set_abs_params(info->ptr, ABS_X, 0, val, 0, 0); + + if (xenbus_scanf(XBT_NIL, info->xbdev->otherend, + "height", "%d", &val) > 0) + input_set_abs_params(info->ptr, ABS_Y, 0, val, 0, 0); + break; case XenbusStateClosing: diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c index 291eef69559..47ed39b52f9 100644 --- a/drivers/video/xen-fbfront.c +++ b/drivers/video/xen-fbfront.c @@ -43,23 +43,47 @@ struct xenfb_info { struct xenfb_page *page; unsigned long *mfns; int update_wanted; /* XENFB_TYPE_UPDATE wanted */ + int feature_resize; /* XENFB_TYPE_RESIZE ok */ + struct xenfb_resize resize; /* protected by resize_lock */ + int resize_dpy; /* ditto */ + spinlock_t resize_lock; struct xenbus_device *xbdev; }; -static u32 xenfb_mem_len = XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH / 8; +#define XENFB_DEFAULT_FB_LEN (XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH / 8) + +enum { KPARAM_MEM, KPARAM_WIDTH, KPARAM_HEIGHT, KPARAM_CNT }; +static int video[KPARAM_CNT] = { 2, XENFB_WIDTH, XENFB_HEIGHT }; +module_param_array(video, int, NULL, 0); +MODULE_PARM_DESC(video, + "Video memory size in MB, width, height in pixels (default 2,800,600)"); static void xenfb_make_preferred_console(void); static int xenfb_remove(struct xenbus_device *); -static void xenfb_init_shared_page(struct xenfb_info *); +static void xenfb_init_shared_page(struct xenfb_info *, struct fb_info *); static int xenfb_connect_backend(struct xenbus_device *, struct xenfb_info *); static void xenfb_disconnect_backend(struct xenfb_info *); +static void xenfb_send_event(struct xenfb_info *info, + union xenfb_out_event *event) +{ + u32 prod; + + prod = info->page->out_prod; + /* caller ensures !xenfb_queue_full() */ + mb(); /* ensure ring space available */ + XENFB_OUT_RING_REF(info->page, prod) = *event; + wmb(); /* ensure ring contents visible */ + info->page->out_prod = prod + 1; + + notify_remote_via_irq(info->irq); +} + static void xenfb_do_update(struct xenfb_info *info, int x, int y, int w, int h) { union xenfb_out_event event; - u32 prod; memset(&event, 0, sizeof(event)); event.type = XENFB_TYPE_UPDATE; @@ -68,14 +92,19 @@ static void xenfb_do_update(struct xenfb_info *info, event.update.width = w; event.update.height = h; - prod = info->page->out_prod; /* caller ensures !xenfb_queue_full() */ - mb(); /* ensure ring space available */ - XENFB_OUT_RING_REF(info->page, prod) = event; - wmb(); /* ensure ring contents visible */ - info->page->out_prod = prod + 1; + xenfb_send_event(info, &event); +} - notify_remote_via_irq(info->irq); +static void xenfb_do_resize(struct xenfb_info *info) +{ + union xenfb_out_event event; + + memset(&event, 0, sizeof(event)); + event.resize = info->resize; + + /* caller ensures !xenfb_queue_full() */ + xenfb_send_event(info, &event); } static int xenfb_queue_full(struct xenfb_info *info) @@ -87,12 +116,28 @@ static int xenfb_queue_full(struct xenfb_info *info) return prod - cons == XENFB_OUT_RING_LEN; } +static void xenfb_handle_resize_dpy(struct xenfb_info *info) +{ + unsigned long flags; + + spin_lock_irqsave(&info->resize_lock, flags); + if (info->resize_dpy) { + if (!xenfb_queue_full(info)) { + info->resize_dpy = 0; + xenfb_do_resize(info); + } + } + spin_unlock_irqrestore(&info->resize_lock, flags); +} + static void xenfb_refresh(struct xenfb_info *info, int x1, int y1, int w, int h) { unsigned long flags; - int y2 = y1 + h - 1; int x2 = x1 + w - 1; + int y2 = y1 + h - 1; + + xenfb_handle_resize_dpy(info); if (!info->update_wanted) return; @@ -225,6 +270,57 @@ static ssize_t xenfb_write(struct fb_info *p, const char __user *buf, return res; } +static int +xenfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) +{ + struct xenfb_info *xenfb_info; + int required_mem_len; + + xenfb_info = info->par; + + if (!xenfb_info->feature_resize) { + if (var->xres == video[KPARAM_WIDTH] && + var->yres == video[KPARAM_HEIGHT] && + var->bits_per_pixel == xenfb_info->page->depth) { + return 0; + } + return -EINVAL; + } + + /* Can't resize past initial width and height */ + if (var->xres > video[KPARAM_WIDTH] || var->yres > video[KPARAM_HEIGHT]) + return -EINVAL; + + required_mem_len = var->xres * var->yres * xenfb_info->page->depth / 8; + if (var->bits_per_pixel == xenfb_info->page->depth && + var->xres <= info->fix.line_length / (XENFB_DEPTH / 8) && + required_mem_len <= info->fix.smem_len) { + var->xres_virtual = var->xres; + var->yres_virtual = var->yres; + return 0; + } + return -EINVAL; +} + +static int xenfb_set_par(struct fb_info *info) +{ + struct xenfb_info *xenfb_info; + unsigned long flags; + + xenfb_info = info->par; + + spin_lock_irqsave(&xenfb_info->resize_lock, flags); + xenfb_info->resize.type = XENFB_TYPE_RESIZE; + xenfb_info->resize.width = info->var.xres; + xenfb_info->resize.height = info->var.yres; + xenfb_info->resize.stride = info->fix.line_length; + xenfb_info->resize.depth = info->var.bits_per_pixel; + xenfb_info->resize.offset = 0; + xenfb_info->resize_dpy = 1; + spin_unlock_irqrestore(&xenfb_info->resize_lock, flags); + return 0; +} + static struct fb_ops xenfb_fb_ops = { .owner = THIS_MODULE, .fb_read = fb_sys_read, @@ -233,6 +329,8 @@ static struct fb_ops xenfb_fb_ops = { .fb_fillrect = xenfb_fillrect, .fb_copyarea = xenfb_copyarea, .fb_imageblit = xenfb_imageblit, + .fb_check_var = xenfb_check_var, + .fb_set_par = xenfb_set_par, }; static irqreturn_t xenfb_event_handler(int rq, void *dev_id) @@ -261,6 +359,8 @@ static int __devinit xenfb_probe(struct xenbus_device *dev, { struct xenfb_info *info; struct fb_info *fb_info; + int fb_size; + int val; int ret; info = kzalloc(sizeof(*info), GFP_KERNEL); @@ -268,18 +368,35 @@ static int __devinit xenfb_probe(struct xenbus_device *dev, xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure"); return -ENOMEM; } + + /* Limit kernel param videoram amount to what is in xenstore */ + if (xenbus_scanf(XBT_NIL, dev->otherend, "videoram", "%d", &val) == 1) { + if (val < video[KPARAM_MEM]) + video[KPARAM_MEM] = val; + } + + /* If requested res does not fit in available memory, use default */ + fb_size = video[KPARAM_MEM] * 1024 * 1024; + if (video[KPARAM_WIDTH] * video[KPARAM_HEIGHT] * XENFB_DEPTH / 8 + > fb_size) { + video[KPARAM_WIDTH] = XENFB_WIDTH; + video[KPARAM_HEIGHT] = XENFB_HEIGHT; + fb_size = XENFB_DEFAULT_FB_LEN; + } + dev->dev.driver_data = info; info->xbdev = dev; info->irq = -1; info->x1 = info->y1 = INT_MAX; spin_lock_init(&info->dirty_lock); + spin_lock_init(&info->resize_lock); - info->fb = vmalloc(xenfb_mem_len); + info->fb = vmalloc(fb_size); if (info->fb == NULL) goto error_nomem; - memset(info->fb, 0, xenfb_mem_len); + memset(info->fb, 0, fb_size); - info->nr_pages = (xenfb_mem_len + PAGE_SIZE - 1) >> PAGE_SHIFT; + info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT; info->mfns = vmalloc(sizeof(unsigned long) * info->nr_pages); if (!info->mfns) @@ -290,8 +407,6 @@ static int __devinit xenfb_probe(struct xenbus_device *dev, if (!info->page) goto error_nomem; - xenfb_init_shared_page(info); - /* abusing framebuffer_alloc() to allocate pseudo_palette */ fb_info = framebuffer_alloc(sizeof(u32) * 256, NULL); if (fb_info == NULL) @@ -304,9 +419,9 @@ static int __devinit xenfb_probe(struct xenbus_device *dev, fb_info->screen_base = info->fb; fb_info->fbops = &xenfb_fb_ops; - fb_info->var.xres_virtual = fb_info->var.xres = info->page->width; - fb_info->var.yres_virtual = fb_info->var.yres = info->page->height; - fb_info->var.bits_per_pixel = info->page->depth; + fb_info->var.xres_virtual = fb_info->var.xres = video[KPARAM_WIDTH]; + fb_info->var.yres_virtual = fb_info->var.yres = video[KPARAM_HEIGHT]; + fb_info->var.bits_per_pixel = XENFB_DEPTH; fb_info->var.red = (struct fb_bitfield){16, 8, 0}; fb_info->var.green = (struct fb_bitfield){8, 8, 0}; @@ -318,9 +433,9 @@ static int __devinit xenfb_probe(struct xenbus_device *dev, fb_info->var.vmode = FB_VMODE_NONINTERLACED; fb_info->fix.visual = FB_VISUAL_TRUECOLOR; - fb_info->fix.line_length = info->page->line_length; + fb_info->fix.line_length = fb_info->var.xres * XENFB_DEPTH / 8; fb_info->fix.smem_start = 0; - fb_info->fix.smem_len = xenfb_mem_len; + fb_info->fix.smem_len = fb_size; strcpy(fb_info->fix.id, "xen"); fb_info->fix.type = FB_TYPE_PACKED_PIXELS; fb_info->fix.accel = FB_ACCEL_NONE; @@ -337,6 +452,8 @@ static int __devinit xenfb_probe(struct xenbus_device *dev, fb_info->fbdefio = &xenfb_defio; fb_deferred_io_init(fb_info); + xenfb_init_shared_page(info, fb_info); + ret = register_framebuffer(fb_info); if (ret) { fb_deferred_io_cleanup(fb_info); @@ -389,7 +506,7 @@ static int xenfb_resume(struct xenbus_device *dev) struct xenfb_info *info = dev->dev.driver_data; xenfb_disconnect_backend(info); - xenfb_init_shared_page(info); + xenfb_init_shared_page(info, info->fb_info); return xenfb_connect_backend(dev, info); } @@ -417,20 +534,23 @@ static unsigned long vmalloc_to_mfn(void *address) return pfn_to_mfn(vmalloc_to_pfn(address)); } -static void xenfb_init_shared_page(struct xenfb_info *info) +static void xenfb_init_shared_page(struct xenfb_info *info, + struct fb_info *fb_info) { int i; + int epd = PAGE_SIZE / sizeof(info->mfns[0]); for (i = 0; i < info->nr_pages; i++) info->mfns[i] = vmalloc_to_mfn(info->fb + i * PAGE_SIZE); - info->page->pd[0] = vmalloc_to_mfn(info->mfns); - info->page->pd[1] = 0; - info->page->width = XENFB_WIDTH; - info->page->height = XENFB_HEIGHT; - info->page->depth = XENFB_DEPTH; - info->page->line_length = (info->page->depth / 8) * info->page->width; - info->page->mem_length = xenfb_mem_len; + for (i = 0; i * epd < info->nr_pages; i++) + info->page->pd[i] = vmalloc_to_mfn(&info->mfns[i * epd]); + + info->page->width = fb_info->var.xres; + info->page->height = fb_info->var.yres; + info->page->depth = fb_info->var.bits_per_pixel; + info->page->line_length = fb_info->fix.line_length; + info->page->mem_length = fb_info->fix.smem_len; info->page->in_cons = info->page->in_prod = 0; info->page->out_cons = info->page->out_prod = 0; } @@ -530,6 +650,11 @@ InitWait: val = 0; if (val) info->update_wanted = 1; + + if (xenbus_scanf(XBT_NIL, dev->otherend, + "feature-resize", "%d", &val) < 0) + val = 0; + info->feature_resize = val; break; case XenbusStateClosing: diff --git a/include/xen/interface/io/fbif.h b/include/xen/interface/io/fbif.h index 5a934dd7796..974a51ed916 100644 --- a/include/xen/interface/io/fbif.h +++ b/include/xen/interface/io/fbif.h @@ -49,11 +49,27 @@ struct xenfb_update { int32_t height; /* rect height */ }; +/* + * Framebuffer resize notification event + * Capable backend sets feature-resize in xenstore. + */ +#define XENFB_TYPE_RESIZE 3 + +struct xenfb_resize { + uint8_t type; /* XENFB_TYPE_RESIZE */ + int32_t width; /* width in pixels */ + int32_t height; /* height in pixels */ + int32_t stride; /* stride in bytes */ + int32_t depth; /* depth in bits */ + int32_t offset; /* start offset within framebuffer */ +}; + #define XENFB_OUT_EVENT_SIZE 40 union xenfb_out_event { uint8_t type; struct xenfb_update update; + struct xenfb_resize resize; char pad[XENFB_OUT_EVENT_SIZE]; }; @@ -105,15 +121,18 @@ struct xenfb_page { * Each directory page holds PAGE_SIZE / sizeof(*pd) * framebuffer pages, and can thus map up to PAGE_SIZE * * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and - * sizeof(unsigned long) == 4, that's 4 Megs. Two directory - * pages should be enough for a while. + * sizeof(unsigned long) == 4/8, that's 4 Megs 32 bit and 2 + * Megs 64 bit. 256 directories give enough room for a 512 + * Meg framebuffer with a max resolution of 12,800x10,240. + * Should be enough for a while with room leftover for + * expansion. */ - unsigned long pd[2]; + unsigned long pd[256]; }; /* - * Wart: xenkbd needs to know resolution. Put it here until a better - * solution is found, but don't leak it to the backend. + * Wart: xenkbd needs to know default resolution. Put it here until a + * better solution is found, but don't leak it to the backend. */ #ifdef __KERNEL__ #define XENFB_WIDTH 800 -- cgit v1.2.3-70-g09d2 From 2edbf8537edc62c9b0ef75e7025d01e8b6a48707 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 10:37:16 -0600 Subject: Input: cdev lock_kernel() pushdown Signed-off-by: Jonathan Corbet --- drivers/input/input.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/input.c b/drivers/input/input.c index 27006fc1830..408df0bd6be 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -21,6 +21,7 @@ #include #include #include +#include MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("Input core"); @@ -1588,13 +1589,17 @@ EXPORT_SYMBOL(input_unregister_handle); static int input_open_file(struct inode *inode, struct file *file) { - struct input_handler *handler = input_table[iminor(inode) >> 5]; + struct input_handler *handler; const struct file_operations *old_fops, *new_fops = NULL; int err; + lock_kernel(); /* No load-on-demand here? */ - if (!handler || !(new_fops = fops_get(handler->fops))) - return -ENODEV; + handler = input_table[iminor(inode) >> 5]; + if (!handler || !(new_fops = fops_get(handler->fops))) { + err = -ENODEV; + goto out; + } /* * That's _really_ odd. Usually NULL ->open means "nothing special", @@ -1602,7 +1607,8 @@ static int input_open_file(struct inode *inode, struct file *file) */ if (!new_fops->open) { fops_put(new_fops); - return -ENODEV; + err = -ENODEV; + goto out; } old_fops = file->f_op; file->f_op = new_fops; @@ -1614,6 +1620,8 @@ static int input_open_file(struct inode *inode, struct file *file) file->f_op = fops_get(old_fops); } fops_put(old_fops); +out: + unlock_kernel(); return err; } -- cgit v1.2.3-70-g09d2 From 986f8b8ccf4806c1e95528a6f157998113fb4f41 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:58 +0200 Subject: hp_sdc_rtc: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/input/misc/hp_sdc_rtc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/input') diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 45e5d05b01d..49d8abfe38f 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -408,6 +409,7 @@ static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait) static int hp_sdc_rtc_open(struct inode *inode, struct file *file) { + cycle_kernel_lock(); return 0; } -- cgit v1.2.3-70-g09d2 From 656acd2bbc4ce7f224de499ee255698701396c48 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 26 Jun 2008 11:30:02 -0400 Subject: Input: fix locking in force-feedback core The newly added event_lock spinlock in the input core disallows sleeping and therefore using mutexes in event handlers. Convert force-feedback core to rely on event_lock instead of mutex to protect slots allocated for fore-feedback effects. The original mutex is still used to serialize uploading and erasing of effects. Reported-by: Anssi Hannula Signed-off-by: Dmitry Torokhov --- drivers/input/ff-core.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c index eebc72465fc..4c01464ec8f 100644 --- a/drivers/input/ff-core.c +++ b/drivers/input/ff-core.c @@ -166,8 +166,10 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, if (ret) goto out; + spin_lock_irq(&dev->event_lock); ff->effects[id] = *effect; ff->effect_owners[id] = file; + spin_unlock_irq(&dev->event_lock); out: mutex_unlock(&ff->mutex); @@ -189,16 +191,22 @@ static int erase_effect(struct input_dev *dev, int effect_id, if (error) return error; + spin_lock_irq(&dev->event_lock); ff->playback(dev, effect_id, 0); + ff->effect_owners[effect_id] = NULL; + spin_unlock_irq(&dev->event_lock); if (ff->erase) { error = ff->erase(dev, effect_id); - if (error) + if (error) { + spin_lock_irq(&dev->event_lock); + ff->effect_owners[effect_id] = file; + spin_unlock_irq(&dev->event_lock); + return error; + } } - ff->effect_owners[effect_id] = NULL; - return 0; } @@ -263,8 +271,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type, if (type != EV_FF) return 0; - mutex_lock(&ff->mutex); - switch (code) { case FF_GAIN: if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff) @@ -286,7 +292,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type, break; } - mutex_unlock(&ff->mutex); return 0; } EXPORT_SYMBOL_GPL(input_ff_event); -- cgit v1.2.3-70-g09d2 From f9c8154f367d471f1af56742fe8534f8458adb98 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:20 +0200 Subject: mousedev: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/input/mousedev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index b989748598a..8137e50ded8 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c @@ -14,6 +14,7 @@ #define MOUSEDEV_MIX 31 #include +#include #include #include #include @@ -545,16 +546,21 @@ static int mousedev_open(struct inode *inode, struct file *file) if (i >= MOUSEDEV_MINORS) return -ENODEV; + lock_kernel(); error = mutex_lock_interruptible(&mousedev_table_mutex); - if (error) + if (error) { + unlock_kernel(); return error; + } mousedev = mousedev_table[i]; if (mousedev) get_device(&mousedev->dev); mutex_unlock(&mousedev_table_mutex); - if (!mousedev) + if (!mousedev) { + unlock_kernel(); return -ENODEV; + } client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL); if (!client) { @@ -573,6 +579,7 @@ static int mousedev_open(struct inode *inode, struct file *file) goto err_free_client; file->private_data = client; + unlock_kernel(); return 0; err_free_client: @@ -580,6 +587,7 @@ static int mousedev_open(struct inode *inode, struct file *file) kfree(client); err_put_mousedev: put_device(&mousedev->dev); + unlock_kernel(); return error; } -- cgit v1.2.3-70-g09d2 From 9edca64b724db74373f0c9ef7cb044a5f221a4a3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:43 +0200 Subject: serio: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/input/serio/serio_raw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index 0403622ae26..c9397c8ee97 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -81,9 +82,10 @@ static int serio_raw_open(struct inode *inode, struct file *file) struct serio_raw_list *list; int retval = 0; + lock_kernel(); retval = mutex_lock_interruptible(&serio_raw_mutex); if (retval) - return retval; + goto out_bkl; if (!(serio_raw = serio_raw_locate(iminor(inode)))) { retval = -ENODEV; @@ -108,6 +110,8 @@ static int serio_raw_open(struct inode *inode, struct file *file) out: mutex_unlock(&serio_raw_mutex); +out_bkl: + unlock_kernel(); return retval; } -- cgit v1.2.3-70-g09d2 From 8702965848ed4bee27486a3e3d2ae34ebba6dd83 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:53 +0200 Subject: uinput: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/input/misc/uinput.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/input') diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index a56ad4ba8fe..2bcfa0b3506 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -37,6 +37,7 @@ #include #include #include +#include static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { @@ -222,6 +223,7 @@ static int uinput_open(struct inode *inode, struct file *file) if (!newdev) return -ENOMEM; + lock_kernel(); mutex_init(&newdev->mutex); spin_lock_init(&newdev->requests_lock); init_waitqueue_head(&newdev->requests_waitq); @@ -229,6 +231,7 @@ static int uinput_open(struct inode *inode, struct file *file) newdev->state = UIST_NEW_DEVICE; file->private_data = newdev; + unlock_kernel(); return 0; } -- cgit v1.2.3-70-g09d2 From 83680cdbcecd1fd284ad4df060d12bf214bb63a8 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 1 Jul 2008 13:55:25 +0200 Subject: drivers/input/ff-core.c needs Commit 656acd2bbc4ce7f224de499ee255698701396c48 ("Input: fix locking in force-feedback core") causes the following regression on m68k: | linux/drivers/input/ff-core.c: In function 'input_ff_upload': | linux/drivers/input/ff-core.c:172: error: dereferencing pointer to incomplete type | linux/drivers/input/ff-core.c: In function 'erase_effect': | linux/drivers/input/ff-core.c:197: error: dereferencing pointer to incomplete type | linux/drivers/input/ff-core.c:204: error: dereferencing pointer to incomplete type | make[4]: *** [drivers/input/ff-core.o] Error 1 As the incomplete type is `struct task_struct', including fixes it. Signed-off-by: Geert Uytterhoeven Acked-by: Dmitry Torokhov Signed-off-by: Linus Torvalds --- drivers/input/ff-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/input') diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c index 4c01464ec8f..72c63e5dd63 100644 --- a/drivers/input/ff-core.c +++ b/drivers/input/ff-core.c @@ -28,6 +28,7 @@ #include #include #include +#include /* * Check that the effect_id is a valid effect and whether the user -- cgit v1.2.3-70-g09d2 From a352def21a642133758b868c71bee12ab34ad5c5 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 16 Jul 2008 21:53:12 +0100 Subject: tty: Ldisc revamp Move the line disciplines towards a conventional ->ops arrangement. For the moment the actual 'tty_ldisc' struct in the tty is kept as part of the tty struct but this can then be changed if it turns out that when it all settles down we want to refcount ldiscs separately to the tty. Pull the ldisc code out of /proc and put it with our ldisc code. Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/bluetooth/hci_ldisc.c | 6 +- drivers/char/cyclades.c | 3 +- drivers/char/epca.c | 4 +- drivers/char/ip2/i2lib.c | 4 +- drivers/char/ip2/ip2main.c | 7 +- drivers/char/n_hdlc.c | 6 +- drivers/char/n_r3964.c | 2 +- drivers/char/n_tty.c | 2 +- drivers/char/pcmcia/synclink_cs.c | 4 +- drivers/char/pty.c | 10 +- drivers/char/selection.c | 3 +- drivers/char/synclink.c | 4 +- drivers/char/synclink_gt.c | 4 +- drivers/char/synclinkmp.c | 4 +- drivers/char/tty_io.c | 336 +++++++++++++++++++++++-------------- drivers/char/tty_ioctl.c | 16 +- drivers/input/serio/serport.c | 2 +- drivers/isdn/capi/capi.c | 4 +- drivers/isdn/gigaset/ser-gigaset.c | 2 +- drivers/net/hamradio/6pack.c | 2 +- drivers/net/hamradio/mkiss.c | 2 +- drivers/net/irda/irtty-sir.c | 2 +- drivers/net/ppp_async.c | 2 +- drivers/net/ppp_synctty.c | 2 +- drivers/net/slip.c | 2 +- drivers/net/wan/pc300_tty.c | 4 +- drivers/net/wan/x25_asy.c | 2 +- fs/proc/proc_tty.c | 48 ------ include/linux/tty.h | 9 +- include/linux/tty_ldisc.h | 7 +- net/bluetooth/rfcomm/tty.c | 13 +- net/irda/ircomm/ircomm_tty.c | 14 +- 32 files changed, 286 insertions(+), 246 deletions(-) (limited to 'drivers/input') diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index e5cd856a2fe..69df187d74c 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -282,8 +282,8 @@ static int hci_uart_tty_open(struct tty_struct *tty) /* FIXME: why is this needed. Note don't use ldisc_ref here as the open path is before the ldisc is referencable */ - if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer(tty); + if (tty->ldisc.ops->flush_buffer) + tty->ldisc.ops->flush_buffer(tty); tty_driver_flush_buffer(tty); return 0; @@ -514,7 +514,7 @@ static unsigned int hci_uart_tty_poll(struct tty_struct *tty, static int __init hci_uart_init(void) { - static struct tty_ldisc hci_uart_ldisc; + static struct tty_ldisc_ops hci_uart_ldisc; int err; BT_INFO("HCI UART driver ver %s", VERSION); diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 6bff9d87dc5..a957dbcc5a4 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -5246,7 +5246,8 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length, HZ, info->idle_stats.recv_bytes, (cur_jifs - info->idle_stats.recv_idle)/ HZ, info->idle_stats.overruns, - (long)info->tty->ldisc.num); + /* FIXME: double check locking */ + (long)info->tty->ldisc.ops->num); else size = sprintf(buf + len, "%3d %8lu %10lu %8lu " "%10lu %8lu %9lu %6ld\n", diff --git a/drivers/char/epca.c b/drivers/char/epca.c index 60a4df7dac1..aa8e19f44b4 100644 --- a/drivers/char/epca.c +++ b/drivers/char/epca.c @@ -2262,8 +2262,8 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file, tty_wait_until_sent(tty, 0); } else { /* ldisc lock already held in ioctl */ - if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer(tty); + if (tty->ldisc.ops->flush_buffer) + tty->ldisc.ops->flush_buffer(tty); } unlock_kernel(); /* Fall Thru */ diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c index 938879cc7bc..0061e18aff6 100644 --- a/drivers/char/ip2/i2lib.c +++ b/drivers/char/ip2/i2lib.c @@ -868,11 +868,11 @@ i2Input(i2ChanStrPtr pCh) amountToMove = count; } // Move the first block - pCh->pTTY->ldisc.receive_buf( pCh->pTTY, + pCh->pTTY->ldisc.ops->receive_buf( pCh->pTTY, &(pCh->Ibuf[stripIndex]), NULL, amountToMove ); // If we needed to wrap, do the second data move if (count > amountToMove) { - pCh->pTTY->ldisc.receive_buf( pCh->pTTY, + pCh->pTTY->ldisc.ops->receive_buf( pCh->pTTY, pCh->Ibuf, NULL, count - amountToMove ); } // Bump and wrap the stripIndex all at once by the amount of data read. This diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 9a2394cda94..5dc74404058 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c @@ -1289,11 +1289,12 @@ static void do_input(struct work_struct *work) // code duplicated from n_tty (ldisc) static inline void isig(int sig, struct tty_struct *tty, int flush) { + /* FIXME: This is completely bogus */ if (tty->pgrp) kill_pgrp(tty->pgrp, sig, 1); if (flush || !L_NOFLSH(tty)) { - if ( tty->ldisc.flush_buffer ) - tty->ldisc.flush_buffer(tty); + if ( tty->ldisc.ops->flush_buffer ) + tty->ldisc.ops->flush_buffer(tty); i2InputFlush( tty->driver_data ); } } @@ -1342,7 +1343,7 @@ static void do_status(struct work_struct *work) } tmp = pCh->pTTY->real_raw; pCh->pTTY->real_raw = 0; - pCh->pTTY->ldisc.receive_buf( pCh->pTTY, &brkc, &brkf, 1 ); + pCh->pTTY->ldisc->ops.receive_buf( pCh->pTTY, &brkc, &brkf, 1 ); pCh->pTTY->real_raw = tmp; } #endif /* NEVER_HAPPENS_AS_SETUP_XXX */ diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c index a35bfd7ee80..ed4e03333ab 100644 --- a/drivers/char/n_hdlc.c +++ b/drivers/char/n_hdlc.c @@ -199,7 +199,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty); #define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data)) #define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty) -static struct tty_ldisc n_hdlc_ldisc = { +static struct tty_ldisc_ops n_hdlc_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "hdlc", @@ -342,8 +342,8 @@ static int n_hdlc_tty_open (struct tty_struct *tty) #endif /* Flush any pending characters in the driver and discipline. */ - if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer(tty); + if (tty->ldisc.ops->flush_buffer) + tty->ldisc.ops->flush_buffer(tty); tty_driver_flush_buffer(tty); diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index 90216906233..ae377aa473b 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c @@ -143,7 +143,7 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count); -static struct tty_ldisc tty_ldisc_N_R3964 = { +static struct tty_ldisc_ops tty_ldisc_N_R3964 = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "R3964", diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 8096389b0dc..708c2b1dbe5 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -1573,7 +1573,7 @@ static unsigned int normal_poll(struct tty_struct *tty, struct file *file, return mask; } -struct tty_ldisc tty_ldisc_N_TTY = { +struct tty_ldisc_ops tty_ldisc_N_TTY = { .magic = TTY_LDISC_MAGIC, .name = "n_tty", .open = n_tty_open, diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 1dd0e992c83..95743e2682f 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -514,8 +514,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, return; ld = tty_ldisc_ref(tty); if (ld) { - if (ld->receive_buf) - ld->receive_buf(tty, data, flags, count); + if (ld->ops->receive_buf) + ld->ops->receive_buf(tty, data, flags, count); tty_ldisc_deref(ld); } } diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 0a05c038ae6..76b27932d22 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -111,7 +111,7 @@ static int pty_write(struct tty_struct * tty, const unsigned char *buf, int coun c = to->receive_room; if (c > count) c = count; - to->ldisc.receive_buf(to, buf, NULL, c); + to->ldisc.ops->receive_buf(to, buf, NULL, c); return c; } @@ -149,11 +149,11 @@ static int pty_chars_in_buffer(struct tty_struct *tty) int count; /* We should get the line discipline lock for "tty->link" */ - if (!to || !to->ldisc.chars_in_buffer) + if (!to || !to->ldisc.ops->chars_in_buffer) return 0; /* The ldisc must report 0 if no characters available to be read */ - count = to->ldisc.chars_in_buffer(to); + count = to->ldisc.ops->chars_in_buffer(to); if (tty->driver->subtype == PTY_TYPE_SLAVE) return count; @@ -186,8 +186,8 @@ static void pty_flush_buffer(struct tty_struct *tty) if (!to) return; - if (to->ldisc.flush_buffer) - to->ldisc.flush_buffer(to); + if (to->ldisc.ops->flush_buffer) + to->ldisc.ops->flush_buffer(to); if (to->packet) { spin_lock_irqsave(&tty->ctrl_lock, flags); diff --git a/drivers/char/selection.c b/drivers/char/selection.c index d63f5ccc29e..2978a49a172 100644 --- a/drivers/char/selection.c +++ b/drivers/char/selection.c @@ -327,7 +327,8 @@ int paste_selection(struct tty_struct *tty) } count = sel_buffer_lth - pasted; count = min(count, tty->receive_room); - tty->ldisc.receive_buf(tty, sel_buffer + pasted, NULL, count); + tty->ldisc.ops->receive_buf(tty, sel_buffer + pasted, + NULL, count); pasted += count; } remove_wait_queue(&vc->paste_wait, &wait); diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index ac5080df256..5e4b2e638d0 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -975,8 +975,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, return; ld = tty_ldisc_ref(tty); if (ld) { - if (ld->receive_buf) - ld->receive_buf(tty, data, flags, count); + if (ld->ops->receive_buf) + ld->ops->receive_buf(tty, data, flags, count); tty_ldisc_deref(ld); } } diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 55c1653be00..e473778cd6f 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -641,8 +641,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, return; ld = tty_ldisc_ref(tty); if (ld) { - if (ld->receive_buf) - ld->receive_buf(tty, data, flags, count); + if (ld->ops->receive_buf) + ld->ops->receive_buf(tty, data, flags, count); tty_ldisc_deref(ld); } } diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index bec54866e0b..5341b5aaf8b 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -712,8 +712,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, return; ld = tty_ldisc_ref(tty); if (ld) { - if (ld->receive_buf) - ld->receive_buf(tty, data, flags, count); + if (ld->ops->receive_buf) + ld->ops->receive_buf(tty, data, flags, count); tty_ldisc_deref(ld); } } diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 047a17339f8..54c4ada460e 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -95,8 +95,9 @@ #include #include #include +#include -#include +#include #include #include @@ -682,7 +683,7 @@ static void tty_set_termios_ldisc(struct tty_struct *tty, int num) static DEFINE_SPINLOCK(tty_ldisc_lock); static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait); /* Line disc dispatch table */ -static struct tty_ldisc tty_ldiscs[NR_LDISCS]; +static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; /** * tty_register_ldisc - install a line discipline @@ -697,7 +698,7 @@ static struct tty_ldisc tty_ldiscs[NR_LDISCS]; * takes tty_ldisc_lock to guard against ldisc races */ -int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc) +int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc) { unsigned long flags; int ret = 0; @@ -706,10 +707,9 @@ int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc) return -EINVAL; spin_lock_irqsave(&tty_ldisc_lock, flags); - tty_ldiscs[disc] = *new_ldisc; - tty_ldiscs[disc].num = disc; - tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED; - tty_ldiscs[disc].refcount = 0; + tty_ldiscs[disc] = new_ldisc; + new_ldisc->num = disc; + new_ldisc->refcount = 0; spin_unlock_irqrestore(&tty_ldisc_lock, flags); return ret; @@ -737,19 +737,56 @@ int tty_unregister_ldisc(int disc) return -EINVAL; spin_lock_irqsave(&tty_ldisc_lock, flags); - if (tty_ldiscs[disc].refcount) + if (tty_ldiscs[disc]->refcount) ret = -EBUSY; else - tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED; + tty_ldiscs[disc] = NULL; spin_unlock_irqrestore(&tty_ldisc_lock, flags); return ret; } EXPORT_SYMBOL(tty_unregister_ldisc); + +/** + * tty_ldisc_try_get - try and reference an ldisc + * @disc: ldisc number + * @ld: tty ldisc structure to complete + * + * Attempt to open and lock a line discipline into place. Return + * the line discipline refcounted and assigned in ld. On an error + * report the error code back + */ + +static int tty_ldisc_try_get(int disc, struct tty_ldisc *ld) +{ + unsigned long flags; + struct tty_ldisc_ops *ldops; + int err = -EINVAL; + + spin_lock_irqsave(&tty_ldisc_lock, flags); + ld->ops = NULL; + ldops = tty_ldiscs[disc]; + /* Check the entry is defined */ + if (ldops) { + /* If the module is being unloaded we can't use it */ + if (!try_module_get(ldops->owner)) + err = -EAGAIN; + else { + /* lock it */ + ldops->refcount++; + ld->ops = ldops; + err = 0; + } + } + spin_unlock_irqrestore(&tty_ldisc_lock, flags); + return err; +} + /** * tty_ldisc_get - take a reference to an ldisc * @disc: ldisc number + * @ld: tty line discipline structure to use * * Takes a reference to a line discipline. Deals with refcounts and * module locking counts. Returns NULL if the discipline is not available. @@ -760,32 +797,20 @@ EXPORT_SYMBOL(tty_unregister_ldisc); * takes tty_ldisc_lock to guard against ldisc races */ -struct tty_ldisc *tty_ldisc_get(int disc) +static int tty_ldisc_get(int disc, struct tty_ldisc *ld) { - unsigned long flags; - struct tty_ldisc *ld; + int err; if (disc < N_TTY || disc >= NR_LDISCS) - return NULL; - - spin_lock_irqsave(&tty_ldisc_lock, flags); - - ld = &tty_ldiscs[disc]; - /* Check the entry is defined */ - if (ld->flags & LDISC_FLAG_DEFINED) { - /* If the module is being unloaded we can't use it */ - if (!try_module_get(ld->owner)) - ld = NULL; - else /* lock it */ - ld->refcount++; - } else - ld = NULL; - spin_unlock_irqrestore(&tty_ldisc_lock, flags); - return ld; + return -EINVAL; + err = tty_ldisc_try_get(disc, ld); + if (err == -EAGAIN) { + request_module("tty-ldisc-%d", disc); + err = tty_ldisc_try_get(disc, ld); + } + return err; } -EXPORT_SYMBOL_GPL(tty_ldisc_get); - /** * tty_ldisc_put - drop ldisc reference * @disc: ldisc number @@ -797,22 +822,67 @@ EXPORT_SYMBOL_GPL(tty_ldisc_get); * takes tty_ldisc_lock to guard against ldisc races */ -void tty_ldisc_put(int disc) +static void tty_ldisc_put(struct tty_ldisc_ops *ld) { - struct tty_ldisc *ld; unsigned long flags; + int disc = ld->num; BUG_ON(disc < N_TTY || disc >= NR_LDISCS); spin_lock_irqsave(&tty_ldisc_lock, flags); - ld = &tty_ldiscs[disc]; + ld = tty_ldiscs[disc]; BUG_ON(ld->refcount == 0); ld->refcount--; module_put(ld->owner); spin_unlock_irqrestore(&tty_ldisc_lock, flags); } -EXPORT_SYMBOL_GPL(tty_ldisc_put); +static void * tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) +{ + return (*pos < NR_LDISCS) ? pos : NULL; +} + +static void * tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos) +{ + (*pos)++; + return (*pos < NR_LDISCS) ? pos : NULL; +} + +static void tty_ldiscs_seq_stop(struct seq_file *m, void *v) +{ +} + +static int tty_ldiscs_seq_show(struct seq_file *m, void *v) +{ + int i = *(loff_t *)v; + struct tty_ldisc ld; + + if (tty_ldisc_get(i, &ld) < 0) + return 0; + seq_printf(m, "%-10s %2d\n", ld.ops->name ? ld.ops->name : "???", i); + tty_ldisc_put(ld.ops); + return 0; +} + +static const struct seq_operations tty_ldiscs_seq_ops = { + .start = tty_ldiscs_seq_start, + .next = tty_ldiscs_seq_next, + .stop = tty_ldiscs_seq_stop, + .show = tty_ldiscs_seq_show, +}; + +static int proc_tty_ldiscs_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &tty_ldiscs_seq_ops); +} + +const struct file_operations tty_ldiscs_proc_fops = { + .owner = THIS_MODULE, + .open = proc_tty_ldiscs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; /** * tty_ldisc_assign - set ldisc on a tty @@ -829,8 +899,8 @@ EXPORT_SYMBOL_GPL(tty_ldisc_put); static void tty_ldisc_assign(struct tty_struct *tty, struct tty_ldisc *ld) { + ld->refcount = 0; tty->ldisc = *ld; - tty->ldisc.refcount = 0; } /** @@ -953,6 +1023,41 @@ static void tty_ldisc_enable(struct tty_struct *tty) wake_up(&tty_ldisc_wait); } +/** + * tty_ldisc_restore - helper for tty ldisc change + * @tty: tty to recover + * @old: previous ldisc + * + * Restore the previous line discipline or N_TTY when a line discipline + * change fails due to an open error + */ + +static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) +{ + char buf[64]; + struct tty_ldisc new_ldisc; + + /* There is an outstanding reference here so this is safe */ + tty_ldisc_get(old->ops->num, old); + tty_ldisc_assign(tty, old); + tty_set_termios_ldisc(tty, old->ops->num); + if (old->ops->open && (old->ops->open(tty) < 0)) { + tty_ldisc_put(old->ops); + /* This driver is always present */ + if (tty_ldisc_get(N_TTY, &new_ldisc) < 0) + panic("n_tty: get"); + tty_ldisc_assign(tty, &new_ldisc); + tty_set_termios_ldisc(tty, N_TTY); + if (new_ldisc.ops->open) { + int r = new_ldisc.ops->open(tty); + if (r < 0) + panic("Couldn't open N_TTY ldisc for " + "%s --- error %d.", + tty_name(tty, buf), r); + } + } +} + /** * tty_set_ldisc - set line discipline * @tty: the terminal to set @@ -967,28 +1072,18 @@ static void tty_ldisc_enable(struct tty_struct *tty) static int tty_set_ldisc(struct tty_struct *tty, int ldisc) { - int retval = 0; - struct tty_ldisc o_ldisc; - char buf[64]; + int retval; + struct tty_ldisc o_ldisc, new_ldisc; int work; unsigned long flags; - struct tty_ldisc *ld; struct tty_struct *o_tty; - if ((ldisc < N_TTY) || (ldisc >= NR_LDISCS)) - return -EINVAL; - restart: - - ld = tty_ldisc_get(ldisc); - /* Eduardo Blanco */ - /* Cyrus Durgin */ - if (ld == NULL) { - request_module("tty-ldisc-%d", ldisc); - ld = tty_ldisc_get(ldisc); - } - if (ld == NULL) - return -EINVAL; + /* This is a bit ugly for now but means we can break the 'ldisc + is part of the tty struct' assumption later */ + retval = tty_ldisc_get(ldisc, &new_ldisc); + if (retval) + return retval; /* * Problem: What do we do if this blocks ? @@ -996,8 +1091,8 @@ restart: tty_wait_until_sent(tty, 0); - if (tty->ldisc.num == ldisc) { - tty_ldisc_put(ldisc); + if (tty->ldisc.ops->num == ldisc) { + tty_ldisc_put(new_ldisc.ops); return 0; } @@ -1024,7 +1119,7 @@ restart: /* Free the new ldisc we grabbed. Must drop the lock first. */ spin_unlock_irqrestore(&tty_ldisc_lock, flags); - tty_ldisc_put(ldisc); + tty_ldisc_put(o_ldisc.ops); /* * There are several reasons we may be busy, including * random momentary I/O traffic. We must therefore @@ -1038,7 +1133,7 @@ restart: } if (o_tty && o_tty->ldisc.refcount) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); - tty_ldisc_put(ldisc); + tty_ldisc_put(o_tty->ldisc.ops); if (wait_event_interruptible(tty_ldisc_wait, o_tty->ldisc.refcount == 0) < 0) return -ERESTARTSYS; goto restart; @@ -1049,8 +1144,9 @@ restart: * another ldisc change */ if (!test_bit(TTY_LDISC, &tty->flags)) { + struct tty_ldisc *ld; spin_unlock_irqrestore(&tty_ldisc_lock, flags); - tty_ldisc_put(ldisc); + tty_ldisc_put(new_ldisc.ops); ld = tty_ldisc_ref_wait(tty); tty_ldisc_deref(ld); goto restart; @@ -1060,7 +1156,7 @@ restart: if (o_tty) clear_bit(TTY_LDISC, &o_tty->flags); spin_unlock_irqrestore(&tty_ldisc_lock, flags); - + /* * From this point on we know nobody has an ldisc * usage reference, nor can they obtain one until @@ -1070,45 +1166,30 @@ restart: work = cancel_delayed_work(&tty->buf.work); /* * Wait for ->hangup_work and ->buf.work handlers to terminate + * MUST NOT hold locks here. */ flush_scheduled_work(); /* Shutdown the current discipline. */ - if (tty->ldisc.close) - (tty->ldisc.close)(tty); + if (o_ldisc.ops->close) + (o_ldisc.ops->close)(tty); /* Now set up the new line discipline. */ - tty_ldisc_assign(tty, ld); + tty_ldisc_assign(tty, &new_ldisc); tty_set_termios_ldisc(tty, ldisc); - if (tty->ldisc.open) - retval = (tty->ldisc.open)(tty); + if (new_ldisc.ops->open) + retval = (new_ldisc.ops->open)(tty); if (retval < 0) { - tty_ldisc_put(ldisc); - /* There is an outstanding reference here so this is safe */ - tty_ldisc_assign(tty, tty_ldisc_get(o_ldisc.num)); - tty_set_termios_ldisc(tty, tty->ldisc.num); - if (tty->ldisc.open && (tty->ldisc.open(tty) < 0)) { - tty_ldisc_put(o_ldisc.num); - /* This driver is always present */ - tty_ldisc_assign(tty, tty_ldisc_get(N_TTY)); - tty_set_termios_ldisc(tty, N_TTY); - if (tty->ldisc.open) { - int r = tty->ldisc.open(tty); - - if (r < 0) - panic("Couldn't open N_TTY ldisc for " - "%s --- error %d.", - tty_name(tty, buf), r); - } - } + tty_ldisc_put(new_ldisc.ops); + tty_ldisc_restore(tty, &o_ldisc); } /* At this point we hold a reference to the new ldisc and a a reference to the old ldisc. If we ended up flipping back to the existing ldisc we have two references to it */ - if (tty->ldisc.num != o_ldisc.num && tty->ops->set_ldisc) + if (tty->ldisc.ops->num != o_ldisc.ops->num && tty->ops->set_ldisc) tty->ops->set_ldisc(tty); - tty_ldisc_put(o_ldisc.num); + tty_ldisc_put(o_ldisc.ops); /* * Allow ldisc referencing to occur as soon as the driver @@ -1335,8 +1416,8 @@ void tty_wakeup(struct tty_struct *tty) if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) { ld = tty_ldisc_ref(tty); if (ld) { - if (ld->write_wakeup) - ld->write_wakeup(tty); + if (ld->ops->write_wakeup) + ld->ops->write_wakeup(tty); tty_ldisc_deref(ld); } } @@ -1357,8 +1438,8 @@ void tty_ldisc_flush(struct tty_struct *tty) { struct tty_ldisc *ld = tty_ldisc_ref(tty); if (ld) { - if (ld->flush_buffer) - ld->flush_buffer(tty); + if (ld->ops->flush_buffer) + ld->ops->flush_buffer(tty); tty_ldisc_deref(ld); } tty_buffer_flush(tty); @@ -1386,7 +1467,7 @@ static void tty_reset_termios(struct tty_struct *tty) * do_tty_hangup - actual handler for hangup events * @work: tty device * - * This can be called by the "eventd" kernel thread. That is process +k * This can be called by the "eventd" kernel thread. That is process * synchronous but doesn't hold any locks, so we need to make sure we * have the appropriate locks for what we're doing. * @@ -1449,14 +1530,14 @@ static void do_tty_hangup(struct work_struct *work) ld = tty_ldisc_ref(tty); if (ld != NULL) { /* We may have no line discipline at this point */ - if (ld->flush_buffer) - ld->flush_buffer(tty); + if (ld->ops->flush_buffer) + ld->ops->flush_buffer(tty); tty_driver_flush_buffer(tty); if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) && - ld->write_wakeup) - ld->write_wakeup(tty); - if (ld->hangup) - ld->hangup(tty); + ld->ops->write_wakeup) + ld->ops->write_wakeup(tty); + if (ld->ops->hangup) + ld->ops->hangup(tty); } /* * FIXME: Once we trust the LDISC code better we can wait here for @@ -1825,8 +1906,8 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count, /* We want to wait for the line discipline to sort out in this situation */ ld = tty_ldisc_ref_wait(tty); - if (ld->read) - i = (ld->read)(tty, file, buf, count); + if (ld->ops->read) + i = (ld->ops->read)(tty, file, buf, count); else i = -EIO; tty_ldisc_deref(ld); @@ -1978,10 +2059,10 @@ static ssize_t tty_write(struct file *file, const char __user *buf, printk(KERN_ERR "tty driver %s lacks a write_room method.\n", tty->driver->name); ld = tty_ldisc_ref_wait(tty); - if (!ld->write) + if (!ld->ops->write) ret = -EIO; else - ret = do_tty_write(ld->write, tty, file, buf, count); + ret = do_tty_write(ld->ops->write, tty, file, buf, count); tty_ldisc_deref(ld); return ret; } @@ -2076,6 +2157,7 @@ static int init_dev(struct tty_driver *driver, int idx, struct ktermios *tp, **tp_loc, *o_tp, **o_tp_loc; struct ktermios *ltp, **ltp_loc, *o_ltp, **o_ltp_loc; int retval = 0; + struct tty_ldisc *ld; /* check whether we're reopening an existing tty */ if (driver->flags & TTY_DRIVER_DEVPTS_MEM) { @@ -2224,17 +2306,19 @@ static int init_dev(struct tty_driver *driver, int idx, * If we fail here just call release_tty to clean up. No need * to decrement the use counts, as release_tty doesn't care. */ + + ld = &tty->ldisc; - if (tty->ldisc.open) { - retval = (tty->ldisc.open)(tty); + if (ld->ops->open) { + retval = (ld->ops->open)(tty); if (retval) goto release_mem_out; } - if (o_tty && o_tty->ldisc.open) { - retval = (o_tty->ldisc.open)(o_tty); + if (o_tty && o_tty->ldisc.ops->open) { + retval = (o_tty->ldisc.ops->open)(o_tty); if (retval) { - if (tty->ldisc.close) - (tty->ldisc.close)(tty); + if (ld->ops->close) + (ld->ops->close)(tty); goto release_mem_out; } tty_ldisc_enable(o_tty); @@ -2378,6 +2462,7 @@ static void release_tty(struct tty_struct *tty, int idx) static void release_dev(struct file *filp) { struct tty_struct *tty, *o_tty; + struct tty_ldisc ld; int pty_master, tty_closing, o_tty_closing, do_sleep; int devpts; int idx; @@ -2611,26 +2696,27 @@ static void release_dev(struct file *filp) spin_unlock_irqrestore(&tty_ldisc_lock, flags); /* * Shutdown the current line discipline, and reset it to N_TTY. - * N.B. why reset ldisc when we're releasing the memory?? * * FIXME: this MUST get fixed for the new reflocking */ - if (tty->ldisc.close) - (tty->ldisc.close)(tty); - tty_ldisc_put(tty->ldisc.num); + if (tty->ldisc.ops->close) + (tty->ldisc.ops->close)(tty); + tty_ldisc_put(tty->ldisc.ops); /* * Switch the line discipline back */ - tty_ldisc_assign(tty, tty_ldisc_get(N_TTY)); + WARN_ON(tty_ldisc_get(N_TTY, &ld)); + tty_ldisc_assign(tty, &ld); tty_set_termios_ldisc(tty, N_TTY); if (o_tty) { /* FIXME: could o_tty be in setldisc here ? */ clear_bit(TTY_LDISC, &o_tty->flags); - if (o_tty->ldisc.close) - (o_tty->ldisc.close)(o_tty); - tty_ldisc_put(o_tty->ldisc.num); - tty_ldisc_assign(o_tty, tty_ldisc_get(N_TTY)); + if (o_tty->ldisc.ops->close) + (o_tty->ldisc.ops->close)(o_tty); + tty_ldisc_put(o_tty->ldisc.ops); + WARN_ON(tty_ldisc_get(N_TTY, &ld)); + tty_ldisc_assign(o_tty, &ld); tty_set_termios_ldisc(o_tty, N_TTY); } /* @@ -2899,8 +2985,8 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait) return 0; ld = tty_ldisc_ref_wait(tty); - if (ld->poll) - ret = (ld->poll)(tty, filp, wait); + if (ld->ops->poll) + ret = (ld->ops->poll)(tty, filp, wait); tty_ldisc_deref(ld); return ret; } @@ -2974,7 +3060,7 @@ static int tiocsti(struct tty_struct *tty, char __user *p) if (get_user(ch, p)) return -EFAULT; ld = tty_ldisc_ref_wait(tty); - ld->receive_buf(tty, &ch, &mbz, 1); + ld->ops->receive_buf(tty, &ch, &mbz, 1); tty_ldisc_deref(ld); return 0; } @@ -3528,7 +3614,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case TIOCGSID: return tiocgsid(tty, real_tty, p); case TIOCGETD: - return put_user(tty->ldisc.num, (int __user *)p); + return put_user(tty->ldisc.ops->num, (int __user *)p); case TIOCSETD: return tiocsetd(tty, p); #ifdef CONFIG_VT @@ -3581,8 +3667,8 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } ld = tty_ldisc_ref_wait(tty); retval = -EINVAL; - if (ld->ioctl) { - retval = ld->ioctl(tty, file, cmd, arg); + if (ld->ops->ioctl) { + retval = ld->ops->ioctl(tty, file, cmd, arg); if (retval == -ENOIOCTLCMD) retval = -EINVAL; } @@ -3609,8 +3695,8 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd, } ld = tty_ldisc_ref_wait(tty); - if (ld->compat_ioctl) - retval = ld->compat_ioctl(tty, file, cmd, arg); + if (ld->ops->compat_ioctl) + retval = ld->ops->compat_ioctl(tty, file, cmd, arg); tty_ldisc_deref(ld); return retval; @@ -3782,7 +3868,8 @@ static void flush_to_ldisc(struct work_struct *work) flag_buf = head->flag_buf_ptr + head->read; head->read += count; spin_unlock_irqrestore(&tty->buf.lock, flags); - disc->receive_buf(tty, char_buf, flag_buf, count); + disc->ops->receive_buf(tty, char_buf, + flag_buf, count); spin_lock_irqsave(&tty->buf.lock, flags); } /* Restore the queue head */ @@ -3843,9 +3930,12 @@ EXPORT_SYMBOL(tty_flip_buffer_push); static void initialize_tty_struct(struct tty_struct *tty) { + struct tty_ldisc ld; memset(tty, 0, sizeof(struct tty_struct)); tty->magic = TTY_MAGIC; - tty_ldisc_assign(tty, tty_ldisc_get(N_TTY)); + if (tty_ldisc_get(N_TTY, &ld) < 0) + panic("n_tty: init_tty"); + tty_ldisc_assign(tty, &ld); tty->session = NULL; tty->pgrp = NULL; tty->overrun_time = jiffies; diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c index 8f81139d619..ea9fc5d03b9 100644 --- a/drivers/char/tty_ioctl.c +++ b/drivers/char/tty_ioctl.c @@ -491,8 +491,8 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios) ld = tty_ldisc_ref(tty); if (ld != NULL) { - if (ld->set_termios) - (ld->set_termios)(tty, &old_termios); + if (ld->ops->set_termios) + (ld->ops->set_termios)(tty, &old_termios); tty_ldisc_deref(ld); } mutex_unlock(&tty->termios_mutex); @@ -552,8 +552,8 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt) ld = tty_ldisc_ref(tty); if (ld != NULL) { - if ((opt & TERMIOS_FLUSH) && ld->flush_buffer) - ld->flush_buffer(tty); + if ((opt & TERMIOS_FLUSH) && ld->ops->flush_buffer) + ld->ops->flush_buffer(tty); tty_ldisc_deref(ld); } @@ -959,12 +959,12 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg) ld = tty_ldisc_ref(tty); switch (arg) { case TCIFLUSH: - if (ld && ld->flush_buffer) - ld->flush_buffer(tty); + if (ld && ld->ops->flush_buffer) + ld->ops->flush_buffer(tty); break; case TCIOFLUSH: - if (ld && ld->flush_buffer) - ld->flush_buffer(tty); + if (ld && ld->ops->flush_buffer) + ld->ops->flush_buffer(tty); /* fall through */ case TCOFLUSH: tty_driver_flush_buffer(tty); diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c index 7ff71ba7b7c..b9694b6445d 100644 --- a/drivers/input/serio/serport.c +++ b/drivers/input/serio/serport.c @@ -216,7 +216,7 @@ static void serport_ldisc_write_wakeup(struct tty_struct * tty) * The line discipline structure. */ -static struct tty_ldisc serport_ldisc = { +static struct tty_ldisc_ops serport_ldisc = { .owner = THIS_MODULE, .name = "input", .open = serport_ldisc_open, diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 2095153582f..8a35029caca 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -466,7 +466,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) ld = tty_ldisc_ref(mp->tty); if (ld == NULL) return -1; - if (ld->receive_buf == NULL) { + if (ld->ops->receive_buf == NULL) { #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) printk(KERN_DEBUG "capi: ldisc has no receive_buf function\n"); #endif @@ -501,7 +501,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) printk(KERN_DEBUG "capi: DATA_B3_RESP %u len=%d => ldisc\n", datahandle, skb->len); #endif - ld->receive_buf(mp->tty, skb->data, NULL, skb->len); + ld->ops->receive_buf(mp->tty, skb->data, NULL, skb->len); kfree_skb(skb); tty_ldisc_deref(ld); return 0; diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c index 45d1ee93cd3..5e89fa17781 100644 --- a/drivers/isdn/gigaset/ser-gigaset.c +++ b/drivers/isdn/gigaset/ser-gigaset.c @@ -766,7 +766,7 @@ gigaset_tty_wakeup(struct tty_struct *tty) cs_put(cs); } -static struct tty_ldisc gigaset_ldisc = { +static struct tty_ldisc_ops gigaset_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "ser_gigaset", diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index 9d5721287d6..19dd0a61749 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c @@ -783,7 +783,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file, return err; } -static struct tty_ldisc sp_ldisc = { +static struct tty_ldisc_ops sp_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "6pack", diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 65166035aca..c6ca47599fd 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c @@ -969,7 +969,7 @@ out: mkiss_put(ax); } -static struct tty_ldisc ax_ldisc = { +static struct tty_ldisc_ops ax_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "mkiss", diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c index e6f40b7f904..9e33196f945 100644 --- a/drivers/net/irda/irtty-sir.c +++ b/drivers/net/irda/irtty-sir.c @@ -533,7 +533,7 @@ static void irtty_close(struct tty_struct *tty) /* ------------------------------------------------------- */ -static struct tty_ldisc irda_ldisc = { +static struct tty_ldisc_ops irda_ldisc = { .magic = TTY_LDISC_MAGIC, .name = "irda", .flags = 0, diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c index f1a52def124..451bdb57d6f 100644 --- a/drivers/net/ppp_async.c +++ b/drivers/net/ppp_async.c @@ -378,7 +378,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty) } -static struct tty_ldisc ppp_ldisc = { +static struct tty_ldisc_ops ppp_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "ppp", diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c index b8f0369a71e..801d8f99d47 100644 --- a/drivers/net/ppp_synctty.c +++ b/drivers/net/ppp_synctty.c @@ -418,7 +418,7 @@ ppp_sync_wakeup(struct tty_struct *tty) } -static struct tty_ldisc ppp_sync_ldisc = { +static struct tty_ldisc_ops ppp_sync_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "pppsync", diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 84af68fdb6c..1d58991d395 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -1301,7 +1301,7 @@ static int sl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) #endif /* VSV changes end */ -static struct tty_ldisc sl_ldisc = { +static struct tty_ldisc_ops sl_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "slip", diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c index e03eef2f228..c2c10c63226 100644 --- a/drivers/net/wan/pc300_tty.c +++ b/drivers/net/wan/pc300_tty.c @@ -688,9 +688,9 @@ static void cpc_tty_rx_work(struct work_struct *work) if (cpc_tty->tty) { ld = tty_ldisc_ref(cpc_tty->tty); if (ld) { - if (ld->receive_buf) { + if (ld->ops->receive_buf) { CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name); - ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size); + ld->ops->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size); } tty_ldisc_deref(ld); } diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 069f8bb0a99..2a6c7a60756 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c @@ -754,7 +754,7 @@ static void x25_asy_setup(struct net_device *dev) dev->flags = IFF_NOARP; } -static struct tty_ldisc x25_ldisc = { +static struct tty_ldisc_ops x25_ldisc = { .owner = THIS_MODULE, .magic = TTY_LDISC_MAGIC, .name = "X.25", diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c index 21f490f5d65..d153946d6d1 100644 --- a/fs/proc/proc_tty.c +++ b/fs/proc/proc_tty.c @@ -136,54 +136,6 @@ static const struct file_operations proc_tty_drivers_operations = { .release = seq_release, }; -static void * tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) -{ - return (*pos < NR_LDISCS) ? pos : NULL; -} - -static void * tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos) -{ - (*pos)++; - return (*pos < NR_LDISCS) ? pos : NULL; -} - -static void tty_ldiscs_seq_stop(struct seq_file *m, void *v) -{ -} - -static int tty_ldiscs_seq_show(struct seq_file *m, void *v) -{ - int i = *(loff_t *)v; - struct tty_ldisc *ld; - - ld = tty_ldisc_get(i); - if (ld == NULL) - return 0; - seq_printf(m, "%-10s %2d\n", ld->name ? ld->name : "???", i); - tty_ldisc_put(i); - return 0; -} - -static const struct seq_operations tty_ldiscs_seq_ops = { - .start = tty_ldiscs_seq_start, - .next = tty_ldiscs_seq_next, - .stop = tty_ldiscs_seq_stop, - .show = tty_ldiscs_seq_show, -}; - -static int proc_tty_ldiscs_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &tty_ldiscs_seq_ops); -} - -static const struct file_operations tty_ldiscs_proc_fops = { - .owner = THIS_MODULE, - .open = proc_tty_ldiscs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - /* * This function is called by tty_register_driver() to handle * registering the driver's /proc handler into /proc/tty/driver/ diff --git a/include/linux/tty.h b/include/linux/tty.h index 324a3b231d4..013711ea738 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -185,6 +185,7 @@ struct tty_struct { struct tty_driver *driver; const struct tty_operations *ops; int index; + /* The ldisc objects are protected by tty_ldisc_lock at the moment */ struct tty_ldisc ldisc; struct mutex termios_mutex; spinlock_t ctrl_lock; @@ -289,7 +290,7 @@ extern void tty_wait_until_sent(struct tty_struct * tty, long timeout); extern int tty_check_change(struct tty_struct * tty); extern void stop_tty(struct tty_struct * tty); extern void start_tty(struct tty_struct * tty); -extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); +extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc); extern int tty_unregister_ldisc(int disc); extern int tty_register_driver(struct tty_driver *driver); extern int tty_unregister_driver(struct tty_driver *driver); @@ -330,9 +331,7 @@ extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b); extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); extern void tty_ldisc_deref(struct tty_ldisc *); extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *); - -extern struct tty_ldisc *tty_ldisc_get(int); -extern void tty_ldisc_put(int); +extern const struct file_operations tty_ldiscs_proc_fops; extern void tty_wakeup(struct tty_struct *tty); extern void tty_ldisc_flush(struct tty_struct *tty); @@ -354,7 +353,7 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay); /* n_tty.c */ -extern struct tty_ldisc tty_ldisc_N_TTY; +extern struct tty_ldisc_ops tty_ldisc_N_TTY; /* tty_audit.c */ #ifdef CONFIG_AUDIT diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index 6226504d910..40f38d89677 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -104,7 +104,7 @@ #include #include -struct tty_ldisc { +struct tty_ldisc_ops { int magic; char *name; int num; @@ -142,6 +142,11 @@ struct tty_ldisc { int refcount; }; +struct tty_ldisc { + struct tty_ldisc_ops *ops; + int refcount; +}; + #define TTY_LDISC_MAGIC 0x5403 #define LDISC_FLAG_DEFINED 0x00000001 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index c9191871c1e..0a387f2eb7a 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -617,14 +617,7 @@ static void rfcomm_tty_wakeup(unsigned long arg) return; BT_DBG("dev %p tty %p", dev, tty); - - if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); - - wake_up_interruptible(&tty->write_wait); -#ifdef SERIAL_HAVE_POLL_WAIT - wake_up_interruptible(&tty->poll_wait); -#endif + tty_wakeup(tty); } static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) @@ -1005,9 +998,7 @@ static void rfcomm_tty_flush_buffer(struct tty_struct *tty) return; skb_queue_purge(&dev->dlc->tx_queue); - - if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup) - tty->ldisc.write_wakeup(tty); + tty_wakeup(tty); } static void rfcomm_tty_send_xchar(struct tty_struct *tty, char ch) diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 76c3057d017..e4e2caeb9d8 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -650,12 +650,7 @@ static void ircomm_tty_do_softint(struct work_struct *work) } /* Check if user (still) wants to be waken up */ - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) - { - (tty->ldisc.write_wakeup)(tty); - } - wake_up_interruptible(&tty->write_wait); + tty_wakeup(tty); } /* @@ -1141,6 +1136,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap, struct sk_buff *skb) { struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; + struct tty_ldisc *ld; IRDA_DEBUG(2, "%s()\n", __func__ ); @@ -1173,7 +1169,11 @@ static int ircomm_tty_data_indication(void *instance, void *sap, * involve the flip buffers, since we are not running in an interrupt * handler */ - self->tty->ldisc.receive_buf(self->tty, skb->data, NULL, skb->len); + + ld = tty_ldisc_ref(self->tty); + if (ld) + ld->ops->receive_buf(self->tty, skb->data, NULL, skb->len); + tty_ldisc_deref(ld); /* No need to kfree_skb - see ircomm_ttp_data_indication() */ -- cgit v1.2.3-70-g09d2 From e945b568e28b42de893ef24989372f0219501d32 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 17 Jul 2008 21:16:10 +0200 Subject: m68k: Return -ENODEV if no device is found According to the tests in do_initcalls(), the proper error code in case no device is found is -ENODEV, not -ENXIO or -EIO. Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/block/ataflop.c | 4 ++-- drivers/char/nvram.c | 2 +- drivers/input/keyboard/atakbd.c | 2 +- drivers/video/atafb.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/input') diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 424995073c6..49f274197b1 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1880,11 +1880,11 @@ static int __init atari_floppy_init (void) if (!MACH_IS_ATARI) /* Amiga, Mac, ... don't have Atari-compatible floppy :-) */ - return -ENXIO; + return -ENODEV; if (MACH_IS_HADES) /* Hades doesn't have Atari-compatible floppy */ - return -ENXIO; + return -ENODEV; if (register_blkdev(FLOPPY_MAJOR,"fd")) return -EBUSY; diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 197cd7a0c33..a22662b6a1a 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c @@ -444,7 +444,7 @@ nvram_init(void) /* First test whether the driver should init at all */ if (!CHECK_DRIVER_INIT()) - return -ENXIO; + return -ENODEV; ret = misc_register(&nvram_dev); if (ret) { diff --git a/drivers/input/keyboard/atakbd.c b/drivers/input/keyboard/atakbd.c index 4e92100c56a..1839194ea98 100644 --- a/drivers/input/keyboard/atakbd.c +++ b/drivers/input/keyboard/atakbd.c @@ -220,7 +220,7 @@ static int __init atakbd_init(void) int i, error; if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP)) - return -EIO; + return -ENODEV; // need to init core driver if not already done so if (atari_keyb_init()) diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c index dff35474b85..c8605730a1b 100644 --- a/drivers/video/atafb.c +++ b/drivers/video/atafb.c @@ -3110,7 +3110,7 @@ int __init atafb_init(void) printk("atafb_init: start\n"); if (!MACH_IS_ATARI) - return -ENXIO; + return -ENODEV; do { #ifdef ATAFB_EXT -- cgit v1.2.3-70-g09d2