28
28
29
29
static struct ida mdev_id ;
30
30
static int dummy_num_buffers ;
31
-
32
- static struct mostcore {
33
- struct device_driver drv ;
34
- struct bus_type bus ;
35
- struct list_head comp_list ;
36
- } mc ;
37
-
38
- #define to_driver (d ) container_of(d, struct mostcore, drv)
31
+ static struct list_head comp_list ;
39
32
40
33
struct pipe {
41
34
struct most_component * comp ;
@@ -457,7 +450,7 @@ static struct most_component *match_component(char *name)
457
450
{
458
451
struct most_component * comp ;
459
452
460
- list_for_each_entry (comp , & mc . comp_list , list ) {
453
+ list_for_each_entry (comp , & comp_list , list ) {
461
454
if (!strcmp (comp -> name , name ))
462
455
return comp ;
463
456
}
@@ -499,11 +492,24 @@ static int print_links(struct device *dev, void *data)
499
492
return 0 ;
500
493
}
501
494
495
+ static int most_match (struct device * dev , struct device_driver * drv )
496
+ {
497
+ if (!strcmp (dev_name (dev ), "most" ))
498
+ return 0 ;
499
+ else
500
+ return 1 ;
501
+ }
502
+
503
+ static struct bus_type mostbus = {
504
+ .name = "most" ,
505
+ .match = most_match ,
506
+ };
507
+
502
508
static ssize_t links_show (struct device_driver * drv , char * buf )
503
509
{
504
510
struct show_links_data d = { .buf = buf };
505
511
506
- bus_for_each_dev (& mc . bus , NULL , & d , print_links );
512
+ bus_for_each_dev (& mostbus , NULL , & d , print_links );
507
513
return d .offs ;
508
514
}
509
515
@@ -512,7 +518,7 @@ static ssize_t components_show(struct device_driver *drv, char *buf)
512
518
struct most_component * comp ;
513
519
int offs = 0 ;
514
520
515
- list_for_each_entry (comp , & mc . comp_list , list ) {
521
+ list_for_each_entry (comp , & comp_list , list ) {
516
522
offs += snprintf (buf + offs , PAGE_SIZE - offs , "%s\n" ,
517
523
comp -> name );
518
524
}
@@ -530,7 +536,7 @@ static struct most_channel *get_channel(char *mdev, char *mdev_ch)
530
536
struct most_interface * iface ;
531
537
struct most_channel * c , * tmp ;
532
538
533
- dev = bus_find_device_by_name (& mc . bus , NULL , mdev );
539
+ dev = bus_find_device_by_name (& mostbus , NULL , mdev );
534
540
if (!dev )
535
541
return NULL ;
536
542
put_device (dev );
@@ -722,13 +728,11 @@ static const struct attribute_group *mc_attr_groups[] = {
722
728
NULL ,
723
729
};
724
730
725
- static int most_match (struct device * dev , struct device_driver * drv )
726
- {
727
- if (!strcmp (dev_name (dev ), "most" ))
728
- return 0 ;
729
- else
730
- return 1 ;
731
- }
731
+ static struct device_driver mostbus_driver = {
732
+ .name = "most_core" ,
733
+ .bus = & mostbus ,
734
+ .groups = mc_attr_groups ,
735
+ };
732
736
733
737
static inline void trash_mbo (struct mbo * mbo )
734
738
{
@@ -1221,7 +1225,7 @@ int most_register_component(struct most_component *comp)
1221
1225
pr_err ("Bad component\n" );
1222
1226
return - EINVAL ;
1223
1227
}
1224
- list_add_tail (& comp -> list , & mc . comp_list );
1228
+ list_add_tail (& comp -> list , & comp_list );
1225
1229
return 0 ;
1226
1230
}
1227
1231
EXPORT_SYMBOL_GPL (most_register_component );
@@ -1255,7 +1259,7 @@ int most_deregister_component(struct most_component *comp)
1255
1259
return - EINVAL ;
1256
1260
}
1257
1261
1258
- bus_for_each_dev (& mc . bus , NULL , comp , disconnect_channels );
1262
+ bus_for_each_dev (& mostbus , NULL , comp , disconnect_channels );
1259
1263
list_del (& comp -> list );
1260
1264
return 0 ;
1261
1265
}
@@ -1302,7 +1306,7 @@ int most_register_interface(struct most_interface *iface)
1302
1306
INIT_LIST_HEAD (& iface -> p -> channel_list );
1303
1307
iface -> p -> dev_id = id ;
1304
1308
strscpy (iface -> p -> name , iface -> description , sizeof (iface -> p -> name ));
1305
- iface -> dev -> bus = & mc . bus ;
1309
+ iface -> dev -> bus = & mostbus ;
1306
1310
iface -> dev -> groups = interface_attr_groups ;
1307
1311
dev_set_drvdata (iface -> dev , iface );
1308
1312
if (device_register (iface -> dev )) {
@@ -1454,21 +1458,15 @@ static int __init most_init(void)
1454
1458
{
1455
1459
int err ;
1456
1460
1457
- INIT_LIST_HEAD (& mc . comp_list );
1461
+ INIT_LIST_HEAD (& comp_list );
1458
1462
ida_init (& mdev_id );
1459
1463
1460
- mc .bus .name = "most" ,
1461
- mc .bus .match = most_match ,
1462
- mc .drv .name = "most_core" ,
1463
- mc .drv .bus = & mc .bus ,
1464
- mc .drv .groups = mc_attr_groups ;
1465
-
1466
- err = bus_register (& mc .bus );
1464
+ err = bus_register (& mostbus );
1467
1465
if (err ) {
1468
1466
pr_err ("Cannot register most bus\n" );
1469
1467
return err ;
1470
1468
}
1471
- err = driver_register (& mc . drv );
1469
+ err = driver_register (& mostbus_driver );
1472
1470
if (err ) {
1473
1471
pr_err ("Cannot register core driver\n" );
1474
1472
goto err_unregister_bus ;
@@ -1477,14 +1475,14 @@ static int __init most_init(void)
1477
1475
return 0 ;
1478
1476
1479
1477
err_unregister_bus :
1480
- bus_unregister (& mc . bus );
1478
+ bus_unregister (& mostbus );
1481
1479
return err ;
1482
1480
}
1483
1481
1484
1482
static void __exit most_exit (void )
1485
1483
{
1486
- driver_unregister (& mc . drv );
1487
- bus_unregister (& mc . bus );
1484
+ driver_unregister (& mostbus_driver );
1485
+ bus_unregister (& mostbus );
1488
1486
ida_destroy (& mdev_id );
1489
1487
}
1490
1488
0 commit comments