@@ -36,7 +36,7 @@ static int max_devices = 16;
3636module_param (max_devices , int , 0644 );
3737MODULE_PARM_DESC (max_devices , "max number of switchtec device instances" );
3838
39- static bool use_dma_mrpc = true ;
39+ static bool use_dma_mrpc = 1 ;
4040module_param (use_dma_mrpc , bool , 0644 );
4141MODULE_PARM_DESC (use_dma_mrpc ,
4242 "Enable the use of the DMA MRPC feature" );
@@ -60,11 +60,10 @@ struct switchtec_user {
6060
6161 enum mrpc_state state ;
6262
63- wait_queue_head_t cmd_comp ;
63+ struct completion comp ;
6464 struct kref kref ;
6565 struct list_head list ;
6666
67- bool cmd_done ;
6867 u32 cmd ;
6968 u32 status ;
7069 u32 return_code ;
@@ -93,7 +92,7 @@ static struct switchtec_user *stuser_create(struct switchtec_dev *stdev)
9392 stuser -> stdev = stdev ;
9493 kref_init (& stuser -> kref );
9594 INIT_LIST_HEAD (& stuser -> list );
96- init_waitqueue_head (& stuser -> cmd_comp );
95+ init_completion (& stuser -> comp );
9796 stuser -> event_cnt = atomic_read (& stdev -> event_cnt );
9897
9998 dev_dbg (& stdev -> dev , "%s: %p\n" , __func__ , stuser );
@@ -188,7 +187,7 @@ static int mrpc_queue_cmd(struct switchtec_user *stuser)
188187 kref_get (& stuser -> kref );
189188 stuser -> read_len = sizeof (stuser -> data );
190189 stuser_set_state (stuser , MRPC_QUEUED );
191- stuser -> cmd_done = false ;
190+ init_completion ( & stuser -> comp ) ;
192191 list_add_tail (& stuser -> list , & stdev -> mrpc_queue );
193192
194193 mrpc_cmd_submit (stdev );
@@ -202,8 +201,7 @@ static void mrpc_cleanup_cmd(struct switchtec_dev *stdev)
202201 struct switchtec_user * stuser = list_entry (stdev -> mrpc_queue .next ,
203202 struct switchtec_user , list );
204203
205- stuser -> cmd_done = true;
206- wake_up_interruptible (& stuser -> cmd_comp );
204+ complete_all (& stuser -> comp );
207205 list_del_init (& stuser -> list );
208206 stuser_put (stuser );
209207 stdev -> mrpc_busy = 0 ;
@@ -574,11 +572,10 @@ static ssize_t switchtec_dev_read(struct file *filp, char __user *data,
574572 mutex_unlock (& stdev -> mrpc_mutex );
575573
576574 if (filp -> f_flags & O_NONBLOCK ) {
577- if (!stuser -> cmd_done )
575+ if (!try_wait_for_completion ( & stuser -> comp ) )
578576 return - EAGAIN ;
579577 } else {
580- rc = wait_event_interruptible (stuser -> cmd_comp ,
581- stuser -> cmd_done );
578+ rc = wait_for_completion_interruptible (& stuser -> comp );
582579 if (rc < 0 )
583580 return rc ;
584581 }
@@ -632,15 +629,15 @@ static __poll_t switchtec_dev_poll(struct file *filp, poll_table *wait)
632629 struct switchtec_dev * stdev = stuser -> stdev ;
633630 __poll_t ret = 0 ;
634631
635- poll_wait (filp , & stuser -> cmd_comp , wait );
632+ poll_wait (filp , & stuser -> comp . wait , wait );
636633 poll_wait (filp , & stdev -> event_wq , wait );
637634
638635 if (lock_mutex_and_test_alive (stdev ))
639636 return EPOLLIN | EPOLLRDHUP | EPOLLOUT | EPOLLERR | EPOLLHUP ;
640637
641638 mutex_unlock (& stdev -> mrpc_mutex );
642639
643- if (stuser -> cmd_done )
640+ if (try_wait_for_completion ( & stuser -> comp ) )
644641 ret |= EPOLLIN | EPOLLRDNORM ;
645642
646643 if (stuser -> event_cnt != atomic_read (& stdev -> event_cnt ))
@@ -988,18 +985,18 @@ static u32 __iomem *event_hdr_addr(struct switchtec_dev *stdev,
988985 size_t off ;
989986
990987 if (event_id < 0 || event_id >= SWITCHTEC_IOCTL_MAX_EVENTS )
991- return ( u32 __iomem * ) ERR_PTR (- EINVAL );
988+ return ERR_PTR (- EINVAL );
992989
993990 off = event_regs [event_id ].offset ;
994991
995992 if (event_regs [event_id ].map_reg == part_ev_reg ) {
996993 if (index == SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX )
997994 index = stdev -> partition ;
998995 else if (index < 0 || index >= stdev -> partition_count )
999- return ( u32 __iomem * ) ERR_PTR (- EINVAL );
996+ return ERR_PTR (- EINVAL );
1000997 } else if (event_regs [event_id ].map_reg == pff_ev_reg ) {
1001998 if (index < 0 || index >= stdev -> pff_csr_count )
1002- return ( u32 __iomem * ) ERR_PTR (- EINVAL );
999+ return ERR_PTR (- EINVAL );
10031000 }
10041001
10051002 return event_regs [event_id ].map_reg (stdev , off , index );
@@ -1108,11 +1105,11 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
11081105}
11091106
11101107static int ioctl_pff_to_port (struct switchtec_dev * stdev ,
1111- struct switchtec_ioctl_pff_port __user * up )
1108+ struct switchtec_ioctl_pff_port * up )
11121109{
11131110 int i , part ;
11141111 u32 reg ;
1115- struct part_cfg_regs __iomem * pcfg ;
1112+ struct part_cfg_regs * pcfg ;
11161113 struct switchtec_ioctl_pff_port p ;
11171114
11181115 if (copy_from_user (& p , up , sizeof (p )))
@@ -1155,10 +1152,10 @@ static int ioctl_pff_to_port(struct switchtec_dev *stdev,
11551152}
11561153
11571154static int ioctl_port_to_pff (struct switchtec_dev * stdev ,
1158- struct switchtec_ioctl_pff_port __user * up )
1155+ struct switchtec_ioctl_pff_port * up )
11591156{
11601157 struct switchtec_ioctl_pff_port p ;
1161- struct part_cfg_regs __iomem * pcfg ;
1158+ struct part_cfg_regs * pcfg ;
11621159
11631160 if (copy_from_user (& p , up , sizeof (p )))
11641161 return - EFAULT ;
@@ -1326,8 +1323,7 @@ static void stdev_kill(struct switchtec_dev *stdev)
13261323
13271324 /* Wake up and kill any users waiting on an MRPC request */
13281325 list_for_each_entry_safe (stuser , tmpuser , & stdev -> mrpc_queue , list ) {
1329- stuser -> cmd_done = true;
1330- wake_up_interruptible (& stuser -> cmd_comp );
1326+ complete_all (& stuser -> comp );
13311327 list_del_init (& stuser -> list );
13321328 stuser_put (stuser );
13331329 }
@@ -1497,7 +1493,7 @@ static int switchtec_init_isr(struct switchtec_dev *stdev)
14971493 if (nvecs < 0 )
14981494 return nvecs ;
14991495
1500- event_irq = ioread16 (& stdev -> mmio_part_cfg -> vep_vector_number );
1496+ event_irq = ioread32 (& stdev -> mmio_part_cfg -> vep_vector_number );
15011497 if (event_irq < 0 || event_irq >= nvecs )
15021498 return - EFAULT ;
15031499
@@ -1534,7 +1530,7 @@ static void init_pff(struct switchtec_dev *stdev)
15341530{
15351531 int i ;
15361532 u32 reg ;
1537- struct part_cfg_regs __iomem * pcfg = stdev -> mmio_part_cfg ;
1533+ struct part_cfg_regs * pcfg = stdev -> mmio_part_cfg ;
15381534
15391535 for (i = 0 ; i < SWITCHTEC_MAX_PFF_CSR ; i ++ ) {
15401536 reg = ioread16 (& stdev -> mmio_pff_csr [i ].vendor_id );
0 commit comments