@@ -906,6 +906,7 @@ static const struct attribute_group auth_attr_group = {
906
906
.is_visible = auth_attr_is_visible ,
907
907
.attrs = auth_attrs ,
908
908
};
909
+ __ATTRIBUTE_GROUPS (auth_attr );
909
910
910
911
/* ---- Attributes sysfs --------------------------------------------------------- */
911
912
static ssize_t display_name_show (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1121,6 +1122,7 @@ static const struct attribute_group tlmi_attr_group = {
1121
1122
.is_visible = attr_is_visible ,
1122
1123
.attrs = tlmi_attrs ,
1123
1124
};
1125
+ __ATTRIBUTE_GROUPS (tlmi_attr );
1124
1126
1125
1127
static void tlmi_attr_setting_release (struct kobject * kobj )
1126
1128
{
@@ -1140,11 +1142,13 @@ static void tlmi_pwd_setting_release(struct kobject *kobj)
1140
1142
static const struct kobj_type tlmi_attr_setting_ktype = {
1141
1143
.release = & tlmi_attr_setting_release ,
1142
1144
.sysfs_ops = & kobj_sysfs_ops ,
1145
+ .default_groups = tlmi_attr_groups ,
1143
1146
};
1144
1147
1145
1148
static const struct kobj_type tlmi_pwd_setting_ktype = {
1146
1149
.release = & tlmi_pwd_setting_release ,
1147
1150
.sysfs_ops = & kobj_sysfs_ops ,
1151
+ .default_groups = auth_attr_groups ,
1148
1152
};
1149
1153
1150
1154
static ssize_t pending_reboot_show (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1314,14 +1318,8 @@ static struct kobj_attribute debug_cmd = __ATTR_WO(debug_cmd);
1314
1318
static void tlmi_release_attr (void )
1315
1319
{
1316
1320
struct kobject * pos , * n ;
1317
- int i ;
1318
1321
1319
1322
/* Attribute structures */
1320
- for (i = 0 ; i < TLMI_SETTINGS_COUNT ; i ++ ) {
1321
- if (tlmi_priv .setting [i ]) {
1322
- sysfs_remove_group (& tlmi_priv .setting [i ]-> kobj , & tlmi_attr_group );
1323
- }
1324
- }
1325
1323
sysfs_remove_file (& tlmi_priv .attribute_kset -> kobj , & pending_reboot .attr );
1326
1324
sysfs_remove_file (& tlmi_priv .attribute_kset -> kobj , & save_settings .attr );
1327
1325
@@ -1338,15 +1336,6 @@ static void tlmi_release_attr(void)
1338
1336
kfree (tlmi_priv .pwd_admin -> save_signature );
1339
1337
1340
1338
/* Authentication structures */
1341
- sysfs_remove_group (& tlmi_priv .pwd_admin -> kobj , & auth_attr_group );
1342
- sysfs_remove_group (& tlmi_priv .pwd_power -> kobj , & auth_attr_group );
1343
-
1344
- if (tlmi_priv .opcode_support ) {
1345
- sysfs_remove_group (& tlmi_priv .pwd_system -> kobj , & auth_attr_group );
1346
- sysfs_remove_group (& tlmi_priv .pwd_hdd -> kobj , & auth_attr_group );
1347
- sysfs_remove_group (& tlmi_priv .pwd_nvme -> kobj , & auth_attr_group );
1348
- }
1349
-
1350
1339
list_for_each_entry_safe (pos , n , & tlmi_priv .authentication_kset -> list , entry )
1351
1340
kobject_put (pos );
1352
1341
@@ -1417,10 +1406,6 @@ static int tlmi_sysfs_init(void)
1417
1406
NULL , "%s" , tlmi_priv .setting [i ]-> display_name );
1418
1407
if (ret )
1419
1408
goto fail_create_attr ;
1420
-
1421
- ret = sysfs_create_group (& tlmi_priv .setting [i ]-> kobj , & tlmi_attr_group );
1422
- if (ret )
1423
- goto fail_create_attr ;
1424
1409
}
1425
1410
1426
1411
ret = sysfs_create_file (& tlmi_priv .attribute_kset -> kobj , & pending_reboot .attr );
@@ -1444,50 +1429,30 @@ static int tlmi_sysfs_init(void)
1444
1429
if (ret )
1445
1430
goto fail_create_attr ;
1446
1431
1447
- ret = sysfs_create_group (& tlmi_priv .pwd_admin -> kobj , & auth_attr_group );
1448
- if (ret )
1449
- goto fail_create_attr ;
1450
-
1451
1432
tlmi_priv .pwd_power -> kobj .kset = tlmi_priv .authentication_kset ;
1452
1433
ret = kobject_init_and_add (& tlmi_priv .pwd_power -> kobj , & tlmi_pwd_setting_ktype ,
1453
1434
NULL , "%s" , "Power-on" );
1454
1435
if (ret )
1455
1436
goto fail_create_attr ;
1456
1437
1457
- ret = sysfs_create_group (& tlmi_priv .pwd_power -> kobj , & auth_attr_group );
1458
- if (ret )
1459
- goto fail_create_attr ;
1460
-
1461
1438
if (tlmi_priv .opcode_support ) {
1462
1439
tlmi_priv .pwd_system -> kobj .kset = tlmi_priv .authentication_kset ;
1463
1440
ret = kobject_init_and_add (& tlmi_priv .pwd_system -> kobj , & tlmi_pwd_setting_ktype ,
1464
1441
NULL , "%s" , "System" );
1465
1442
if (ret )
1466
1443
goto fail_create_attr ;
1467
1444
1468
- ret = sysfs_create_group (& tlmi_priv .pwd_system -> kobj , & auth_attr_group );
1469
- if (ret )
1470
- goto fail_create_attr ;
1471
-
1472
1445
tlmi_priv .pwd_hdd -> kobj .kset = tlmi_priv .authentication_kset ;
1473
1446
ret = kobject_init_and_add (& tlmi_priv .pwd_hdd -> kobj , & tlmi_pwd_setting_ktype ,
1474
1447
NULL , "%s" , "HDD" );
1475
1448
if (ret )
1476
1449
goto fail_create_attr ;
1477
1450
1478
- ret = sysfs_create_group (& tlmi_priv .pwd_hdd -> kobj , & auth_attr_group );
1479
- if (ret )
1480
- goto fail_create_attr ;
1481
-
1482
1451
tlmi_priv .pwd_nvme -> kobj .kset = tlmi_priv .authentication_kset ;
1483
1452
ret = kobject_init_and_add (& tlmi_priv .pwd_nvme -> kobj , & tlmi_pwd_setting_ktype ,
1484
1453
NULL , "%s" , "NVMe" );
1485
1454
if (ret )
1486
1455
goto fail_create_attr ;
1487
-
1488
- ret = sysfs_create_group (& tlmi_priv .pwd_nvme -> kobj , & auth_attr_group );
1489
- if (ret )
1490
- goto fail_create_attr ;
1491
1456
}
1492
1457
1493
1458
return ret ;
0 commit comments