@@ -197,44 +197,6 @@ static void scmi_fetch_response(struct scmi_xfer *xfer,
197
197
memcpy_fromio (xfer -> rx .buf , mem -> msg_payload + 4 , xfer -> rx .len );
198
198
}
199
199
200
- /**
201
- * scmi_rx_callback() - mailbox client callback for receive messages
202
- *
203
- * @cl: client pointer
204
- * @m: mailbox message
205
- *
206
- * Processes one received message to appropriate transfer information and
207
- * signals completion of the transfer.
208
- *
209
- * NOTE: This function will be invoked in IRQ context, hence should be
210
- * as optimal as possible.
211
- */
212
- static void scmi_rx_callback (struct mbox_client * cl , void * m )
213
- {
214
- u16 xfer_id ;
215
- struct scmi_xfer * xfer ;
216
- struct scmi_chan_info * cinfo = client_to_scmi_chan_info (cl );
217
- struct device * dev = cinfo -> dev ;
218
- struct scmi_info * info = handle_to_scmi_info (cinfo -> handle );
219
- struct scmi_xfers_info * minfo = & info -> minfo ;
220
- struct scmi_shared_mem __iomem * mem = cinfo -> payload ;
221
-
222
- xfer_id = MSG_XTRACT_TOKEN (ioread32 (& mem -> msg_header ));
223
-
224
- /* Are we even expecting this? */
225
- if (!test_bit (xfer_id , minfo -> xfer_alloc_table )) {
226
- dev_err (dev , "message for %d is not expected!\n" , xfer_id );
227
- return ;
228
- }
229
-
230
- xfer = & minfo -> xfer_block [xfer_id ];
231
-
232
- scmi_dump_header_dbg (dev , & xfer -> hdr );
233
-
234
- scmi_fetch_response (xfer , mem );
235
- complete (& xfer -> done );
236
- }
237
-
238
200
/**
239
201
* pack_scmi_header() - packs and returns 32-bit header
240
202
*
@@ -349,6 +311,44 @@ void scmi_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer)
349
311
spin_unlock_irqrestore (& minfo -> xfer_lock , flags );
350
312
}
351
313
314
+ /**
315
+ * scmi_rx_callback() - mailbox client callback for receive messages
316
+ *
317
+ * @cl: client pointer
318
+ * @m: mailbox message
319
+ *
320
+ * Processes one received message to appropriate transfer information and
321
+ * signals completion of the transfer.
322
+ *
323
+ * NOTE: This function will be invoked in IRQ context, hence should be
324
+ * as optimal as possible.
325
+ */
326
+ static void scmi_rx_callback (struct mbox_client * cl , void * m )
327
+ {
328
+ u16 xfer_id ;
329
+ struct scmi_xfer * xfer ;
330
+ struct scmi_chan_info * cinfo = client_to_scmi_chan_info (cl );
331
+ struct device * dev = cinfo -> dev ;
332
+ struct scmi_info * info = handle_to_scmi_info (cinfo -> handle );
333
+ struct scmi_xfers_info * minfo = & info -> minfo ;
334
+ struct scmi_shared_mem __iomem * mem = cinfo -> payload ;
335
+
336
+ xfer_id = MSG_XTRACT_TOKEN (ioread32 (& mem -> msg_header ));
337
+
338
+ /* Are we even expecting this? */
339
+ if (!test_bit (xfer_id , minfo -> xfer_alloc_table )) {
340
+ dev_err (dev , "message for %d is not expected!\n" , xfer_id );
341
+ return ;
342
+ }
343
+
344
+ xfer = & minfo -> xfer_block [xfer_id ];
345
+
346
+ scmi_dump_header_dbg (dev , & xfer -> hdr );
347
+
348
+ scmi_fetch_response (xfer , mem );
349
+ complete (& xfer -> done );
350
+ }
351
+
352
352
static bool
353
353
scmi_xfer_poll_done (const struct scmi_chan_info * cinfo , struct scmi_xfer * xfer )
354
354
{
@@ -599,20 +599,6 @@ int scmi_handle_put(const struct scmi_handle *handle)
599
599
return 0 ;
600
600
}
601
601
602
- static const struct scmi_desc scmi_generic_desc = {
603
- .max_rx_timeout_ms = 30 , /* We may increase this if required */
604
- .max_msg = 20 , /* Limited by MBOX_TX_QUEUE_LEN */
605
- .max_msg_size = 128 ,
606
- };
607
-
608
- /* Each compatible listed below must have descriptor associated with it */
609
- static const struct of_device_id scmi_of_match [] = {
610
- { .compatible = "arm,scmi" , .data = & scmi_generic_desc },
611
- { /* Sentinel */ },
612
- };
613
-
614
- MODULE_DEVICE_TABLE (of , scmi_of_match );
615
-
616
602
static int scmi_xfer_info_init (struct scmi_info * sinfo )
617
603
{
618
604
int i ;
@@ -659,44 +645,6 @@ static int scmi_mailbox_check(struct device_node *np)
659
645
return of_parse_phandle_with_args (np , "mboxes" , "#mbox-cells" , 0 , NULL );
660
646
}
661
647
662
- static int scmi_mbox_free_channel (int id , void * p , void * data )
663
- {
664
- struct scmi_chan_info * cinfo = p ;
665
- struct idr * idr = data ;
666
-
667
- if (!IS_ERR_OR_NULL (cinfo -> chan )) {
668
- mbox_free_channel (cinfo -> chan );
669
- cinfo -> chan = NULL ;
670
- }
671
-
672
- idr_remove (idr , id );
673
-
674
- return 0 ;
675
- }
676
-
677
- static int scmi_remove (struct platform_device * pdev )
678
- {
679
- int ret = 0 ;
680
- struct scmi_info * info = platform_get_drvdata (pdev );
681
- struct idr * idr = & info -> tx_idr ;
682
-
683
- mutex_lock (& scmi_list_mutex );
684
- if (info -> users )
685
- ret = - EBUSY ;
686
- else
687
- list_del (& info -> node );
688
- mutex_unlock (& scmi_list_mutex );
689
-
690
- if (ret )
691
- return ret ;
692
-
693
- /* Safe to free channels since no more users */
694
- ret = idr_for_each (idr , scmi_mbox_free_channel , idr );
695
- idr_destroy (& info -> tx_idr );
696
-
697
- return ret ;
698
- }
699
-
700
648
static inline int
701
649
scmi_mbox_chan_setup (struct scmi_info * info , struct device * dev , int prot_id )
702
650
{
@@ -856,6 +804,58 @@ static int scmi_probe(struct platform_device *pdev)
856
804
return 0 ;
857
805
}
858
806
807
+ static int scmi_mbox_free_channel (int id , void * p , void * data )
808
+ {
809
+ struct scmi_chan_info * cinfo = p ;
810
+ struct idr * idr = data ;
811
+
812
+ if (!IS_ERR_OR_NULL (cinfo -> chan )) {
813
+ mbox_free_channel (cinfo -> chan );
814
+ cinfo -> chan = NULL ;
815
+ }
816
+
817
+ idr_remove (idr , id );
818
+
819
+ return 0 ;
820
+ }
821
+
822
+ static int scmi_remove (struct platform_device * pdev )
823
+ {
824
+ int ret = 0 ;
825
+ struct scmi_info * info = platform_get_drvdata (pdev );
826
+ struct idr * idr = & info -> tx_idr ;
827
+
828
+ mutex_lock (& scmi_list_mutex );
829
+ if (info -> users )
830
+ ret = - EBUSY ;
831
+ else
832
+ list_del (& info -> node );
833
+ mutex_unlock (& scmi_list_mutex );
834
+
835
+ if (ret )
836
+ return ret ;
837
+
838
+ /* Safe to free channels since no more users */
839
+ ret = idr_for_each (idr , scmi_mbox_free_channel , idr );
840
+ idr_destroy (& info -> tx_idr );
841
+
842
+ return ret ;
843
+ }
844
+
845
+ static const struct scmi_desc scmi_generic_desc = {
846
+ .max_rx_timeout_ms = 30 , /* We may increase this if required */
847
+ .max_msg = 20 , /* Limited by MBOX_TX_QUEUE_LEN */
848
+ .max_msg_size = 128 ,
849
+ };
850
+
851
+ /* Each compatible listed below must have descriptor associated with it */
852
+ static const struct of_device_id scmi_of_match [] = {
853
+ { .compatible = "arm,scmi" , .data = & scmi_generic_desc },
854
+ { /* Sentinel */ },
855
+ };
856
+
857
+ MODULE_DEVICE_TABLE (of , scmi_of_match );
858
+
859
859
static struct platform_driver scmi_driver = {
860
860
.driver = {
861
861
.name = "arm-scmi" ,
0 commit comments