aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/defkeymap.c_shipped68
-rw-r--r--drivers/char/esp.c1
-rw-r--r--drivers/char/isicom.c2
-rw-r--r--drivers/char/nozomi.c61
-rw-r--r--drivers/char/pcmcia/ipwireless/network.c5
-rw-r--r--drivers/char/riscom8.c8
-rw-r--r--drivers/char/rtc.c4
-rw-r--r--drivers/char/specialix.c1
-rw-r--r--drivers/char/vt.c1
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.c80
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.c60
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c138
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.h24
13 files changed, 231 insertions, 222 deletions
diff --git a/drivers/char/defkeymap.c_shipped b/drivers/char/defkeymap.c_shipped
index 0aa419a61767..d2208dfe3f67 100644
--- a/drivers/char/defkeymap.c_shipped
+++ b/drivers/char/defkeymap.c_shipped
@@ -223,40 +223,40 @@ char *func_table[MAX_NR_FUNC] = {
223}; 223};
224 224
225struct kbdiacruc accent_table[MAX_DIACR] = { 225struct kbdiacruc accent_table[MAX_DIACR] = {
226 {'`', 'A', '\300'}, {'`', 'a', '\340'}, 226 {'`', 'A', 0300}, {'`', 'a', 0340},
227 {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, 227 {'\'', 'A', 0301}, {'\'', 'a', 0341},
228 {'^', 'A', '\302'}, {'^', 'a', '\342'}, 228 {'^', 'A', 0302}, {'^', 'a', 0342},
229 {'~', 'A', '\303'}, {'~', 'a', '\343'}, 229 {'~', 'A', 0303}, {'~', 'a', 0343},
230 {'"', 'A', '\304'}, {'"', 'a', '\344'}, 230 {'"', 'A', 0304}, {'"', 'a', 0344},
231 {'O', 'A', '\305'}, {'o', 'a', '\345'}, 231 {'O', 'A', 0305}, {'o', 'a', 0345},
232 {'0', 'A', '\305'}, {'0', 'a', '\345'}, 232 {'0', 'A', 0305}, {'0', 'a', 0345},
233 {'A', 'A', '\305'}, {'a', 'a', '\345'}, 233 {'A', 'A', 0305}, {'a', 'a', 0345},
234 {'A', 'E', '\306'}, {'a', 'e', '\346'}, 234 {'A', 'E', 0306}, {'a', 'e', 0346},
235 {',', 'C', '\307'}, {',', 'c', '\347'}, 235 {',', 'C', 0307}, {',', 'c', 0347},
236 {'`', 'E', '\310'}, {'`', 'e', '\350'}, 236 {'`', 'E', 0310}, {'`', 'e', 0350},
237 {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, 237 {'\'', 'E', 0311}, {'\'', 'e', 0351},
238 {'^', 'E', '\312'}, {'^', 'e', '\352'}, 238 {'^', 'E', 0312}, {'^', 'e', 0352},
239 {'"', 'E', '\313'}, {'"', 'e', '\353'}, 239 {'"', 'E', 0313}, {'"', 'e', 0353},
240 {'`', 'I', '\314'}, {'`', 'i', '\354'}, 240 {'`', 'I', 0314}, {'`', 'i', 0354},
241 {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, 241 {'\'', 'I', 0315}, {'\'', 'i', 0355},
242 {'^', 'I', '\316'}, {'^', 'i', '\356'}, 242 {'^', 'I', 0316}, {'^', 'i', 0356},
243 {'"', 'I', '\317'}, {'"', 'i', '\357'}, 243 {'"', 'I', 0317}, {'"', 'i', 0357},
244 {'-', 'D', '\320'}, {'-', 'd', '\360'}, 244 {'-', 'D', 0320}, {'-', 'd', 0360},
245 {'~', 'N', '\321'}, {'~', 'n', '\361'}, 245 {'~', 'N', 0321}, {'~', 'n', 0361},
246 {'`', 'O', '\322'}, {'`', 'o', '\362'}, 246 {'`', 'O', 0322}, {'`', 'o', 0362},
247 {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, 247 {'\'', 'O', 0323}, {'\'', 'o', 0363},
248 {'^', 'O', '\324'}, {'^', 'o', '\364'}, 248 {'^', 'O', 0324}, {'^', 'o', 0364},
249 {'~', 'O', '\325'}, {'~', 'o', '\365'}, 249 {'~', 'O', 0325}, {'~', 'o', 0365},
250 {'"', 'O', '\326'}, {'"', 'o', '\366'}, 250 {'"', 'O', 0326}, {'"', 'o', 0366},
251 {'/', 'O', '\330'}, {'/', 'o', '\370'}, 251 {'/', 'O', 0330}, {'/', 'o', 0370},
252 {'`', 'U', '\331'}, {'`', 'u', '\371'}, 252 {'`', 'U', 0331}, {'`', 'u', 0371},
253 {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, 253 {'\'', 'U', 0332}, {'\'', 'u', 0372},
254 {'^', 'U', '\333'}, {'^', 'u', '\373'}, 254 {'^', 'U', 0333}, {'^', 'u', 0373},
255 {'"', 'U', '\334'}, {'"', 'u', '\374'}, 255 {'"', 'U', 0334}, {'"', 'u', 0374},
256 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, 256 {'\'', 'Y', 0335}, {'\'', 'y', 0375},
257 {'T', 'H', '\336'}, {'t', 'h', '\376'}, 257 {'T', 'H', 0336}, {'t', 'h', 0376},
258 {'s', 's', '\337'}, {'"', 'y', '\377'}, 258 {'s', 's', 0337}, {'"', 'y', 0377},
259 {'s', 'z', '\337'}, {'i', 'j', '\377'}, 259 {'s', 'z', 0337}, {'i', 'j', 0377},
260}; 260};
261 261
262unsigned int accent_table_size = 68; 262unsigned int accent_table_size = 68;
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index c01e26d9ee5e..f3fe62067344 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -2484,6 +2484,7 @@ static int __init espserial_init(void)
2484 return 0; 2484 return 0;
2485 } 2485 }
2486 2486
2487 spin_lock_init(&info->lock);
2487 /* rx_trigger, tx_trigger are needed by autoconfig */ 2488 /* rx_trigger, tx_trigger are needed by autoconfig */
2488 info->config.rx_trigger = rx_trigger; 2489 info->config.rx_trigger = rx_trigger;
2489 info->config.tx_trigger = tx_trigger; 2490 info->config.tx_trigger = tx_trigger;
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 85d596a3c18c..eba2883b630e 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -1527,7 +1527,7 @@ static int __devinit reset_card(struct pci_dev *pdev,
1527 msleep(10); 1527 msleep(10);
1528 1528
1529 portcount = inw(base + 0x2); 1529 portcount = inw(base + 0x2);
1530 if (!inw(base + 0xe) & 0x1 || (portcount != 0 && portcount != 4 && 1530 if (!(inw(base + 0xe) & 0x1) || (portcount != 0 && portcount != 4 &&
1531 portcount != 8 && portcount != 16)) { 1531 portcount != 8 && portcount != 16)) {
1532 dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure.\n", 1532 dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure.\n",
1533 card + 1); 1533 card + 1);
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index dfaab2322de3..6d0dc5f9b6bb 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -190,6 +190,14 @@ enum card_type {
190 F32_8 = 8192, /* 3072 bytes downl. + 1024 bytes uplink * 2 -> 8192 */ 190 F32_8 = 8192, /* 3072 bytes downl. + 1024 bytes uplink * 2 -> 8192 */
191}; 191};
192 192
193/* Initialization states a card can be in */
194enum card_state {
195 NOZOMI_STATE_UKNOWN = 0,
196 NOZOMI_STATE_ENABLED = 1, /* pci device enabled */
197 NOZOMI_STATE_ALLOCATED = 2, /* config setup done */
198 NOZOMI_STATE_READY = 3, /* flowcontrols received */
199};
200
193/* Two different toggle channels exist */ 201/* Two different toggle channels exist */
194enum channel_type { 202enum channel_type {
195 CH_A = 0, 203 CH_A = 0,
@@ -385,6 +393,7 @@ struct nozomi {
385 spinlock_t spin_mutex; /* secures access to registers and tty */ 393 spinlock_t spin_mutex; /* secures access to registers and tty */
386 394
387 unsigned int index_start; 395 unsigned int index_start;
396 enum card_state state;
388 u32 open_ttys; 397 u32 open_ttys;
389}; 398};
390 399
@@ -686,6 +695,7 @@ static int nozomi_read_config_table(struct nozomi *dc)
686 dc->last_ier = dc->last_ier | CTRL_DL; 695 dc->last_ier = dc->last_ier | CTRL_DL;
687 writew(dc->last_ier, dc->reg_ier); 696 writew(dc->last_ier, dc->reg_ier);
688 697
698 dc->state = NOZOMI_STATE_ALLOCATED;
689 dev_info(&dc->pdev->dev, "Initialization OK!\n"); 699 dev_info(&dc->pdev->dev, "Initialization OK!\n");
690 return 1; 700 return 1;
691 } 701 }
@@ -944,6 +954,14 @@ static int receive_flow_control(struct nozomi *dc)
944 case CTRL_APP2: 954 case CTRL_APP2:
945 port = PORT_APP2; 955 port = PORT_APP2;
946 enable_ier = APP2_DL; 956 enable_ier = APP2_DL;
957 if (dc->state == NOZOMI_STATE_ALLOCATED) {
958 /*
959 * After card initialization the flow control
960 * received for APP2 is always the last
961 */
962 dc->state = NOZOMI_STATE_READY;
963 dev_info(&dc->pdev->dev, "Device READY!\n");
964 }
947 break; 965 break;
948 default: 966 default:
949 dev_err(&dc->pdev->dev, 967 dev_err(&dc->pdev->dev,
@@ -1366,22 +1384,12 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1366 1384
1367 dc->pdev = pdev; 1385 dc->pdev = pdev;
1368 1386
1369 /* Find out what card type it is */
1370 nozomi_get_card_type(dc);
1371
1372 ret = pci_enable_device(dc->pdev); 1387 ret = pci_enable_device(dc->pdev);
1373 if (ret) { 1388 if (ret) {
1374 dev_err(&pdev->dev, "Failed to enable PCI Device\n"); 1389 dev_err(&pdev->dev, "Failed to enable PCI Device\n");
1375 goto err_free; 1390 goto err_free;
1376 } 1391 }
1377 1392
1378 start = pci_resource_start(dc->pdev, 0);
1379 if (start == 0) {
1380 dev_err(&pdev->dev, "No I/O address for card detected\n");
1381 ret = -ENODEV;
1382 goto err_disable_device;
1383 }
1384
1385 ret = pci_request_regions(dc->pdev, NOZOMI_NAME); 1393 ret = pci_request_regions(dc->pdev, NOZOMI_NAME);
1386 if (ret) { 1394 if (ret) {
1387 dev_err(&pdev->dev, "I/O address 0x%04x already in use\n", 1395 dev_err(&pdev->dev, "I/O address 0x%04x already in use\n",
@@ -1389,6 +1397,16 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1389 goto err_disable_device; 1397 goto err_disable_device;
1390 } 1398 }
1391 1399
1400 start = pci_resource_start(dc->pdev, 0);
1401 if (start == 0) {
1402 dev_err(&pdev->dev, "No I/O address for card detected\n");
1403 ret = -ENODEV;
1404 goto err_rel_regs;
1405 }
1406
1407 /* Find out what card type it is */
1408 nozomi_get_card_type(dc);
1409
1392 dc->base_addr = ioremap(start, dc->card_type); 1410 dc->base_addr = ioremap(start, dc->card_type);
1393 if (!dc->base_addr) { 1411 if (!dc->base_addr) {
1394 dev_err(&pdev->dev, "Unable to map card MMIO\n"); 1412 dev_err(&pdev->dev, "Unable to map card MMIO\n");
@@ -1425,6 +1443,14 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1425 dc->index_start = ndev_idx * MAX_PORT; 1443 dc->index_start = ndev_idx * MAX_PORT;
1426 ndevs[ndev_idx] = dc; 1444 ndevs[ndev_idx] = dc;
1427 1445
1446 pci_set_drvdata(pdev, dc);
1447
1448 /* Enable RESET interrupt */
1449 dc->last_ier = RESET;
1450 iowrite16(dc->last_ier, dc->reg_ier);
1451
1452 dc->state = NOZOMI_STATE_ENABLED;
1453
1428 for (i = 0; i < MAX_PORT; i++) { 1454 for (i = 0; i < MAX_PORT; i++) {
1429 mutex_init(&dc->port[i].tty_sem); 1455 mutex_init(&dc->port[i].tty_sem);
1430 dc->port[i].tty_open_count = 0; 1456 dc->port[i].tty_open_count = 0;
@@ -1433,12 +1459,6 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1433 &pdev->dev); 1459 &pdev->dev);
1434 } 1460 }
1435 1461
1436 /* Enable RESET interrupt. */
1437 dc->last_ier = RESET;
1438 writew(dc->last_ier, dc->reg_ier);
1439
1440 pci_set_drvdata(pdev, dc);
1441
1442 return 0; 1462 return 0;
1443 1463
1444err_free_sbuf: 1464err_free_sbuf:
@@ -1553,7 +1573,7 @@ static int ntty_open(struct tty_struct *tty, struct file *file)
1553 struct nozomi *dc = get_dc_by_tty(tty); 1573 struct nozomi *dc = get_dc_by_tty(tty);
1554 unsigned long flags; 1574 unsigned long flags;
1555 1575
1556 if (!port || !dc) 1576 if (!port || !dc || dc->state != NOZOMI_STATE_READY)
1557 return -ENODEV; 1577 return -ENODEV;
1558 1578
1559 if (mutex_lock_interruptible(&port->tty_sem)) 1579 if (mutex_lock_interruptible(&port->tty_sem))
@@ -1716,6 +1736,10 @@ static int ntty_tiocmget(struct tty_struct *tty, struct file *file)
1716static int ntty_tiocmset(struct tty_struct *tty, struct file *file, 1736static int ntty_tiocmset(struct tty_struct *tty, struct file *file,
1717 unsigned int set, unsigned int clear) 1737 unsigned int set, unsigned int clear)
1718{ 1738{
1739 struct nozomi *dc = get_dc_by_tty(tty);
1740 unsigned long flags;
1741
1742 spin_lock_irqsave(&dc->spin_mutex, flags);
1719 if (set & TIOCM_RTS) 1743 if (set & TIOCM_RTS)
1720 set_rts(tty, 1); 1744 set_rts(tty, 1);
1721 else if (clear & TIOCM_RTS) 1745 else if (clear & TIOCM_RTS)
@@ -1725,6 +1749,7 @@ static int ntty_tiocmset(struct tty_struct *tty, struct file *file,
1725 set_dtr(tty, 1); 1749 set_dtr(tty, 1);
1726 else if (clear & TIOCM_DTR) 1750 else if (clear & TIOCM_DTR)
1727 set_dtr(tty, 0); 1751 set_dtr(tty, 0);
1752 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1728 1753
1729 return 0; 1754 return 0;
1730} 1755}
@@ -1762,7 +1787,7 @@ static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp)
1762 icount.brk = cnow.brk; 1787 icount.brk = cnow.brk;
1763 icount.buf_overrun = cnow.buf_overrun; 1788 icount.buf_overrun = cnow.buf_overrun;
1764 1789
1765 return copy_to_user(argp, &icount, sizeof(icount)); 1790 return copy_to_user(argp, &icount, sizeof(icount)) ? -EFAULT : 0;
1766} 1791}
1767 1792
1768static int ntty_ioctl(struct tty_struct *tty, struct file *file, 1793static int ntty_ioctl(struct tty_struct *tty, struct file *file,
diff --git a/drivers/char/pcmcia/ipwireless/network.c b/drivers/char/pcmcia/ipwireless/network.c
index ff35230058d3..d793e68b3e0d 100644
--- a/drivers/char/pcmcia/ipwireless/network.c
+++ b/drivers/char/pcmcia/ipwireless/network.c
@@ -377,13 +377,16 @@ void ipwireless_network_packet_received(struct ipw_network *network,
377 for (i = 0; i < MAX_ASSOCIATED_TTYS; i++) { 377 for (i = 0; i < MAX_ASSOCIATED_TTYS; i++) {
378 struct ipw_tty *tty = network->associated_ttys[channel_idx][i]; 378 struct ipw_tty *tty = network->associated_ttys[channel_idx][i];
379 379
380 if (!tty)
381 continue;
382
380 /* 383 /*
381 * If it's associated with a tty (other than the RAS channel 384 * If it's associated with a tty (other than the RAS channel
382 * when we're online), then send the data to that tty. The RAS 385 * when we're online), then send the data to that tty. The RAS
383 * channel's data is handled above - it always goes through 386 * channel's data is handled above - it always goes through
384 * ppp_generic. 387 * ppp_generic.
385 */ 388 */
386 if (tty && channel_idx == IPW_CHANNEL_RAS 389 if (channel_idx == IPW_CHANNEL_RAS
387 && (network->ras_control_lines & 390 && (network->ras_control_lines &
388 IPW_CONTROL_LINE_DCD) != 0 391 IPW_CONTROL_LINE_DCD) != 0
389 && ipwireless_tty_is_modem(tty)) { 392 && ipwireless_tty_is_modem(tty)) {
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 8fc4fe4e38f1..3f9d0a9ac36d 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1620,14 +1620,8 @@ static int __init rc_init_drivers(void)
1620 1620
1621static void rc_release_drivers(void) 1621static void rc_release_drivers(void)
1622{ 1622{
1623 unsigned long flags;
1624
1625 spin_lock_irqsave(&riscom_lock, flags);
1626
1627 tty_unregister_driver(riscom_driver); 1623 tty_unregister_driver(riscom_driver);
1628 put_tty_driver(riscom_driver); 1624 put_tty_driver(riscom_driver);
1629
1630 spin_unlock_irqrestore(&riscom_lock, flags);
1631} 1625}
1632 1626
1633#ifndef MODULE 1627#ifndef MODULE
@@ -1715,7 +1709,7 @@ static int __init riscom8_init_module (void)
1715 1709
1716 if (iobase || iobase1 || iobase2 || iobase3) { 1710 if (iobase || iobase1 || iobase2 || iobase3) {
1717 for(i = 0; i < RC_NBOARD; i++) 1711 for(i = 0; i < RC_NBOARD; i++)
1718 rc_board[0].base = 0; 1712 rc_board[i].base = 0;
1719 } 1713 }
1720 1714
1721 if (iobase) 1715 if (iobase)
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 78b151c4d20f..5c3142b6f1fc 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -110,8 +110,8 @@ static int rtc_has_irq = 1;
110#define hpet_set_rtc_irq_bit(arg) 0 110#define hpet_set_rtc_irq_bit(arg) 0
111#define hpet_rtc_timer_init() do { } while (0) 111#define hpet_rtc_timer_init() do { } while (0)
112#define hpet_rtc_dropped_irq() 0 112#define hpet_rtc_dropped_irq() 0
113#define hpet_register_irq_handler(h) 0 113#define hpet_register_irq_handler(h) ({ 0; })
114#define hpet_unregister_irq_handler(h) 0 114#define hpet_unregister_irq_handler(h) ({ 0; })
115#ifdef RTC_IRQ 115#ifdef RTC_IRQ
116static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) 116static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
117{ 117{
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index c0e08c7bca2f..5ff83df67b44 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2109,7 +2109,6 @@ static void sx_throttle(struct tty_struct * tty)
2109 sx_out(bp, CD186x_CAR, port_No(port)); 2109 sx_out(bp, CD186x_CAR, port_No(port));
2110 spin_unlock_irqrestore(&bp->lock, flags); 2110 spin_unlock_irqrestore(&bp->lock, flags);
2111 if (I_IXOFF(tty)) { 2111 if (I_IXOFF(tty)) {
2112 spin_unlock_irqrestore(&bp->lock, flags);
2113 sx_wait_CCR(bp); 2112 sx_wait_CCR(bp);
2114 spin_lock_irqsave(&bp->lock, flags); 2113 spin_lock_irqsave(&bp->lock, flags);
2115 sx_out(bp, CD186x_CCR, CCR_SSCH2); 2114 sx_out(bp, CD186x_CCR, CCR_SSCH2);
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 367be9175061..9b58b894f823 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -702,6 +702,7 @@ void redraw_screen(struct vc_data *vc, int is_switch)
702 if (is_switch) { 702 if (is_switch) {
703 set_leds(); 703 set_leds();
704 compute_shiftstate(); 704 compute_shiftstate();
705 notify_update(vc);
705 } 706 }
706} 707}
707 708
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.c b/drivers/char/xilinx_hwicap/buffer_icap.c
index dfea2bde162b..f577daedb630 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.c
+++ b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -73,8 +73,8 @@
73#define XHI_BUFFER_START 0 73#define XHI_BUFFER_START 0
74 74
75/** 75/**
76 * buffer_icap_get_status: Get the contents of the status register. 76 * buffer_icap_get_status - Get the contents of the status register.
77 * @parameter base_address: is the base address of the device 77 * @base_address: is the base address of the device
78 * 78 *
79 * The status register contains the ICAP status and the done bit. 79 * The status register contains the ICAP status and the done bit.
80 * 80 *
@@ -94,9 +94,9 @@ static inline u32 buffer_icap_get_status(void __iomem *base_address)
94} 94}
95 95
96/** 96/**
97 * buffer_icap_get_bram: Reads data from the storage buffer bram. 97 * buffer_icap_get_bram - Reads data from the storage buffer bram.
98 * @parameter base_address: contains the base address of the component. 98 * @base_address: contains the base address of the component.
99 * @parameter offset: The word offset from which the data should be read. 99 * @offset: The word offset from which the data should be read.
100 * 100 *
101 * A bram is used as a configuration memory cache. One frame of data can 101 * A bram is used as a configuration memory cache. One frame of data can
102 * be stored in this "storage buffer". 102 * be stored in this "storage buffer".
@@ -108,8 +108,8 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address,
108} 108}
109 109
110/** 110/**
111 * buffer_icap_busy: Return true if the icap device is busy 111 * buffer_icap_busy - Return true if the icap device is busy
112 * @parameter base_address: is the base address of the device 112 * @base_address: is the base address of the device
113 * 113 *
114 * The queries the low order bit of the status register, which 114 * The queries the low order bit of the status register, which
115 * indicates whether the current configuration or readback operation 115 * indicates whether the current configuration or readback operation
@@ -121,8 +121,8 @@ static inline bool buffer_icap_busy(void __iomem *base_address)
121} 121}
122 122
123/** 123/**
124 * buffer_icap_busy: Return true if the icap device is not busy 124 * buffer_icap_busy - Return true if the icap device is not busy
125 * @parameter base_address: is the base address of the device 125 * @base_address: is the base address of the device
126 * 126 *
127 * The queries the low order bit of the status register, which 127 * The queries the low order bit of the status register, which
128 * indicates whether the current configuration or readback operation 128 * indicates whether the current configuration or readback operation
@@ -134,9 +134,9 @@ static inline bool buffer_icap_done(void __iomem *base_address)
134} 134}
135 135
136/** 136/**
137 * buffer_icap_set_size: Set the size register. 137 * buffer_icap_set_size - Set the size register.
138 * @parameter base_address: is the base address of the device 138 * @base_address: is the base address of the device
139 * @parameter data: The size in bytes. 139 * @data: The size in bytes.
140 * 140 *
141 * The size register holds the number of 8 bit bytes to transfer between 141 * The size register holds the number of 8 bit bytes to transfer between
142 * bram and the icap (or icap to bram). 142 * bram and the icap (or icap to bram).
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void __iomem *base_address,
148} 148}
149 149
150/** 150/**
151 * buffer_icap_mSetoffsetReg: Set the bram offset register. 151 * buffer_icap_set_offset - Set the bram offset register.
152 * @parameter base_address: contains the base address of the device. 152 * @base_address: contains the base address of the device.
153 * @parameter data: is the value to be written to the data register. 153 * @data: is the value to be written to the data register.
154 * 154 *
155 * The bram offset register holds the starting bram address to transfer 155 * The bram offset register holds the starting bram address to transfer
156 * data from during configuration or write data to during readback. 156 * data from during configuration or write data to during readback.
@@ -162,9 +162,9 @@ static inline void buffer_icap_set_offset(void __iomem *base_address,
162} 162}
163 163
164/** 164/**
165 * buffer_icap_set_rnc: Set the RNC (Readback not Configure) register. 165 * buffer_icap_set_rnc - Set the RNC (Readback not Configure) register.
166 * @parameter base_address: contains the base address of the device. 166 * @base_address: contains the base address of the device.
167 * @parameter data: is the value to be written to the data register. 167 * @data: is the value to be written to the data register.
168 * 168 *
169 * The RNC register determines the direction of the data transfer. It 169 * The RNC register determines the direction of the data transfer. It
170 * controls whether a configuration or readback take place. Writing to 170 * controls whether a configuration or readback take place. Writing to
@@ -178,10 +178,10 @@ static inline void buffer_icap_set_rnc(void __iomem *base_address,
178} 178}
179 179
180/** 180/**
181 * buffer_icap_set_bram: Write data to the storage buffer bram. 181 * buffer_icap_set_bram - Write data to the storage buffer bram.
182 * @parameter base_address: contains the base address of the component. 182 * @base_address: contains the base address of the component.
183 * @parameter offset: The word offset at which the data should be written. 183 * @offset: The word offset at which the data should be written.
184 * @parameter data: The value to be written to the bram offset. 184 * @data: The value to be written to the bram offset.
185 * 185 *
186 * A bram is used as a configuration memory cache. One frame of data can 186 * A bram is used as a configuration memory cache. One frame of data can
187 * be stored in this "storage buffer". 187 * be stored in this "storage buffer".
@@ -193,10 +193,10 @@ static inline void buffer_icap_set_bram(void __iomem *base_address,
193} 193}
194 194
195/** 195/**
196 * buffer_icap_device_read: Transfer bytes from ICAP to the storage buffer. 196 * buffer_icap_device_read - Transfer bytes from ICAP to the storage buffer.
197 * @parameter drvdata: a pointer to the drvdata. 197 * @drvdata: a pointer to the drvdata.
198 * @parameter offset: The storage buffer start address. 198 * @offset: The storage buffer start address.
199 * @parameter count: The number of words (32 bit) to read from the 199 * @count: The number of words (32 bit) to read from the
200 * device (ICAP). 200 * device (ICAP).
201 **/ 201 **/
202static int buffer_icap_device_read(struct hwicap_drvdata *drvdata, 202static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
@@ -227,10 +227,10 @@ static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
227}; 227};
228 228
229/** 229/**
230 * buffer_icap_device_write: Transfer bytes from ICAP to the storage buffer. 230 * buffer_icap_device_write - Transfer bytes from ICAP to the storage buffer.
231 * @parameter drvdata: a pointer to the drvdata. 231 * @drvdata: a pointer to the drvdata.
232 * @parameter offset: The storage buffer start address. 232 * @offset: The storage buffer start address.
233 * @parameter count: The number of words (32 bit) to read from the 233 * @count: The number of words (32 bit) to read from the
234 * device (ICAP). 234 * device (ICAP).
235 **/ 235 **/
236static int buffer_icap_device_write(struct hwicap_drvdata *drvdata, 236static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
@@ -261,8 +261,8 @@ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
261}; 261};
262 262
263/** 263/**
264 * buffer_icap_reset: Reset the logic of the icap device. 264 * buffer_icap_reset - Reset the logic of the icap device.
265 * @parameter drvdata: a pointer to the drvdata. 265 * @drvdata: a pointer to the drvdata.
266 * 266 *
267 * Writing to the status register resets the ICAP logic in an internal 267 * Writing to the status register resets the ICAP logic in an internal
268 * version of the core. For the version of the core published in EDK, 268 * version of the core. For the version of the core published in EDK,
@@ -274,10 +274,10 @@ void buffer_icap_reset(struct hwicap_drvdata *drvdata)
274} 274}
275 275
276/** 276/**
277 * buffer_icap_set_configuration: Load a partial bitstream from system memory. 277 * buffer_icap_set_configuration - Load a partial bitstream from system memory.
278 * @parameter drvdata: a pointer to the drvdata. 278 * @drvdata: a pointer to the drvdata.
279 * @parameter data: Kernel address of the partial bitstream. 279 * @data: Kernel address of the partial bitstream.
280 * @parameter size: the size of the partial bitstream in 32 bit words. 280 * @size: the size of the partial bitstream in 32 bit words.
281 **/ 281 **/
282int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data, 282int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
283 u32 size) 283 u32 size)
@@ -333,10 +333,10 @@ int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
333}; 333};
334 334
335/** 335/**
336 * buffer_icap_get_configuration: Read configuration data from the device. 336 * buffer_icap_get_configuration - Read configuration data from the device.
337 * @parameter drvdata: a pointer to the drvdata. 337 * @drvdata: a pointer to the drvdata.
338 * @parameter data: Address of the data representing the partial bitstream 338 * @data: Address of the data representing the partial bitstream
339 * @parameter size: the size of the partial bitstream in 32 bit words. 339 * @size: the size of the partial bitstream in 32 bit words.
340 **/ 340 **/
341int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data, 341int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data,
342 u32 size) 342 u32 size)
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.c b/drivers/char/xilinx_hwicap/fifo_icap.c
index 0988314694a6..6f45dbd47125 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.c
+++ b/drivers/char/xilinx_hwicap/fifo_icap.c
@@ -94,9 +94,9 @@
94 94
95 95
96/** 96/**
97 * fifo_icap_fifo_write: Write data to the write FIFO. 97 * fifo_icap_fifo_write - Write data to the write FIFO.
98 * @parameter drvdata: a pointer to the drvdata. 98 * @drvdata: a pointer to the drvdata.
99 * @parameter data: the 32-bit value to be written to the FIFO. 99 * @data: the 32-bit value to be written to the FIFO.
100 * 100 *
101 * This function will silently fail if the fifo is full. 101 * This function will silently fail if the fifo is full.
102 **/ 102 **/
@@ -108,8 +108,8 @@ static inline void fifo_icap_fifo_write(struct hwicap_drvdata *drvdata,
108} 108}
109 109
110/** 110/**
111 * fifo_icap_fifo_read: Read data from the Read FIFO. 111 * fifo_icap_fifo_read - Read data from the Read FIFO.
112 * @parameter drvdata: a pointer to the drvdata. 112 * @drvdata: a pointer to the drvdata.
113 * 113 *
114 * This function will silently fail if the fifo is empty. 114 * This function will silently fail if the fifo is empty.
115 **/ 115 **/
@@ -121,9 +121,9 @@ static inline u32 fifo_icap_fifo_read(struct hwicap_drvdata *drvdata)
121} 121}
122 122
123/** 123/**
124 * fifo_icap_set_read_size: Set the the size register. 124 * fifo_icap_set_read_size - Set the the size register.
125 * @parameter drvdata: a pointer to the drvdata. 125 * @drvdata: a pointer to the drvdata.
126 * @parameter data: the size of the following read transaction, in words. 126 * @data: the size of the following read transaction, in words.
127 **/ 127 **/
128static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata, 128static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
129 u32 data) 129 u32 data)
@@ -132,8 +132,8 @@ static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
132} 132}
133 133
134/** 134/**
135 * fifo_icap_start_config: Initiate a configuration (write) to the device. 135 * fifo_icap_start_config - Initiate a configuration (write) to the device.
136 * @parameter drvdata: a pointer to the drvdata. 136 * @drvdata: a pointer to the drvdata.
137 **/ 137 **/
138static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata) 138static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
139{ 139{
@@ -142,8 +142,8 @@ static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
142} 142}
143 143
144/** 144/**
145 * fifo_icap_start_readback: Initiate a readback from the device. 145 * fifo_icap_start_readback - Initiate a readback from the device.
146 * @parameter drvdata: a pointer to the drvdata. 146 * @drvdata: a pointer to the drvdata.
147 **/ 147 **/
148static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata) 148static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
149{ 149{
@@ -152,8 +152,8 @@ static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
152} 152}
153 153
154/** 154/**
155 * fifo_icap_busy: Return true if the ICAP is still processing a transaction. 155 * fifo_icap_busy - Return true if the ICAP is still processing a transaction.
156 * @parameter drvdata: a pointer to the drvdata. 156 * @drvdata: a pointer to the drvdata.
157 **/ 157 **/
158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata) 158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
159{ 159{
@@ -163,8 +163,8 @@ static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
163} 163}
164 164
165/** 165/**
166 * fifo_icap_write_fifo_vacancy: Query the write fifo available space. 166 * fifo_icap_write_fifo_vacancy - Query the write fifo available space.
167 * @parameter drvdata: a pointer to the drvdata. 167 * @drvdata: a pointer to the drvdata.
168 * 168 *
169 * Return the number of words that can be safely pushed into the write fifo. 169 * Return the number of words that can be safely pushed into the write fifo.
170 **/ 170 **/
@@ -175,8 +175,8 @@ static inline u32 fifo_icap_write_fifo_vacancy(
175} 175}
176 176
177/** 177/**
178 * fifo_icap_read_fifo_occupancy: Query the read fifo available data. 178 * fifo_icap_read_fifo_occupancy - Query the read fifo available data.
179 * @parameter drvdata: a pointer to the drvdata. 179 * @drvdata: a pointer to the drvdata.
180 * 180 *
181 * Return the number of words that can be safely read from the read fifo. 181 * Return the number of words that can be safely read from the read fifo.
182 **/ 182 **/
@@ -187,11 +187,11 @@ static inline u32 fifo_icap_read_fifo_occupancy(
187} 187}
188 188
189/** 189/**
190 * fifo_icap_set_configuration: Send configuration data to the ICAP. 190 * fifo_icap_set_configuration - Send configuration data to the ICAP.
191 * @parameter drvdata: a pointer to the drvdata. 191 * @drvdata: a pointer to the drvdata.
192 * @parameter frame_buffer: a pointer to the data to be written to the 192 * @frame_buffer: a pointer to the data to be written to the
193 * ICAP device. 193 * ICAP device.
194 * @parameter num_words: the number of words (32 bit) to write to the ICAP 194 * @num_words: the number of words (32 bit) to write to the ICAP
195 * device. 195 * device.
196 196
197 * This function writes the given user data to the Write FIFO in 197 * This function writes the given user data to the Write FIFO in
@@ -266,10 +266,10 @@ int fifo_icap_set_configuration(struct hwicap_drvdata *drvdata,
266} 266}
267 267
268/** 268/**
269 * fifo_icap_get_configuration: Read configuration data from the device. 269 * fifo_icap_get_configuration - Read configuration data from the device.
270 * @parameter drvdata: a pointer to the drvdata. 270 * @drvdata: a pointer to the drvdata.
271 * @parameter data: Address of the data representing the partial bitstream 271 * @data: Address of the data representing the partial bitstream
272 * @parameter size: the size of the partial bitstream in 32 bit words. 272 * @size: the size of the partial bitstream in 32 bit words.
273 * 273 *
274 * This function reads the specified number of words from the ICAP device in 274 * This function reads the specified number of words from the ICAP device in
275 * the polled mode. 275 * the polled mode.
@@ -335,8 +335,8 @@ int fifo_icap_get_configuration(struct hwicap_drvdata *drvdata,
335} 335}
336 336
337/** 337/**
338 * buffer_icap_reset: Reset the logic of the icap device. 338 * buffer_icap_reset - Reset the logic of the icap device.
339 * @parameter drvdata: a pointer to the drvdata. 339 * @drvdata: a pointer to the drvdata.
340 * 340 *
341 * This function forces the software reset of the complete HWICAP device. 341 * This function forces the software reset of the complete HWICAP device.
342 * All the registers will return to the default value and the FIFO is also 342 * All the registers will return to the default value and the FIFO is also
@@ -360,8 +360,8 @@ void fifo_icap_reset(struct hwicap_drvdata *drvdata)
360} 360}
361 361
362/** 362/**
363 * fifo_icap_flush_fifo: This function flushes the FIFOs in the device. 363 * fifo_icap_flush_fifo - This function flushes the FIFOs in the device.
364 * @parameter drvdata: a pointer to the drvdata. 364 * @drvdata: a pointer to the drvdata.
365 */ 365 */
366void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata) 366void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata)
367{ 367{
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 24f6aef0fd3c..2284fa2a5a57 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -84,7 +84,7 @@
84#include <linux/init.h> 84#include <linux/init.h>
85#include <linux/poll.h> 85#include <linux/poll.h>
86#include <linux/proc_fs.h> 86#include <linux/proc_fs.h>
87#include <asm/semaphore.h> 87#include <linux/mutex.h>
88#include <linux/sysctl.h> 88#include <linux/sysctl.h>
89#include <linux/version.h> 89#include <linux/version.h>
90#include <linux/fs.h> 90#include <linux/fs.h>
@@ -119,6 +119,7 @@ module_param(xhwicap_minor, int, S_IRUGO);
119 119
120/* An array, which is set to true when the device is registered. */ 120/* An array, which is set to true when the device is registered. */
121static bool probed_devices[HWICAP_DEVICES]; 121static bool probed_devices[HWICAP_DEVICES];
122static struct mutex icap_sem;
122 123
123static struct class *icap_class; 124static struct class *icap_class;
124 125
@@ -199,14 +200,14 @@ static const struct config_registers v5_config_registers = {
199}; 200};
200 201
201/** 202/**
202 * hwicap_command_desync: Send a DESYNC command to the ICAP port. 203 * hwicap_command_desync - Send a DESYNC command to the ICAP port.
203 * @parameter drvdata: a pointer to the drvdata. 204 * @drvdata: a pointer to the drvdata.
204 * 205 *
205 * This command desynchronizes the ICAP After this command, a 206 * This command desynchronizes the ICAP After this command, a
206 * bitstream containing a NULL packet, followed by a SYNCH packet is 207 * bitstream containing a NULL packet, followed by a SYNCH packet is
207 * required before the ICAP will recognize commands. 208 * required before the ICAP will recognize commands.
208 */ 209 */
209int hwicap_command_desync(struct hwicap_drvdata *drvdata) 210static int hwicap_command_desync(struct hwicap_drvdata *drvdata)
210{ 211{
211 u32 buffer[4]; 212 u32 buffer[4];
212 u32 index = 0; 213 u32 index = 0;
@@ -228,51 +229,18 @@ int hwicap_command_desync(struct hwicap_drvdata *drvdata)
228} 229}
229 230
230/** 231/**
231 * hwicap_command_capture: Send a CAPTURE command to the ICAP port. 232 * hwicap_get_configuration_register - Query a configuration register.
232 * @parameter drvdata: a pointer to the drvdata. 233 * @drvdata: a pointer to the drvdata.
233 * 234 * @reg: a constant which represents the configuration
234 * This command captures all of the flip flop states so they will be
235 * available during readback. One can use this command instead of
236 * enabling the CAPTURE block in the design.
237 */
238int hwicap_command_capture(struct hwicap_drvdata *drvdata)
239{
240 u32 buffer[7];
241 u32 index = 0;
242
243 /*
244 * Create the data to be written to the ICAP.
245 */
246 buffer[index++] = XHI_DUMMY_PACKET;
247 buffer[index++] = XHI_SYNC_PACKET;
248 buffer[index++] = XHI_NOOP_PACKET;
249 buffer[index++] = hwicap_type_1_write(drvdata->config_regs->CMD) | 1;
250 buffer[index++] = XHI_CMD_GCAPTURE;
251 buffer[index++] = XHI_DUMMY_PACKET;
252 buffer[index++] = XHI_DUMMY_PACKET;
253
254 /*
255 * Write the data to the FIFO and intiate the transfer of data
256 * present in the FIFO to the ICAP device.
257 */
258 return drvdata->config->set_configuration(drvdata,
259 &buffer[0], index);
260
261}
262
263/**
264 * hwicap_get_configuration_register: Query a configuration register.
265 * @parameter drvdata: a pointer to the drvdata.
266 * @parameter reg: a constant which represents the configuration
267 * register value to be returned. 235 * register value to be returned.
268 * Examples: XHI_IDCODE, XHI_FLR. 236 * Examples: XHI_IDCODE, XHI_FLR.
269 * @parameter RegData: returns the value of the register. 237 * @reg_data: returns the value of the register.
270 * 238 *
271 * Sends a query packet to the ICAP and then receives the response. 239 * Sends a query packet to the ICAP and then receives the response.
272 * The icap is left in Synched state. 240 * The icap is left in Synched state.
273 */ 241 */
274int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata, 242static int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
275 u32 reg, u32 *RegData) 243 u32 reg, u32 *reg_data)
276{ 244{
277 int status; 245 int status;
278 u32 buffer[6]; 246 u32 buffer[6];
@@ -300,14 +268,14 @@ int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
300 /* 268 /*
301 * Read the configuration register 269 * Read the configuration register
302 */ 270 */
303 status = drvdata->config->get_configuration(drvdata, RegData, 1); 271 status = drvdata->config->get_configuration(drvdata, reg_data, 1);
304 if (status) 272 if (status)
305 return status; 273 return status;
306 274
307 return 0; 275 return 0;
308} 276}
309 277
310int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata) 278static int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
311{ 279{
312 int status; 280 int status;
313 u32 idcode; 281 u32 idcode;
@@ -344,7 +312,7 @@ int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
344} 312}
345 313
346static ssize_t 314static ssize_t
347hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos) 315hwicap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
348{ 316{
349 struct hwicap_drvdata *drvdata = file->private_data; 317 struct hwicap_drvdata *drvdata = file->private_data;
350 ssize_t bytes_to_read = 0; 318 ssize_t bytes_to_read = 0;
@@ -353,8 +321,9 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
353 u32 bytes_remaining; 321 u32 bytes_remaining;
354 int status; 322 int status;
355 323
356 if (down_interruptible(&drvdata->sem)) 324 status = mutex_lock_interruptible(&drvdata->sem);
357 return -ERESTARTSYS; 325 if (status)
326 return status;
358 327
359 if (drvdata->read_buffer_in_use) { 328 if (drvdata->read_buffer_in_use) {
360 /* If there are leftover bytes in the buffer, just */ 329 /* If there are leftover bytes in the buffer, just */
@@ -370,8 +339,9 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
370 goto error; 339 goto error;
371 } 340 }
372 drvdata->read_buffer_in_use -= bytes_to_read; 341 drvdata->read_buffer_in_use -= bytes_to_read;
373 memcpy(drvdata->read_buffer + bytes_to_read, 342 memmove(drvdata->read_buffer,
374 drvdata->read_buffer, 4 - bytes_to_read); 343 drvdata->read_buffer + bytes_to_read,
344 4 - bytes_to_read);
375 } else { 345 } else {
376 /* Get new data from the ICAP, and return was was requested. */ 346 /* Get new data from the ICAP, and return was was requested. */
377 kbuf = (u32 *) get_zeroed_page(GFP_KERNEL); 347 kbuf = (u32 *) get_zeroed_page(GFP_KERNEL);
@@ -414,18 +384,20 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
414 status = -EFAULT; 384 status = -EFAULT;
415 goto error; 385 goto error;
416 } 386 }
417 memcpy(kbuf, drvdata->read_buffer, bytes_remaining); 387 memcpy(drvdata->read_buffer,
388 kbuf,
389 bytes_remaining);
418 drvdata->read_buffer_in_use = bytes_remaining; 390 drvdata->read_buffer_in_use = bytes_remaining;
419 free_page((unsigned long)kbuf); 391 free_page((unsigned long)kbuf);
420 } 392 }
421 status = bytes_to_read; 393 status = bytes_to_read;
422 error: 394 error:
423 up(&drvdata->sem); 395 mutex_unlock(&drvdata->sem);
424 return status; 396 return status;
425} 397}
426 398
427static ssize_t 399static ssize_t
428hwicap_write(struct file *file, const char *buf, 400hwicap_write(struct file *file, const char __user *buf,
429 size_t count, loff_t *ppos) 401 size_t count, loff_t *ppos)
430{ 402{
431 struct hwicap_drvdata *drvdata = file->private_data; 403 struct hwicap_drvdata *drvdata = file->private_data;
@@ -435,8 +407,9 @@ hwicap_write(struct file *file, const char *buf,
435 ssize_t len; 407 ssize_t len;
436 ssize_t status; 408 ssize_t status;
437 409
438 if (down_interruptible(&drvdata->sem)) 410 status = mutex_lock_interruptible(&drvdata->sem);
439 return -ERESTARTSYS; 411 if (status)
412 return status;
440 413
441 left += drvdata->write_buffer_in_use; 414 left += drvdata->write_buffer_in_use;
442 415
@@ -465,7 +438,7 @@ hwicap_write(struct file *file, const char *buf,
465 memcpy(kbuf, drvdata->write_buffer, 438 memcpy(kbuf, drvdata->write_buffer,
466 drvdata->write_buffer_in_use); 439 drvdata->write_buffer_in_use);
467 if (copy_from_user( 440 if (copy_from_user(
468 (((char *)kbuf) + (drvdata->write_buffer_in_use)), 441 (((char *)kbuf) + drvdata->write_buffer_in_use),
469 buf + written, 442 buf + written,
470 len - (drvdata->write_buffer_in_use))) { 443 len - (drvdata->write_buffer_in_use))) {
471 free_page((unsigned long)kbuf); 444 free_page((unsigned long)kbuf);
@@ -508,7 +481,7 @@ hwicap_write(struct file *file, const char *buf,
508 free_page((unsigned long)kbuf); 481 free_page((unsigned long)kbuf);
509 status = written; 482 status = written;
510 error: 483 error:
511 up(&drvdata->sem); 484 mutex_unlock(&drvdata->sem);
512 return status; 485 return status;
513} 486}
514 487
@@ -519,8 +492,9 @@ static int hwicap_open(struct inode *inode, struct file *file)
519 492
520 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 493 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
521 494
522 if (down_interruptible(&drvdata->sem)) 495 status = mutex_lock_interruptible(&drvdata->sem);
523 return -ERESTARTSYS; 496 if (status)
497 return status;
524 498
525 if (drvdata->is_open) { 499 if (drvdata->is_open) {
526 status = -EBUSY; 500 status = -EBUSY;
@@ -539,7 +513,7 @@ static int hwicap_open(struct inode *inode, struct file *file)
539 drvdata->is_open = 1; 513 drvdata->is_open = 1;
540 514
541 error: 515 error:
542 up(&drvdata->sem); 516 mutex_unlock(&drvdata->sem);
543 return status; 517 return status;
544} 518}
545 519
@@ -549,8 +523,7 @@ static int hwicap_release(struct inode *inode, struct file *file)
549 int i; 523 int i;
550 int status = 0; 524 int status = 0;
551 525
552 if (down_interruptible(&drvdata->sem)) 526 mutex_lock(&drvdata->sem);
553 return -ERESTARTSYS;
554 527
555 if (drvdata->write_buffer_in_use) { 528 if (drvdata->write_buffer_in_use) {
556 /* Flush write buffer. */ 529 /* Flush write buffer. */
@@ -569,7 +542,7 @@ static int hwicap_release(struct inode *inode, struct file *file)
569 542
570 error: 543 error:
571 drvdata->is_open = 0; 544 drvdata->is_open = 0;
572 up(&drvdata->sem); 545 mutex_unlock(&drvdata->sem);
573 return status; 546 return status;
574} 547}
575 548
@@ -592,31 +565,36 @@ static int __devinit hwicap_setup(struct device *dev, int id,
592 565
593 dev_info(dev, "Xilinx icap port driver\n"); 566 dev_info(dev, "Xilinx icap port driver\n");
594 567
568 mutex_lock(&icap_sem);
569
595 if (id < 0) { 570 if (id < 0) {
596 for (id = 0; id < HWICAP_DEVICES; id++) 571 for (id = 0; id < HWICAP_DEVICES; id++)
597 if (!probed_devices[id]) 572 if (!probed_devices[id])
598 break; 573 break;
599 } 574 }
600 if (id < 0 || id >= HWICAP_DEVICES) { 575 if (id < 0 || id >= HWICAP_DEVICES) {
576 mutex_unlock(&icap_sem);
601 dev_err(dev, "%s%i too large\n", DRIVER_NAME, id); 577 dev_err(dev, "%s%i too large\n", DRIVER_NAME, id);
602 return -EINVAL; 578 return -EINVAL;
603 } 579 }
604 if (probed_devices[id]) { 580 if (probed_devices[id]) {
581 mutex_unlock(&icap_sem);
605 dev_err(dev, "cannot assign to %s%i; it is already in use\n", 582 dev_err(dev, "cannot assign to %s%i; it is already in use\n",
606 DRIVER_NAME, id); 583 DRIVER_NAME, id);
607 return -EBUSY; 584 return -EBUSY;
608 } 585 }
609 586
610 probed_devices[id] = 1; 587 probed_devices[id] = 1;
588 mutex_unlock(&icap_sem);
611 589
612 devt = MKDEV(xhwicap_major, xhwicap_minor + id); 590 devt = MKDEV(xhwicap_major, xhwicap_minor + id);
613 591
614 drvdata = kmalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); 592 drvdata = kzalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL);
615 if (!drvdata) { 593 if (!drvdata) {
616 dev_err(dev, "Couldn't allocate device private record\n"); 594 dev_err(dev, "Couldn't allocate device private record\n");
617 return -ENOMEM; 595 retval = -ENOMEM;
596 goto failed0;
618 } 597 }
619 memset((void *)drvdata, 0, sizeof(struct hwicap_drvdata));
620 dev_set_drvdata(dev, (void *)drvdata); 598 dev_set_drvdata(dev, (void *)drvdata);
621 599
622 if (!regs_res) { 600 if (!regs_res) {
@@ -648,7 +626,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
648 drvdata->config = config; 626 drvdata->config = config;
649 drvdata->config_regs = config_regs; 627 drvdata->config_regs = config_regs;
650 628
651 init_MUTEX(&drvdata->sem); 629 mutex_init(&drvdata->sem);
652 drvdata->is_open = 0; 630 drvdata->is_open = 0;
653 631
654 dev_info(dev, "ioremap %lx to %p with size %x\n", 632 dev_info(dev, "ioremap %lx to %p with size %x\n",
@@ -663,7 +641,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
663 goto failed3; 641 goto failed3;
664 } 642 }
665 /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */ 643 /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */
666 class_device_create(icap_class, NULL, devt, NULL, DRIVER_NAME); 644 device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id);
667 return 0; /* success */ 645 return 0; /* success */
668 646
669 failed3: 647 failed3:
@@ -675,6 +653,11 @@ static int __devinit hwicap_setup(struct device *dev, int id,
675 failed1: 653 failed1:
676 kfree(drvdata); 654 kfree(drvdata);
677 655
656 failed0:
657 mutex_lock(&icap_sem);
658 probed_devices[id] = 0;
659 mutex_unlock(&icap_sem);
660
678 return retval; 661 return retval;
679} 662}
680 663
@@ -699,14 +682,16 @@ static int __devexit hwicap_remove(struct device *dev)
699 if (!drvdata) 682 if (!drvdata)
700 return 0; 683 return 0;
701 684
702 class_device_destroy(icap_class, drvdata->devt); 685 device_destroy(icap_class, drvdata->devt);
703 cdev_del(&drvdata->cdev); 686 cdev_del(&drvdata->cdev);
704 iounmap(drvdata->base_address); 687 iounmap(drvdata->base_address);
705 release_mem_region(drvdata->mem_start, drvdata->mem_size); 688 release_mem_region(drvdata->mem_start, drvdata->mem_size);
706 kfree(drvdata); 689 kfree(drvdata);
707 dev_set_drvdata(dev, NULL); 690 dev_set_drvdata(dev, NULL);
708 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0;
709 691
692 mutex_lock(&icap_sem);
693 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0;
694 mutex_unlock(&icap_sem);
710 return 0; /* success */ 695 return 0; /* success */
711} 696}
712 697
@@ -821,28 +806,29 @@ static struct of_platform_driver hwicap_of_driver = {
821}; 806};
822 807
823/* Registration helpers to keep the number of #ifdefs to a minimum */ 808/* Registration helpers to keep the number of #ifdefs to a minimum */
824static inline int __devinit hwicap_of_register(void) 809static inline int __init hwicap_of_register(void)
825{ 810{
826 pr_debug("hwicap: calling of_register_platform_driver()\n"); 811 pr_debug("hwicap: calling of_register_platform_driver()\n");
827 return of_register_platform_driver(&hwicap_of_driver); 812 return of_register_platform_driver(&hwicap_of_driver);
828} 813}
829 814
830static inline void __devexit hwicap_of_unregister(void) 815static inline void __exit hwicap_of_unregister(void)
831{ 816{
832 of_unregister_platform_driver(&hwicap_of_driver); 817 of_unregister_platform_driver(&hwicap_of_driver);
833} 818}
834#else /* CONFIG_OF */ 819#else /* CONFIG_OF */
835/* CONFIG_OF not enabled; do nothing helpers */ 820/* CONFIG_OF not enabled; do nothing helpers */
836static inline int __devinit hwicap_of_register(void) { return 0; } 821static inline int __init hwicap_of_register(void) { return 0; }
837static inline void __devexit hwicap_of_unregister(void) { } 822static inline void __exit hwicap_of_unregister(void) { }
838#endif /* CONFIG_OF */ 823#endif /* CONFIG_OF */
839 824
840static int __devinit hwicap_module_init(void) 825static int __init hwicap_module_init(void)
841{ 826{
842 dev_t devt; 827 dev_t devt;
843 int retval; 828 int retval;
844 829
845 icap_class = class_create(THIS_MODULE, "xilinx_config"); 830 icap_class = class_create(THIS_MODULE, "xilinx_config");
831 mutex_init(&icap_sem);
846 832
847 if (xhwicap_major) { 833 if (xhwicap_major) {
848 devt = MKDEV(xhwicap_major, xhwicap_minor); 834 devt = MKDEV(xhwicap_major, xhwicap_minor);
@@ -883,7 +869,7 @@ static int __devinit hwicap_module_init(void)
883 return retval; 869 return retval;
884} 870}
885 871
886static void __devexit hwicap_module_cleanup(void) 872static void __exit hwicap_module_cleanup(void)
887{ 873{
888 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor); 874 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor);
889 875
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
index ae771cac1629..405fee7e189b 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
@@ -48,9 +48,9 @@ struct hwicap_drvdata {
48 u8 write_buffer[4]; 48 u8 write_buffer[4];
49 u32 read_buffer_in_use; /* Always in [0,3] */ 49 u32 read_buffer_in_use; /* Always in [0,3] */
50 u8 read_buffer[4]; 50 u8 read_buffer[4];
51 u32 mem_start; /* phys. address of the control registers */ 51 resource_size_t mem_start;/* phys. address of the control registers */
52 u32 mem_end; /* phys. address of the control registers */ 52 resource_size_t mem_end; /* phys. address of the control registers */
53 u32 mem_size; 53 resource_size_t mem_size;
54 void __iomem *base_address;/* virt. address of the control registers */ 54 void __iomem *base_address;/* virt. address of the control registers */
55 55
56 struct device *dev; 56 struct device *dev;
@@ -61,7 +61,7 @@ struct hwicap_drvdata {
61 const struct config_registers *config_regs; 61 const struct config_registers *config_regs;
62 void *private_data; 62 void *private_data;
63 bool is_open; 63 bool is_open;
64 struct semaphore sem; 64 struct mutex sem;
65}; 65};
66 66
67struct hwicap_driver_config { 67struct hwicap_driver_config {
@@ -164,29 +164,29 @@ struct config_registers {
164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL 164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL
165 165
166/** 166/**
167 * hwicap_type_1_read: Generates a Type 1 read packet header. 167 * hwicap_type_1_read - Generates a Type 1 read packet header.
168 * @parameter: Register is the address of the register to be read back. 168 * @reg: is the address of the register to be read back.
169 * 169 *
170 * Generates a Type 1 read packet header, which is used to indirectly 170 * Generates a Type 1 read packet header, which is used to indirectly
171 * read registers in the configuration logic. This packet must then 171 * read registers in the configuration logic. This packet must then
172 * be sent through the icap device, and a return packet received with 172 * be sent through the icap device, and a return packet received with
173 * the information. 173 * the information.
174 **/ 174 **/
175static inline u32 hwicap_type_1_read(u32 Register) 175static inline u32 hwicap_type_1_read(u32 reg)
176{ 176{
177 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) | 177 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
178 (Register << XHI_REGISTER_SHIFT) | 178 (reg << XHI_REGISTER_SHIFT) |
179 (XHI_OP_READ << XHI_OP_SHIFT); 179 (XHI_OP_READ << XHI_OP_SHIFT);
180} 180}
181 181
182/** 182/**
183 * hwicap_type_1_write: Generates a Type 1 write packet header 183 * hwicap_type_1_write - Generates a Type 1 write packet header
184 * @parameter: Register is the address of the register to be read back. 184 * @reg: is the address of the register to be read back.
185 **/ 185 **/
186static inline u32 hwicap_type_1_write(u32 Register) 186static inline u32 hwicap_type_1_write(u32 reg)
187{ 187{
188 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) | 188 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
189 (Register << XHI_REGISTER_SHIFT) | 189 (reg << XHI_REGISTER_SHIFT) |
190 (XHI_OP_WRITE << XHI_OP_SHIFT); 190 (XHI_OP_WRITE << XHI_OP_SHIFT);
191} 191}
192 192