aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2012-03-19 15:48:34 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-15 08:36:51 -0400
commit1eaef48b42aae965950c884e3f03143cb44da71b (patch)
treee42778c4a4b84b62e16a6444718e3e2022cd9648
parent943a903459db81a07c3af703605d4eb6fb64b523 (diff)
[media] dib9000: get rid of Dib*Lock macros
The patch replaces Dib*Lock macros with direct calls to mutex functions as soon as they just make the driver code harder to review (per request of Mauro). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/frontends/dib9000.c128
1 files changed, 58 insertions, 70 deletions
diff --git a/drivers/media/dvb/frontends/dib9000.c b/drivers/media/dvb/frontends/dib9000.c
index 0661da919b50..6201c59a78dd 100644
--- a/drivers/media/dvb/frontends/dib9000.c
+++ b/drivers/media/dvb/frontends/dib9000.c
@@ -31,13 +31,6 @@ struct i2c_device {
31 u8 *i2c_write_buffer; 31 u8 *i2c_write_buffer;
32}; 32};
33 33
34/* lock */
35#define DIB_LOCK struct mutex
36#define DibAcquireLock(lock) mutex_lock_interruptible(lock)
37#define DibReleaseLock(lock) mutex_unlock(lock)
38#define DibInitLock(lock) mutex_init(lock)
39#define DibFreeLock(lock)
40
41struct dib9000_pid_ctrl { 34struct dib9000_pid_ctrl {
42#define DIB9000_PID_FILTER_CTRL 0 35#define DIB9000_PID_FILTER_CTRL 0
43#define DIB9000_PID_FILTER 1 36#define DIB9000_PID_FILTER 1
@@ -82,11 +75,11 @@ struct dib9000_state {
82 } fe_mm[18]; 75 } fe_mm[18];
83 u8 memcmd; 76 u8 memcmd;
84 77
85 DIB_LOCK mbx_if_lock; /* to protect read/write operations */ 78 struct mutex mbx_if_lock; /* to protect read/write operations */
86 DIB_LOCK mbx_lock; /* to protect the whole mailbox handling */ 79 struct mutex mbx_lock; /* to protect the whole mailbox handling */
87 80
88 DIB_LOCK mem_lock; /* to protect the memory accesses */ 81 struct mutex mem_lock; /* to protect the memory accesses */
89 DIB_LOCK mem_mbx_lock; /* to protect the memory-based mailbox */ 82 struct mutex mem_mbx_lock; /* to protect the memory-based mailbox */
90 83
91#define MBX_MAX_WORDS (256 - 200 - 2) 84#define MBX_MAX_WORDS (256 - 200 - 2)
92#define DIB9000_MSG_CACHE_SIZE 2 85#define DIB9000_MSG_CACHE_SIZE 2
@@ -108,7 +101,7 @@ struct dib9000_state {
108 struct i2c_msg msg[2]; 101 struct i2c_msg msg[2];
109 u8 i2c_write_buffer[255]; 102 u8 i2c_write_buffer[255];
110 u8 i2c_read_buffer[255]; 103 u8 i2c_read_buffer[255];
111 DIB_LOCK demod_lock; 104 struct mutex demod_lock;
112 u8 get_frontend_internal; 105 u8 get_frontend_internal;
113 struct dib9000_pid_ctrl pid_ctrl[10]; 106 struct dib9000_pid_ctrl pid_ctrl[10];
114 s8 pid_ctrl_index; /* -1: empty list; -2: do not use the list */ 107 s8 pid_ctrl_index; /* -1: empty list; -2: do not use the list */
@@ -446,13 +439,13 @@ static int dib9000_risc_mem_read(struct dib9000_state *state, u8 cmd, u8 * b, u1
446 if (!state->platform.risc.fw_is_running) 439 if (!state->platform.risc.fw_is_running)
447 return -EIO; 440 return -EIO;
448 441
449 if (DibAcquireLock(&state->platform.risc.mem_lock) < 0) { 442 if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) {
450 dprintk("could not get the lock"); 443 dprintk("could not get the lock");
451 return -EINTR; 444 return -EINTR;
452 } 445 }
453 dib9000_risc_mem_setup(state, cmd | 0x80); 446 dib9000_risc_mem_setup(state, cmd | 0x80);
454 dib9000_risc_mem_read_chunks(state, b, len); 447 dib9000_risc_mem_read_chunks(state, b, len);
455 DibReleaseLock(&state->platform.risc.mem_lock); 448 mutex_unlock(&state->platform.risc.mem_lock);
456 return 0; 449 return 0;
457} 450}
458 451
@@ -462,13 +455,13 @@ static int dib9000_risc_mem_write(struct dib9000_state *state, u8 cmd, const u8
462 if (!state->platform.risc.fw_is_running) 455 if (!state->platform.risc.fw_is_running)
463 return -EIO; 456 return -EIO;
464 457
465 if (DibAcquireLock(&state->platform.risc.mem_lock) < 0) { 458 if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) {
466 dprintk("could not get the lock"); 459 dprintk("could not get the lock");
467 return -EINTR; 460 return -EINTR;
468 } 461 }
469 dib9000_risc_mem_setup(state, cmd); 462 dib9000_risc_mem_setup(state, cmd);
470 dib9000_risc_mem_write_chunks(state, b, m->size); 463 dib9000_risc_mem_write_chunks(state, b, m->size);
471 DibReleaseLock(&state->platform.risc.mem_lock); 464 mutex_unlock(&state->platform.risc.mem_lock);
472 return 0; 465 return 0;
473} 466}
474 467
@@ -537,7 +530,7 @@ static int dib9000_mbx_send_attr(struct dib9000_state *state, u8 id, u16 * data,
537 if (!state->platform.risc.fw_is_running) 530 if (!state->platform.risc.fw_is_running)
538 return -EINVAL; 531 return -EINVAL;
539 532
540 if (DibAcquireLock(&state->platform.risc.mbx_if_lock) < 0) { 533 if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) {
541 dprintk("could not get the lock"); 534 dprintk("could not get the lock");
542 return -EINTR; 535 return -EINTR;
543 } 536 }
@@ -584,7 +577,7 @@ static int dib9000_mbx_send_attr(struct dib9000_state *state, u8 id, u16 * data,
584 ret = (u8) dib9000_write_word_attr(state, 1043, 1 << 14, attr); 577 ret = (u8) dib9000_write_word_attr(state, 1043, 1 << 14, attr);
585 578
586out: 579out:
587 DibReleaseLock(&state->platform.risc.mbx_if_lock); 580 mutex_unlock(&state->platform.risc.mbx_if_lock);
588 581
589 return ret; 582 return ret;
590} 583}
@@ -602,7 +595,7 @@ static u8 dib9000_mbx_read(struct dib9000_state *state, u16 * data, u8 risc_id,
602 if (!state->platform.risc.fw_is_running) 595 if (!state->platform.risc.fw_is_running)
603 return 0; 596 return 0;
604 597
605 if (DibAcquireLock(&state->platform.risc.mbx_if_lock) < 0) { 598 if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) {
606 dprintk("could not get the lock"); 599 dprintk("could not get the lock");
607 return 0; 600 return 0;
608 } 601 }
@@ -643,7 +636,7 @@ static u8 dib9000_mbx_read(struct dib9000_state *state, u16 * data, u8 risc_id,
643 /* Update register nb_mes_in_TX */ 636 /* Update register nb_mes_in_TX */
644 dib9000_write_word_attr(state, 1028 + mc_base, 1 << 14, attr); 637 dib9000_write_word_attr(state, 1028 + mc_base, 1 << 14, attr);
645 638
646 DibReleaseLock(&state->platform.risc.mbx_if_lock); 639 mutex_unlock(&state->platform.risc.mbx_if_lock);
647 640
648 return size + 1; 641 return size + 1;
649} 642}
@@ -712,7 +705,7 @@ static int dib9000_mbx_process(struct dib9000_state *state, u16 attr)
712 if (!state->platform.risc.fw_is_running) 705 if (!state->platform.risc.fw_is_running)
713 return -1; 706 return -1;
714 707
715 if (DibAcquireLock(&state->platform.risc.mbx_lock) < 0) { 708 if (mutex_lock_interruptible(&state->platform.risc.mbx_lock) < 0) {
716 dprintk("could not get the lock"); 709 dprintk("could not get the lock");
717 return -1; 710 return -1;
718 } 711 }
@@ -723,7 +716,7 @@ static int dib9000_mbx_process(struct dib9000_state *state, u16 attr)
723 dib9000_read_word_attr(state, 1229, attr); /* Clear the IRQ */ 716 dib9000_read_word_attr(state, 1229, attr); /* Clear the IRQ */
724/* if (tmp) */ 717/* if (tmp) */
725/* dprintk( "cleared IRQ: %x", tmp); */ 718/* dprintk( "cleared IRQ: %x", tmp); */
726 DibReleaseLock(&state->platform.risc.mbx_lock); 719 mutex_unlock(&state->platform.risc.mbx_lock);
727 720
728 return ret; 721 return ret;
729} 722}
@@ -1192,7 +1185,7 @@ static int dib9000_fw_get_channel(struct dvb_frontend *fe)
1192 struct dibDVBTChannel *ch; 1185 struct dibDVBTChannel *ch;
1193 int ret = 0; 1186 int ret = 0;
1194 1187
1195 if (DibAcquireLock(&state->platform.risc.mem_mbx_lock) < 0) { 1188 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
1196 dprintk("could not get the lock"); 1189 dprintk("could not get the lock");
1197 return -EINTR; 1190 return -EINTR;
1198 } 1191 }
@@ -1322,7 +1315,7 @@ static int dib9000_fw_get_channel(struct dvb_frontend *fe)
1322 } 1315 }
1323 1316
1324error: 1317error:
1325 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 1318 mutex_unlock(&state->platform.risc.mem_mbx_lock);
1326 return ret; 1319 return ret;
1327} 1320}
1328 1321
@@ -1677,7 +1670,7 @@ static int dib9000_fw_component_bus_xfer(struct i2c_adapter *i2c_adap, struct i2
1677 p[12] = 0; 1670 p[12] = 0;
1678 } 1671 }
1679 1672
1680 if (DibAcquireLock(&state->platform.risc.mem_mbx_lock) < 0) { 1673 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
1681 dprintk("could not get the lock"); 1674 dprintk("could not get the lock");
1682 return 0; 1675 return 0;
1683 } 1676 }
@@ -1691,7 +1684,7 @@ static int dib9000_fw_component_bus_xfer(struct i2c_adapter *i2c_adap, struct i2
1691 1684
1692 /* do the transaction */ 1685 /* do the transaction */
1693 if (dib9000_fw_memmbx_sync(state, FE_SYNC_COMPONENT_ACCESS) < 0) { 1686 if (dib9000_fw_memmbx_sync(state, FE_SYNC_COMPONENT_ACCESS) < 0) {
1694 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 1687 mutex_unlock(&state->platform.risc.mem_mbx_lock);
1695 return 0; 1688 return 0;
1696 } 1689 }
1697 1690
@@ -1699,7 +1692,7 @@ static int dib9000_fw_component_bus_xfer(struct i2c_adapter *i2c_adap, struct i2
1699 if ((num > 1) && (msg[1].flags & I2C_M_RD)) 1692 if ((num > 1) && (msg[1].flags & I2C_M_RD))
1700 dib9000_risc_mem_read(state, FE_MM_RW_COMPONENT_ACCESS_BUFFER, msg[1].buf, msg[1].len); 1693 dib9000_risc_mem_read(state, FE_MM_RW_COMPONENT_ACCESS_BUFFER, msg[1].buf, msg[1].len);
1701 1694
1702 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 1695 mutex_unlock(&state->platform.risc.mem_mbx_lock);
1703 1696
1704 return num; 1697 return num;
1705} 1698}
@@ -1788,7 +1781,7 @@ int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
1788 return 0; 1781 return 0;
1789 } 1782 }
1790 1783
1791 if (DibAcquireLock(&state->demod_lock) < 0) { 1784 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1792 dprintk("could not get the lock"); 1785 dprintk("could not get the lock");
1793 return -EINTR; 1786 return -EINTR;
1794 } 1787 }
@@ -1798,7 +1791,7 @@ int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
1798 1791
1799 dprintk("PID filter enabled %d", onoff); 1792 dprintk("PID filter enabled %d", onoff);
1800 ret = dib9000_write_word(state, 294 + 1, val); 1793 ret = dib9000_write_word(state, 294 + 1, val);
1801 DibReleaseLock(&state->demod_lock); 1794 mutex_unlock(&state->demod_lock);
1802 return ret; 1795 return ret;
1803 1796
1804} 1797}
@@ -1823,14 +1816,14 @@ int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
1823 return 0; 1816 return 0;
1824 } 1817 }
1825 1818
1826 if (DibAcquireLock(&state->demod_lock) < 0) { 1819 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1827 dprintk("could not get the lock"); 1820 dprintk("could not get the lock");
1828 return -EINTR; 1821 return -EINTR;
1829 } 1822 }
1830 dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff); 1823 dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff);
1831 ret = dib9000_write_word(state, 300 + 1 + id, 1824 ret = dib9000_write_word(state, 300 + 1 + id,
1832 onoff ? (1 << 13) | pid : 0); 1825 onoff ? (1 << 13) | pid : 0);
1833 DibReleaseLock(&state->demod_lock); 1826 mutex_unlock(&state->demod_lock);
1834 return ret; 1827 return ret;
1835} 1828}
1836EXPORT_SYMBOL(dib9000_fw_pid_filter); 1829EXPORT_SYMBOL(dib9000_fw_pid_filter);
@@ -1850,11 +1843,6 @@ static void dib9000_release(struct dvb_frontend *demod)
1850 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (st->fe[index_frontend] != NULL); index_frontend++) 1843 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (st->fe[index_frontend] != NULL); index_frontend++)
1851 dvb_frontend_detach(st->fe[index_frontend]); 1844 dvb_frontend_detach(st->fe[index_frontend]);
1852 1845
1853 DibFreeLock(&state->platform.risc.mbx_if_lock);
1854 DibFreeLock(&state->platform.risc.mbx_lock);
1855 DibFreeLock(&state->platform.risc.mem_lock);
1856 DibFreeLock(&state->platform.risc.mem_mbx_lock);
1857 DibFreeLock(&state->demod_lock);
1858 dibx000_exit_i2c_master(&st->i2c_master); 1846 dibx000_exit_i2c_master(&st->i2c_master);
1859 1847
1860 i2c_del_adapter(&st->tuner_adap); 1848 i2c_del_adapter(&st->tuner_adap);
@@ -1874,7 +1862,7 @@ static int dib9000_sleep(struct dvb_frontend *fe)
1874 u8 index_frontend; 1862 u8 index_frontend;
1875 int ret = 0; 1863 int ret = 0;
1876 1864
1877 if (DibAcquireLock(&state->demod_lock) < 0) { 1865 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1878 dprintk("could not get the lock"); 1866 dprintk("could not get the lock");
1879 return -EINTR; 1867 return -EINTR;
1880 } 1868 }
@@ -1886,7 +1874,7 @@ static int dib9000_sleep(struct dvb_frontend *fe)
1886 ret = dib9000_mbx_send(state, OUT_MSG_FE_SLEEP, NULL, 0); 1874 ret = dib9000_mbx_send(state, OUT_MSG_FE_SLEEP, NULL, 0);
1887 1875
1888error: 1876error:
1889 DibReleaseLock(&state->demod_lock); 1877 mutex_unlock(&state->demod_lock);
1890 return ret; 1878 return ret;
1891} 1879}
1892 1880
@@ -1904,7 +1892,7 @@ static int dib9000_get_frontend(struct dvb_frontend *fe)
1904 int ret = 0; 1892 int ret = 0;
1905 1893
1906 if (state->get_frontend_internal == 0) { 1894 if (state->get_frontend_internal == 0) {
1907 if (DibAcquireLock(&state->demod_lock) < 0) { 1895 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
1908 dprintk("could not get the lock"); 1896 dprintk("could not get the lock");
1909 return -EINTR; 1897 return -EINTR;
1910 } 1898 }
@@ -1963,7 +1951,7 @@ static int dib9000_get_frontend(struct dvb_frontend *fe)
1963 1951
1964return_value: 1952return_value:
1965 if (state->get_frontend_internal == 0) 1953 if (state->get_frontend_internal == 0)
1966 DibReleaseLock(&state->demod_lock); 1954 mutex_unlock(&state->demod_lock);
1967 return ret; 1955 return ret;
1968} 1956}
1969 1957
@@ -2011,7 +1999,7 @@ static int dib9000_set_frontend(struct dvb_frontend *fe)
2011 } 1999 }
2012 2000
2013 state->pid_ctrl_index = -1; /* postpone the pid filtering cmd */ 2001 state->pid_ctrl_index = -1; /* postpone the pid filtering cmd */
2014 if (DibAcquireLock(&state->demod_lock) < 0) { 2002 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2015 dprintk("could not get the lock"); 2003 dprintk("could not get the lock");
2016 return 0; 2004 return 0;
2017 } 2005 }
@@ -2080,7 +2068,7 @@ static int dib9000_set_frontend(struct dvb_frontend *fe)
2080 /* check the tune result */ 2068 /* check the tune result */
2081 if (exit_condition == 1) { /* tune failed */ 2069 if (exit_condition == 1) { /* tune failed */
2082 dprintk("tune failed"); 2070 dprintk("tune failed");
2083 DibReleaseLock(&state->demod_lock); 2071 mutex_unlock(&state->demod_lock);
2084 /* tune failed; put all the pid filtering cmd to junk */ 2072 /* tune failed; put all the pid filtering cmd to junk */
2085 state->pid_ctrl_index = -1; 2073 state->pid_ctrl_index = -1;
2086 return 0; 2074 return 0;
@@ -2136,7 +2124,7 @@ static int dib9000_set_frontend(struct dvb_frontend *fe)
2136 /* turn off the diversity for the last frontend */ 2124 /* turn off the diversity for the last frontend */
2137 dib9000_fw_set_diversity_in(state->fe[index_frontend - 1], 0); 2125 dib9000_fw_set_diversity_in(state->fe[index_frontend - 1], 0);
2138 2126
2139 DibReleaseLock(&state->demod_lock); 2127 mutex_unlock(&state->demod_lock);
2140 if (state->pid_ctrl_index >= 0) { 2128 if (state->pid_ctrl_index >= 0) {
2141 u8 index_pid_filter_cmd; 2129 u8 index_pid_filter_cmd;
2142 u8 pid_ctrl_index = state->pid_ctrl_index; 2130 u8 pid_ctrl_index = state->pid_ctrl_index;
@@ -2174,7 +2162,7 @@ static int dib9000_read_status(struct dvb_frontend *fe, fe_status_t * stat)
2174 u8 index_frontend; 2162 u8 index_frontend;
2175 u16 lock = 0, lock_slave = 0; 2163 u16 lock = 0, lock_slave = 0;
2176 2164
2177 if (DibAcquireLock(&state->demod_lock) < 0) { 2165 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2178 dprintk("could not get the lock"); 2166 dprintk("could not get the lock");
2179 return -EINTR; 2167 return -EINTR;
2180 } 2168 }
@@ -2196,7 +2184,7 @@ static int dib9000_read_status(struct dvb_frontend *fe, fe_status_t * stat)
2196 if ((lock & 0x0008) || (lock_slave & 0x0008)) 2184 if ((lock & 0x0008) || (lock_slave & 0x0008))
2197 *stat |= FE_HAS_LOCK; 2185 *stat |= FE_HAS_LOCK;
2198 2186
2199 DibReleaseLock(&state->demod_lock); 2187 mutex_unlock(&state->demod_lock);
2200 2188
2201 return 0; 2189 return 0;
2202} 2190}
@@ -2207,30 +2195,30 @@ static int dib9000_read_ber(struct dvb_frontend *fe, u32 * ber)
2207 u16 *c; 2195 u16 *c;
2208 int ret = 0; 2196 int ret = 0;
2209 2197
2210 if (DibAcquireLock(&state->demod_lock) < 0) { 2198 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2211 dprintk("could not get the lock"); 2199 dprintk("could not get the lock");
2212 return -EINTR; 2200 return -EINTR;
2213 } 2201 }
2214 if (DibAcquireLock(&state->platform.risc.mem_mbx_lock) < 0) { 2202 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2215 dprintk("could not get the lock"); 2203 dprintk("could not get the lock");
2216 ret = -EINTR; 2204 ret = -EINTR;
2217 goto error; 2205 goto error;
2218 } 2206 }
2219 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) { 2207 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
2220 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2208 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2221 ret = -EIO; 2209 ret = -EIO;
2222 goto error; 2210 goto error;
2223 } 2211 }
2224 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, 2212 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR,
2225 state->i2c_read_buffer, 16 * 2); 2213 state->i2c_read_buffer, 16 * 2);
2226 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2214 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2227 2215
2228 c = (u16 *)state->i2c_read_buffer; 2216 c = (u16 *)state->i2c_read_buffer;
2229 2217
2230 *ber = c[10] << 16 | c[11]; 2218 *ber = c[10] << 16 | c[11];
2231 2219
2232error: 2220error:
2233 DibReleaseLock(&state->demod_lock); 2221 mutex_unlock(&state->demod_lock);
2234 return ret; 2222 return ret;
2235} 2223}
2236 2224
@@ -2242,7 +2230,7 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
2242 u16 val; 2230 u16 val;
2243 int ret = 0; 2231 int ret = 0;
2244 2232
2245 if (DibAcquireLock(&state->demod_lock) < 0) { 2233 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2246 dprintk("could not get the lock"); 2234 dprintk("could not get the lock");
2247 return -EINTR; 2235 return -EINTR;
2248 } 2236 }
@@ -2255,18 +2243,18 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
2255 *strength += val; 2243 *strength += val;
2256 } 2244 }
2257 2245
2258 if (DibAcquireLock(&state->platform.risc.mem_mbx_lock) < 0) { 2246 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2259 dprintk("could not get the lock"); 2247 dprintk("could not get the lock");
2260 ret = -EINTR; 2248 ret = -EINTR;
2261 goto error; 2249 goto error;
2262 } 2250 }
2263 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) { 2251 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
2264 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2252 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2265 ret = -EIO; 2253 ret = -EIO;
2266 goto error; 2254 goto error;
2267 } 2255 }
2268 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2); 2256 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2);
2269 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2257 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2270 2258
2271 val = 65535 - c[4]; 2259 val = 65535 - c[4];
2272 if (val > 65535 - *strength) 2260 if (val > 65535 - *strength)
@@ -2275,7 +2263,7 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
2275 *strength += val; 2263 *strength += val;
2276 2264
2277error: 2265error:
2278 DibReleaseLock(&state->demod_lock); 2266 mutex_unlock(&state->demod_lock);
2279 return ret; 2267 return ret;
2280} 2268}
2281 2269
@@ -2286,16 +2274,16 @@ static u32 dib9000_get_snr(struct dvb_frontend *fe)
2286 u32 n, s, exp; 2274 u32 n, s, exp;
2287 u16 val; 2275 u16 val;
2288 2276
2289 if (DibAcquireLock(&state->platform.risc.mem_mbx_lock) < 0) { 2277 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2290 dprintk("could not get the lock"); 2278 dprintk("could not get the lock");
2291 return 0; 2279 return 0;
2292 } 2280 }
2293 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) { 2281 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
2294 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2282 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2295 return 0; 2283 return 0;
2296 } 2284 }
2297 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2); 2285 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2);
2298 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2286 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2299 2287
2300 val = c[7]; 2288 val = c[7];
2301 n = (val >> 4) & 0xff; 2289 n = (val >> 4) & 0xff;
@@ -2325,7 +2313,7 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr)
2325 u8 index_frontend; 2313 u8 index_frontend;
2326 u32 snr_master; 2314 u32 snr_master;
2327 2315
2328 if (DibAcquireLock(&state->demod_lock) < 0) { 2316 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2329 dprintk("could not get the lock"); 2317 dprintk("could not get the lock");
2330 return -EINTR; 2318 return -EINTR;
2331 } 2319 }
@@ -2339,7 +2327,7 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr)
2339 } else 2327 } else
2340 *snr = 0; 2328 *snr = 0;
2341 2329
2342 DibReleaseLock(&state->demod_lock); 2330 mutex_unlock(&state->demod_lock);
2343 2331
2344 return 0; 2332 return 0;
2345} 2333}
@@ -2350,27 +2338,27 @@ static int dib9000_read_unc_blocks(struct dvb_frontend *fe, u32 * unc)
2350 u16 *c = (u16 *)state->i2c_read_buffer; 2338 u16 *c = (u16 *)state->i2c_read_buffer;
2351 int ret = 0; 2339 int ret = 0;
2352 2340
2353 if (DibAcquireLock(&state->demod_lock) < 0) { 2341 if (mutex_lock_interruptible(&state->demod_lock) < 0) {
2354 dprintk("could not get the lock"); 2342 dprintk("could not get the lock");
2355 return -EINTR; 2343 return -EINTR;
2356 } 2344 }
2357 if (DibAcquireLock(&state->platform.risc.mem_mbx_lock) < 0) { 2345 if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
2358 dprintk("could not get the lock"); 2346 dprintk("could not get the lock");
2359 ret = -EINTR; 2347 ret = -EINTR;
2360 goto error; 2348 goto error;
2361 } 2349 }
2362 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) { 2350 if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
2363 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2351 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2364 ret = -EIO; 2352 ret = -EIO;
2365 goto error; 2353 goto error;
2366 } 2354 }
2367 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2); 2355 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2);
2368 DibReleaseLock(&state->platform.risc.mem_mbx_lock); 2356 mutex_unlock(&state->platform.risc.mem_mbx_lock);
2369 2357
2370 *unc = c[12]; 2358 *unc = c[12];
2371 2359
2372error: 2360error:
2373 DibReleaseLock(&state->demod_lock); 2361 mutex_unlock(&state->demod_lock);
2374 return ret; 2362 return ret;
2375} 2363}
2376 2364
@@ -2513,11 +2501,11 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c
2513 st->gpio_val = DIB9000_GPIO_DEFAULT_VALUES; 2501 st->gpio_val = DIB9000_GPIO_DEFAULT_VALUES;
2514 st->gpio_pwm_pos = DIB9000_GPIO_DEFAULT_PWM_POS; 2502 st->gpio_pwm_pos = DIB9000_GPIO_DEFAULT_PWM_POS;
2515 2503
2516 DibInitLock(&st->platform.risc.mbx_if_lock); 2504 mutex_init(&st->platform.risc.mbx_if_lock);
2517 DibInitLock(&st->platform.risc.mbx_lock); 2505 mutex_init(&st->platform.risc.mbx_lock);
2518 DibInitLock(&st->platform.risc.mem_lock); 2506 mutex_init(&st->platform.risc.mem_lock);
2519 DibInitLock(&st->platform.risc.mem_mbx_lock); 2507 mutex_init(&st->platform.risc.mem_mbx_lock);
2520 DibInitLock(&st->demod_lock); 2508 mutex_init(&st->demod_lock);
2521 st->get_frontend_internal = 0; 2509 st->get_frontend_internal = 0;
2522 2510
2523 st->pid_ctrl_index = -2; 2511 st->pid_ctrl_index = -2;