diff options
Diffstat (limited to 'drivers/char/pcmcia/synclink_cs.c')
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 126 |
1 files changed, 46 insertions, 80 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 9ecd6bef5d3b..15781396af25 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -70,7 +70,6 @@ | |||
70 | #include <linux/workqueue.h> | 70 | #include <linux/workqueue.h> |
71 | #include <linux/hdlc.h> | 71 | #include <linux/hdlc.h> |
72 | 72 | ||
73 | #include <pcmcia/cs.h> | ||
74 | #include <pcmcia/cistpl.h> | 73 | #include <pcmcia/cistpl.h> |
75 | #include <pcmcia/cisreg.h> | 74 | #include <pcmcia/cisreg.h> |
76 | #include <pcmcia/ds.h> | 75 | #include <pcmcia/ds.h> |
@@ -419,9 +418,9 @@ static void bh_status(MGSLPC_INFO *info); | |||
419 | /* | 418 | /* |
420 | * ioctl handlers | 419 | * ioctl handlers |
421 | */ | 420 | */ |
422 | static int tiocmget(struct tty_struct *tty, struct file *file); | 421 | static int tiocmget(struct tty_struct *tty); |
423 | static int tiocmset(struct tty_struct *tty, struct file *file, | 422 | static int tiocmset(struct tty_struct *tty, |
424 | unsigned int set, unsigned int clear); | 423 | unsigned int set, unsigned int clear); |
425 | static int get_stats(MGSLPC_INFO *info, struct mgsl_icount __user *user_icount); | 424 | static int get_stats(MGSLPC_INFO *info, struct mgsl_icount __user *user_icount); |
426 | static int get_params(MGSLPC_INFO *info, MGSL_PARAMS __user *user_params); | 425 | static int get_params(MGSLPC_INFO *info, MGSL_PARAMS __user *user_params); |
427 | static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params, struct tty_struct *tty); | 426 | static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params, struct tty_struct *tty); |
@@ -550,9 +549,6 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
550 | 549 | ||
551 | /* Initialize the struct pcmcia_device structure */ | 550 | /* Initialize the struct pcmcia_device structure */ |
552 | 551 | ||
553 | link->conf.Attributes = 0; | ||
554 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
555 | |||
556 | ret = mgslpc_config(link); | 552 | ret = mgslpc_config(link); |
557 | if (ret) | 553 | if (ret) |
558 | return ret; | 554 | return ret; |
@@ -565,20 +561,8 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
565 | /* Card has been inserted. | 561 | /* Card has been inserted. |
566 | */ | 562 | */ |
567 | 563 | ||
568 | static int mgslpc_ioprobe(struct pcmcia_device *p_dev, | 564 | static int mgslpc_ioprobe(struct pcmcia_device *p_dev, void *priv_data) |
569 | cistpl_cftable_entry_t *cfg, | ||
570 | cistpl_cftable_entry_t *dflt, | ||
571 | unsigned int vcc, | ||
572 | void *priv_data) | ||
573 | { | 565 | { |
574 | if (!cfg->io.nwin) | ||
575 | return -ENODEV; | ||
576 | |||
577 | p_dev->resource[0]->start = cfg->io.win[0].base; | ||
578 | p_dev->resource[0]->end = cfg->io.win[0].len; | ||
579 | p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); | ||
580 | p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
581 | |||
582 | return pcmcia_request_io(p_dev); | 566 | return pcmcia_request_io(p_dev); |
583 | } | 567 | } |
584 | 568 | ||
@@ -590,32 +574,24 @@ static int mgslpc_config(struct pcmcia_device *link) | |||
590 | if (debug_level >= DEBUG_LEVEL_INFO) | 574 | if (debug_level >= DEBUG_LEVEL_INFO) |
591 | printk("mgslpc_config(0x%p)\n", link); | 575 | printk("mgslpc_config(0x%p)\n", link); |
592 | 576 | ||
577 | link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; | ||
578 | |||
593 | ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL); | 579 | ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL); |
594 | if (ret != 0) | 580 | if (ret != 0) |
595 | goto failed; | 581 | goto failed; |
596 | 582 | ||
597 | link->conf.Attributes = CONF_ENABLE_IRQ; | 583 | link->config_index = 8; |
598 | link->conf.IntType = INT_MEMORY_AND_IO; | 584 | link->config_regs = PRESENT_OPTION; |
599 | link->conf.ConfigIndex = 8; | ||
600 | link->conf.Present = PRESENT_OPTION; | ||
601 | 585 | ||
602 | ret = pcmcia_request_irq(link, mgslpc_isr); | 586 | ret = pcmcia_request_irq(link, mgslpc_isr); |
603 | if (ret) | 587 | if (ret) |
604 | goto failed; | 588 | goto failed; |
605 | ret = pcmcia_request_configuration(link, &link->conf); | 589 | ret = pcmcia_enable_device(link); |
606 | if (ret) | 590 | if (ret) |
607 | goto failed; | 591 | goto failed; |
608 | 592 | ||
609 | info->io_base = link->resource[0]->start; | 593 | info->io_base = link->resource[0]->start; |
610 | info->irq_level = link->irq; | 594 | info->irq_level = link->irq; |
611 | |||
612 | dev_info(&link->dev, "index 0x%02x:", | ||
613 | link->conf.ConfigIndex); | ||
614 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | ||
615 | printk(", irq %d", link->irq); | ||
616 | if (link->resource[0]) | ||
617 | printk(", io %pR", link->resource[0]); | ||
618 | printk("\n"); | ||
619 | return 0; | 595 | return 0; |
620 | 596 | ||
621 | failed: | 597 | failed: |
@@ -1314,7 +1290,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) | |||
1314 | /* Allocate and claim adapter resources */ | 1290 | /* Allocate and claim adapter resources */ |
1315 | retval = claim_resources(info); | 1291 | retval = claim_resources(info); |
1316 | 1292 | ||
1317 | /* perform existance check and diagnostics */ | 1293 | /* perform existence check and diagnostics */ |
1318 | if ( !retval ) | 1294 | if ( !retval ) |
1319 | retval = adapter_test(info); | 1295 | retval = adapter_test(info); |
1320 | 1296 | ||
@@ -2138,7 +2114,7 @@ static int modem_input_wait(MGSLPC_INFO *info,int arg) | |||
2138 | 2114 | ||
2139 | /* return the state of the serial control and status signals | 2115 | /* return the state of the serial control and status signals |
2140 | */ | 2116 | */ |
2141 | static int tiocmget(struct tty_struct *tty, struct file *file) | 2117 | static int tiocmget(struct tty_struct *tty) |
2142 | { | 2118 | { |
2143 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; | 2119 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; |
2144 | unsigned int result; | 2120 | unsigned int result; |
@@ -2163,7 +2139,7 @@ static int tiocmget(struct tty_struct *tty, struct file *file) | |||
2163 | 2139 | ||
2164 | /* set modem control signals (DTR/RTS) | 2140 | /* set modem control signals (DTR/RTS) |
2165 | */ | 2141 | */ |
2166 | static int tiocmset(struct tty_struct *tty, struct file *file, | 2142 | static int tiocmset(struct tty_struct *tty, |
2167 | unsigned int set, unsigned int clear) | 2143 | unsigned int set, unsigned int clear) |
2168 | { | 2144 | { |
2169 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; | 2145 | MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; |
@@ -2215,26 +2191,47 @@ static int mgslpc_break(struct tty_struct *tty, int break_state) | |||
2215 | return 0; | 2191 | return 0; |
2216 | } | 2192 | } |
2217 | 2193 | ||
2194 | static int mgslpc_get_icount(struct tty_struct *tty, | ||
2195 | struct serial_icounter_struct *icount) | ||
2196 | { | ||
2197 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; | ||
2198 | struct mgsl_icount cnow; /* kernel counter temps */ | ||
2199 | unsigned long flags; | ||
2200 | |||
2201 | spin_lock_irqsave(&info->lock,flags); | ||
2202 | cnow = info->icount; | ||
2203 | spin_unlock_irqrestore(&info->lock,flags); | ||
2204 | |||
2205 | icount->cts = cnow.cts; | ||
2206 | icount->dsr = cnow.dsr; | ||
2207 | icount->rng = cnow.rng; | ||
2208 | icount->dcd = cnow.dcd; | ||
2209 | icount->rx = cnow.rx; | ||
2210 | icount->tx = cnow.tx; | ||
2211 | icount->frame = cnow.frame; | ||
2212 | icount->overrun = cnow.overrun; | ||
2213 | icount->parity = cnow.parity; | ||
2214 | icount->brk = cnow.brk; | ||
2215 | icount->buf_overrun = cnow.buf_overrun; | ||
2216 | |||
2217 | return 0; | ||
2218 | } | ||
2219 | |||
2218 | /* Service an IOCTL request | 2220 | /* Service an IOCTL request |
2219 | * | 2221 | * |
2220 | * Arguments: | 2222 | * Arguments: |
2221 | * | 2223 | * |
2222 | * tty pointer to tty instance data | 2224 | * tty pointer to tty instance data |
2223 | * file pointer to associated file object for device | ||
2224 | * cmd IOCTL command code | 2225 | * cmd IOCTL command code |
2225 | * arg command argument/context | 2226 | * arg command argument/context |
2226 | * | 2227 | * |
2227 | * Return Value: 0 if success, otherwise error code | 2228 | * Return Value: 0 if success, otherwise error code |
2228 | */ | 2229 | */ |
2229 | static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | 2230 | static int mgslpc_ioctl(struct tty_struct *tty, |
2230 | unsigned int cmd, unsigned long arg) | 2231 | unsigned int cmd, unsigned long arg) |
2231 | { | 2232 | { |
2232 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; | 2233 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; |
2233 | int error; | ||
2234 | struct mgsl_icount cnow; /* kernel counter temps */ | ||
2235 | struct serial_icounter_struct __user *p_cuser; /* user space */ | ||
2236 | void __user *argp = (void __user *)arg; | 2234 | void __user *argp = (void __user *)arg; |
2237 | unsigned long flags; | ||
2238 | 2235 | ||
2239 | if (debug_level >= DEBUG_LEVEL_INFO) | 2236 | if (debug_level >= DEBUG_LEVEL_INFO) |
2240 | printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, | 2237 | printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, |
@@ -2244,7 +2241,7 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | |||
2244 | return -ENODEV; | 2241 | return -ENODEV; |
2245 | 2242 | ||
2246 | if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && | 2243 | if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && |
2247 | (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { | 2244 | (cmd != TIOCMIWAIT)) { |
2248 | if (tty->flags & (1 << TTY_IO_ERROR)) | 2245 | if (tty->flags & (1 << TTY_IO_ERROR)) |
2249 | return -EIO; | 2246 | return -EIO; |
2250 | } | 2247 | } |
@@ -2274,34 +2271,6 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | |||
2274 | return wait_events(info, argp); | 2271 | return wait_events(info, argp); |
2275 | case TIOCMIWAIT: | 2272 | case TIOCMIWAIT: |
2276 | return modem_input_wait(info,(int)arg); | 2273 | return modem_input_wait(info,(int)arg); |
2277 | case TIOCGICOUNT: | ||
2278 | spin_lock_irqsave(&info->lock,flags); | ||
2279 | cnow = info->icount; | ||
2280 | spin_unlock_irqrestore(&info->lock,flags); | ||
2281 | p_cuser = argp; | ||
2282 | PUT_USER(error,cnow.cts, &p_cuser->cts); | ||
2283 | if (error) return error; | ||
2284 | PUT_USER(error,cnow.dsr, &p_cuser->dsr); | ||
2285 | if (error) return error; | ||
2286 | PUT_USER(error,cnow.rng, &p_cuser->rng); | ||
2287 | if (error) return error; | ||
2288 | PUT_USER(error,cnow.dcd, &p_cuser->dcd); | ||
2289 | if (error) return error; | ||
2290 | PUT_USER(error,cnow.rx, &p_cuser->rx); | ||
2291 | if (error) return error; | ||
2292 | PUT_USER(error,cnow.tx, &p_cuser->tx); | ||
2293 | if (error) return error; | ||
2294 | PUT_USER(error,cnow.frame, &p_cuser->frame); | ||
2295 | if (error) return error; | ||
2296 | PUT_USER(error,cnow.overrun, &p_cuser->overrun); | ||
2297 | if (error) return error; | ||
2298 | PUT_USER(error,cnow.parity, &p_cuser->parity); | ||
2299 | if (error) return error; | ||
2300 | PUT_USER(error,cnow.brk, &p_cuser->brk); | ||
2301 | if (error) return error; | ||
2302 | PUT_USER(error,cnow.buf_overrun, &p_cuser->buf_overrun); | ||
2303 | if (error) return error; | ||
2304 | return 0; | ||
2305 | default: | 2274 | default: |
2306 | return -ENOIOCTLCMD; | 2275 | return -ENOIOCTLCMD; |
2307 | } | 2276 | } |
@@ -2711,7 +2680,7 @@ static void rx_free_buffers(MGSLPC_INFO *info) | |||
2711 | static int claim_resources(MGSLPC_INFO *info) | 2680 | static int claim_resources(MGSLPC_INFO *info) |
2712 | { | 2681 | { |
2713 | if (rx_alloc_buffers(info) < 0 ) { | 2682 | if (rx_alloc_buffers(info) < 0 ) { |
2714 | printk( "Cant allocate rx buffer %s\n", info->device_name); | 2683 | printk( "Can't allocate rx buffer %s\n", info->device_name); |
2715 | release_resources(info); | 2684 | release_resources(info); |
2716 | return -ENODEV; | 2685 | return -ENODEV; |
2717 | } | 2686 | } |
@@ -2789,7 +2758,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info) | |||
2789 | } | 2758 | } |
2790 | } | 2759 | } |
2791 | 2760 | ||
2792 | static struct pcmcia_device_id mgslpc_ids[] = { | 2761 | static const struct pcmcia_device_id mgslpc_ids[] = { |
2793 | PCMCIA_DEVICE_MANF_CARD(0x02c5, 0x0050), | 2762 | PCMCIA_DEVICE_MANF_CARD(0x02c5, 0x0050), |
2794 | PCMCIA_DEVICE_NULL | 2763 | PCMCIA_DEVICE_NULL |
2795 | }; | 2764 | }; |
@@ -2797,9 +2766,7 @@ MODULE_DEVICE_TABLE(pcmcia, mgslpc_ids); | |||
2797 | 2766 | ||
2798 | static struct pcmcia_driver mgslpc_driver = { | 2767 | static struct pcmcia_driver mgslpc_driver = { |
2799 | .owner = THIS_MODULE, | 2768 | .owner = THIS_MODULE, |
2800 | .drv = { | 2769 | .name = "synclink_cs", |
2801 | .name = "synclink_cs", | ||
2802 | }, | ||
2803 | .probe = mgslpc_probe, | 2770 | .probe = mgslpc_probe, |
2804 | .remove = mgslpc_detach, | 2771 | .remove = mgslpc_detach, |
2805 | .id_table = mgslpc_ids, | 2772 | .id_table = mgslpc_ids, |
@@ -2828,6 +2795,7 @@ static const struct tty_operations mgslpc_ops = { | |||
2828 | .hangup = mgslpc_hangup, | 2795 | .hangup = mgslpc_hangup, |
2829 | .tiocmget = tiocmget, | 2796 | .tiocmget = tiocmget, |
2830 | .tiocmset = tiocmset, | 2797 | .tiocmset = tiocmset, |
2798 | .get_icount = mgslpc_get_icount, | ||
2831 | .proc_fops = &mgslpc_proc_fops, | 2799 | .proc_fops = &mgslpc_proc_fops, |
2832 | }; | 2800 | }; |
2833 | 2801 | ||
@@ -2835,8 +2803,6 @@ static void synclink_cs_cleanup(void) | |||
2835 | { | 2803 | { |
2836 | int rc; | 2804 | int rc; |
2837 | 2805 | ||
2838 | printk("Unloading %s: version %s\n", driver_name, driver_version); | ||
2839 | |||
2840 | while(mgslpc_device_list) | 2806 | while(mgslpc_device_list) |
2841 | mgslpc_remove_device(mgslpc_device_list); | 2807 | mgslpc_remove_device(mgslpc_device_list); |
2842 | 2808 | ||
@@ -2859,8 +2825,6 @@ static int __init synclink_cs_init(void) | |||
2859 | BREAKPOINT(); | 2825 | BREAKPOINT(); |
2860 | } | 2826 | } |
2861 | 2827 | ||
2862 | printk("%s %s\n", driver_name, driver_version); | ||
2863 | |||
2864 | if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) | 2828 | if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) |
2865 | return rc; | 2829 | return rc; |
2866 | 2830 | ||
@@ -4127,6 +4091,8 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
4127 | if (cmd != SIOCWANDEV) | 4091 | if (cmd != SIOCWANDEV) |
4128 | return hdlc_ioctl(dev, ifr, cmd); | 4092 | return hdlc_ioctl(dev, ifr, cmd); |
4129 | 4093 | ||
4094 | memset(&new_line, 0, size); | ||
4095 | |||
4130 | switch(ifr->ifr_settings.type) { | 4096 | switch(ifr->ifr_settings.type) { |
4131 | case IF_GET_IFACE: /* return current sync_serial_settings */ | 4097 | case IF_GET_IFACE: /* return current sync_serial_settings */ |
4132 | 4098 | ||