@@ -128,11 +128,6 @@ struct aspeed_kcs_bmc {
128128 } obe ;
129129};
130130
131- struct aspeed_kcs_of_ops {
132- int (* get_channel )(struct platform_device * pdev );
133- int (* get_io_address )(struct platform_device * pdev , u32 addrs [2 ]);
134- };
135-
136131static inline struct aspeed_kcs_bmc * to_aspeed_kcs_bmc (struct kcs_bmc_device * kcs_bmc )
137132{
138133 return container_of (kcs_bmc , struct aspeed_kcs_bmc , kcs_bmc );
@@ -475,38 +470,7 @@ static const struct kcs_ioreg ast_kcs_bmc_ioregs[KCS_CHANNEL_MAX] = {
475470 { .idr = LPC_IDR4 , .odr = LPC_ODR4 , .str = LPC_STR4 },
476471};
477472
478- static int aspeed_kcs_of_v1_get_channel (struct platform_device * pdev )
479- {
480- struct device_node * np ;
481- u32 channel ;
482- int rc ;
483-
484- np = pdev -> dev .of_node ;
485-
486- rc = of_property_read_u32 (np , "kcs_chan" , & channel );
487- if ((rc != 0 ) || (channel == 0 || channel > KCS_CHANNEL_MAX )) {
488- dev_err (& pdev -> dev , "no valid 'kcs_chan' configured\n" );
489- return - EINVAL ;
490- }
491-
492- return channel ;
493- }
494-
495- static int
496- aspeed_kcs_of_v1_get_io_address (struct platform_device * pdev , u32 addrs [2 ])
497- {
498- int rc ;
499-
500- rc = of_property_read_u32 (pdev -> dev .of_node , "kcs_addr" , addrs );
501- if (rc || addrs [0 ] > 0xffff ) {
502- dev_err (& pdev -> dev , "no valid 'kcs_addr' configured\n" );
503- return - EINVAL ;
504- }
505-
506- return 1 ;
507- }
508-
509- static int aspeed_kcs_of_v2_get_channel (struct platform_device * pdev )
473+ static int aspeed_kcs_of_get_channel (struct platform_device * pdev )
510474{
511475 struct device_node * np ;
512476 struct kcs_ioreg ioreg ;
@@ -535,12 +499,11 @@ static int aspeed_kcs_of_v2_get_channel(struct platform_device *pdev)
535499 if (!memcmp (& ast_kcs_bmc_ioregs [i ], & ioreg , sizeof (ioreg )))
536500 return i + 1 ;
537501 }
538-
539502 return - EINVAL ;
540503}
541504
542505static int
543- aspeed_kcs_of_v2_get_io_address (struct platform_device * pdev , u32 addrs [2 ])
506+ aspeed_kcs_of_get_io_address (struct platform_device * pdev , u32 addrs [2 ])
544507{
545508 int rc ;
546509
@@ -567,7 +530,6 @@ aspeed_kcs_of_v2_get_io_address(struct platform_device *pdev, u32 addrs[2])
567530
568531static int aspeed_kcs_probe (struct platform_device * pdev )
569532{
570- const struct aspeed_kcs_of_ops * ops ;
571533 struct kcs_bmc_device * kcs_bmc ;
572534 struct aspeed_kcs_bmc * priv ;
573535 struct device_node * np ;
@@ -585,15 +547,11 @@ static int aspeed_kcs_probe(struct platform_device *pdev)
585547 return - ENODEV ;
586548 }
587549
588- ops = of_device_get_match_data (& pdev -> dev );
589- if (!ops )
590- return - EINVAL ;
591-
592- channel = ops -> get_channel (pdev );
550+ channel = aspeed_kcs_of_get_channel (pdev );
593551 if (channel < 0 )
594552 return channel ;
595553
596- nr_addrs = ops -> get_io_address (pdev , addrs );
554+ nr_addrs = aspeed_kcs_of_get_io_address (pdev , addrs );
597555 if (nr_addrs < 0 )
598556 return nr_addrs ;
599557
@@ -678,22 +636,10 @@ static int aspeed_kcs_remove(struct platform_device *pdev)
678636 return 0 ;
679637}
680638
681- static const struct aspeed_kcs_of_ops of_v1_ops = {
682- .get_channel = aspeed_kcs_of_v1_get_channel ,
683- .get_io_address = aspeed_kcs_of_v1_get_io_address ,
684- };
685-
686- static const struct aspeed_kcs_of_ops of_v2_ops = {
687- .get_channel = aspeed_kcs_of_v2_get_channel ,
688- .get_io_address = aspeed_kcs_of_v2_get_io_address ,
689- };
690-
691639static const struct of_device_id ast_kcs_bmc_match [] = {
692- { .compatible = "aspeed,ast2400-kcs-bmc" , .data = & of_v1_ops },
693- { .compatible = "aspeed,ast2500-kcs-bmc" , .data = & of_v1_ops },
694- { .compatible = "aspeed,ast2400-kcs-bmc-v2" , .data = & of_v2_ops },
695- { .compatible = "aspeed,ast2500-kcs-bmc-v2" , .data = & of_v2_ops },
696- { .compatible = "aspeed,ast2600-kcs-bmc" , .data = & of_v2_ops },
640+ { .compatible = "aspeed,ast2400-kcs-bmc-v2" },
641+ { .compatible = "aspeed,ast2500-kcs-bmc-v2" },
642+ { .compatible = "aspeed,ast2600-kcs-bmc" },
697643 { }
698644};
699645MODULE_DEVICE_TABLE (of , ast_kcs_bmc_match );
0 commit comments