drm/drm_crtc: return -EFAULT on copy_to_user errors
[safe/jmp/linux-2.6] / drivers / bluetooth / dtl1_cs.c
index 77b99ee..ef044d5 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/types.h>
-#include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/ptrace.h>
@@ -68,7 +67,6 @@ MODULE_LICENSE("GPL");
 
 typedef struct dtl1_info_t {
        struct pcmcia_device *p_dev;
-       dev_node_t node;
 
        struct hci_dev *hdev;
 
@@ -298,11 +296,11 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst)
        unsigned char msr;
        int boguscount = 0;
        int iir, lsr;
+       irqreturn_t r = IRQ_NONE;
 
-       if (!info || !info->hdev) {
-               BT_ERR("Call of irq %d for unknown device", irq);
+       if (!info || !info->hdev)
+               /* our irq handler is shared */
                return IRQ_NONE;
-       }
 
        iobase = info->p_dev->io.BasePort1;
 
@@ -311,6 +309,7 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst)
        iir = inb(iobase + UART_IIR) & UART_IIR_ID;
        while (iir) {
 
+               r = IRQ_HANDLED;
                /* Clear interrupt */
                lsr = inb(iobase + UART_LSR);
 
@@ -347,11 +346,12 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst)
                info->ri_latch = msr & UART_MSR_RI;
                clear_bit(XMIT_WAITING, &(info->tx_state));
                dtl1_write_wakeup(info);
+               r = IRQ_HANDLED;
        }
 
        spin_unlock(&(info->lock));
 
-       return IRQ_HANDLED;
+       return r;
 }
 
 
@@ -416,6 +416,8 @@ static int dtl1_hci_send_frame(struct sk_buff *skb)
                hdev->stat.sco_tx++;
                nsh.type = 0x83;
                break;
+       default:
+               return -EILSEQ;
        };
 
        nsh.zero = 0;
@@ -426,7 +428,7 @@ static int dtl1_hci_send_frame(struct sk_buff *skb)
                return -ENOMEM;
 
        skb_reserve(s, NSHL);
-       memcpy(skb_put(s, skb->len), skb->data, skb->len);
+       skb_copy_from_linear_data(skb, skb_put(s, skb->len), skb->len);
        if (skb->len & 0x0001)
                *skb_put(s, 1) = 0;     /* PAD */
 
@@ -482,7 +484,7 @@ static int dtl1_open(dtl1_info_t *info)
 
        info->hdev = hdev;
 
-       hdev->type = HCI_PCCARD;
+       hdev->bus = HCI_PCCARD;
        hdev->driver_data = info;
        SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
 
@@ -572,11 +574,6 @@ static int dtl1_probe(struct pcmcia_device *link)
 
        link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
        link->io.NumPorts1 = 8;
-       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
-       link->irq.IRQInfo1 = IRQ_LEVEL_ID;
-
-       link->irq.Handler = dtl1_interrupt;
-       link->irq.Instance = info;
 
        link->conf.Attributes = CONF_ENABLE_IRQ;
        link->conf.IntType = INT_MEMORY_AND_IO;
@@ -594,85 +591,43 @@ static void dtl1_detach(struct pcmcia_device *link)
        kfree(info);
 }
 
-static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
-{
-       int i;
-
-       i = pcmcia_get_tuple_data(handle, tuple);
-       if (i != CS_SUCCESS)
-               return i;
-
-       return pcmcia_parse_tuple(handle, tuple, parse);
-}
-
-static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
-{
-       if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
-               return CS_NO_MORE_ITEMS;
-       return get_tuple(handle, tuple, parse);
-}
-
-static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
+static int dtl1_confcheck(struct pcmcia_device *p_dev,
+                         cistpl_cftable_entry_t *cf,
+                         cistpl_cftable_entry_t *dflt,
+                         unsigned int vcc,
+                         void *priv_data)
 {
-       if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
-               return CS_NO_MORE_ITEMS;
-       return get_tuple(handle, tuple, parse);
+       if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
+               p_dev->io.BasePort1 = cf->io.win[0].base;
+               p_dev->io.NumPorts1 = cf->io.win[0].len;        /*yo */
+               p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
+               if (!pcmcia_request_io(p_dev, &p_dev->io))
+                       return 0;
+       }
+       return -ENODEV;
 }
 
 static int dtl1_config(struct pcmcia_device *link)
 {
        dtl1_info_t *info = link->priv;
-       tuple_t tuple;
-       u_short buf[256];
-       cisparse_t parse;
-       cistpl_cftable_entry_t *cf = &parse.cftable_entry;
        int i;
 
-       tuple.TupleData = (cisdata_t *)buf;
-       tuple.TupleOffset = 0;
-       tuple.TupleDataMax = 255;
-       tuple.Attributes = 0;
-       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-
        /* Look for a generic full-sized window */
        link->io.NumPorts1 = 8;
-       i = first_tuple(link, &tuple, &parse);
-       while (i != CS_NO_MORE_ITEMS) {
-               if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
-                       link->conf.ConfigIndex = cf->index;
-                       link->io.BasePort1 = cf->io.win[0].base;
-                       link->io.NumPorts1 = cf->io.win[0].len; /*yo */
-                       link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
-                       i = pcmcia_request_io(link, &link->io);
-                       if (i == CS_SUCCESS)
-                               break;
-               }
-               i = next_tuple(link, &tuple, &parse);
-       }
-
-       if (i != CS_SUCCESS) {
-               cs_error(link, RequestIO, i);
+       if (pcmcia_loop_config(link, dtl1_confcheck, NULL) < 0)
                goto failed;
-       }
 
-       i = pcmcia_request_irq(link, &link->irq);
-       if (i != CS_SUCCESS) {
-               cs_error(link, RequestIRQ, i);
-               link->irq.AssignedIRQ = 0;
-       }
+       i = pcmcia_request_irq(link, dtl1_interrupt);
+       if (i != 0)
+               goto failed;
 
        i = pcmcia_request_configuration(link, &link->conf);
-       if (i != CS_SUCCESS) {
-               cs_error(link, RequestConfiguration, i);
+       if (i != 0)
                goto failed;
-       }
 
        if (dtl1_open(info) != 0)
                goto failed;
 
-       strcpy(info->node.dev_name, info->hdev->name);
-       link->dev_node = &info->node;
-
        return 0;
 
 failed: