File tree Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change @@ -2441,8 +2441,37 @@ static struct caam_crypto_alg *caam_alg_alloc(struct caam_alg_template
24412441
24422442static int __init caam_algapi_init (void )
24432443{
2444+ struct device_node * dev_node ;
2445+ struct platform_device * pdev ;
2446+ struct device * ctrldev ;
2447+ void * priv ;
24442448 int i = 0 , err = 0 ;
24452449
2450+ dev_node = of_find_compatible_node (NULL , NULL , "fsl,sec-v4.0" );
2451+ if (!dev_node ) {
2452+ dev_node = of_find_compatible_node (NULL , NULL , "fsl,sec4.0" );
2453+ if (!dev_node )
2454+ return - ENODEV ;
2455+ }
2456+
2457+ pdev = of_find_device_by_node (dev_node );
2458+ if (!pdev ) {
2459+ of_node_put (dev_node );
2460+ return - ENODEV ;
2461+ }
2462+
2463+ ctrldev = & pdev -> dev ;
2464+ priv = dev_get_drvdata (ctrldev );
2465+ of_node_put (dev_node );
2466+
2467+ /*
2468+ * If priv is NULL, it's probably because the caam driver wasn't
2469+ * properly initialized (e.g. RNG4 init failed). Thus, bail out here.
2470+ */
2471+ if (!priv )
2472+ return - ENODEV ;
2473+
2474+
24462475 INIT_LIST_HEAD (& alg_list );
24472476
24482477 /* register crypto algorithms the device supports */
Original file line number Diff line number Diff line change @@ -1793,8 +1793,36 @@ caam_hash_alloc(struct caam_hash_template *template,
17931793
17941794static int __init caam_algapi_hash_init (void )
17951795{
1796+ struct device_node * dev_node ;
1797+ struct platform_device * pdev ;
1798+ struct device * ctrldev ;
1799+ void * priv ;
17961800 int i = 0 , err = 0 ;
17971801
1802+ dev_node = of_find_compatible_node (NULL , NULL , "fsl,sec-v4.0" );
1803+ if (!dev_node ) {
1804+ dev_node = of_find_compatible_node (NULL , NULL , "fsl,sec4.0" );
1805+ if (!dev_node )
1806+ return - ENODEV ;
1807+ }
1808+
1809+ pdev = of_find_device_by_node (dev_node );
1810+ if (!pdev ) {
1811+ of_node_put (dev_node );
1812+ return - ENODEV ;
1813+ }
1814+
1815+ ctrldev = & pdev -> dev ;
1816+ priv = dev_get_drvdata (ctrldev );
1817+ of_node_put (dev_node );
1818+
1819+ /*
1820+ * If priv is NULL, it's probably because the caam driver wasn't
1821+ * properly initialized (e.g. RNG4 init failed). Thus, bail out here.
1822+ */
1823+ if (!priv )
1824+ return - ENODEV ;
1825+
17981826 INIT_LIST_HEAD (& hash_list );
17991827
18001828 /* register crypto algorithms the device supports */
Original file line number Diff line number Diff line change @@ -278,6 +278,34 @@ static void __exit caam_rng_exit(void)
278278static int __init caam_rng_init (void )
279279{
280280 struct device * dev ;
281+ struct device_node * dev_node ;
282+ struct platform_device * pdev ;
283+ struct device * ctrldev ;
284+ void * priv ;
285+
286+ dev_node = of_find_compatible_node (NULL , NULL , "fsl,sec-v4.0" );
287+ if (!dev_node ) {
288+ dev_node = of_find_compatible_node (NULL , NULL , "fsl,sec4.0" );
289+ if (!dev_node )
290+ return - ENODEV ;
291+ }
292+
293+ pdev = of_find_device_by_node (dev_node );
294+ if (!pdev ) {
295+ of_node_put (dev_node );
296+ return - ENODEV ;
297+ }
298+
299+ ctrldev = & pdev -> dev ;
300+ priv = dev_get_drvdata (ctrldev );
301+ of_node_put (dev_node );
302+
303+ /*
304+ * If priv is NULL, it's probably because the caam driver wasn't
305+ * properly initialized (e.g. RNG4 init failed). Thus, bail out here.
306+ */
307+ if (!priv )
308+ return - ENODEV ;
281309
282310 dev = caam_jr_alloc ();
283311 if (IS_ERR (dev )) {
You can’t perform that action at this time.
0 commit comments