@@ -664,19 +664,6 @@ static DEVICE_ATTR(dhchap_ctrl_secret, S_IRUGO | S_IWUSR,
664
664
nvme_ctrl_dhchap_ctrl_secret_show , nvme_ctrl_dhchap_ctrl_secret_store ) ;
665
665
#endif
666
666
667
- #ifdef CONFIG_NVME_TCP_TLS
668
- static ssize_t tls_key_show (struct device * dev ,
669
- struct device_attribute * attr , char * buf )
670
- {
671
- struct nvme_ctrl * ctrl = dev_get_drvdata (dev );
672
-
673
- if (!ctrl -> tls_pskid )
674
- return 0 ;
675
- return sysfs_emit (buf , "%08x\n" , ctrl -> tls_pskid );
676
- }
677
- static DEVICE_ATTR_RO (tls_key );
678
- #endif
679
-
680
667
static struct attribute * nvme_dev_attrs [] = {
681
668
& dev_attr_reset_controller .attr ,
682
669
& dev_attr_rescan_controller .attr ,
@@ -703,9 +690,6 @@ static struct attribute *nvme_dev_attrs[] = {
703
690
#ifdef CONFIG_NVME_HOST_AUTH
704
691
& dev_attr_dhchap_secret .attr ,
705
692
& dev_attr_dhchap_ctrl_secret .attr ,
706
- #endif
707
- #ifdef CONFIG_NVME_TCP_TLS
708
- & dev_attr_tls_key .attr ,
709
693
#endif
710
694
& dev_attr_adm_passthru_err_log_enabled .attr ,
711
695
NULL
@@ -737,11 +721,6 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
737
721
if (a == & dev_attr_dhchap_ctrl_secret .attr && !ctrl -> opts )
738
722
return 0 ;
739
723
#endif
740
- #ifdef CONFIG_NVME_TCP_TLS
741
- if (a == & dev_attr_tls_key .attr &&
742
- (!ctrl -> opts || strcmp (ctrl -> opts -> transport , "tcp" )))
743
- return 0 ;
744
- #endif
745
724
746
725
return a -> mode ;
747
726
}
@@ -752,8 +731,49 @@ const struct attribute_group nvme_dev_attrs_group = {
752
731
};
753
732
EXPORT_SYMBOL_GPL (nvme_dev_attrs_group );
754
733
734
+ #ifdef CONFIG_NVME_TCP_TLS
735
+ static ssize_t tls_key_show (struct device * dev ,
736
+ struct device_attribute * attr , char * buf )
737
+ {
738
+ struct nvme_ctrl * ctrl = dev_get_drvdata (dev );
739
+
740
+ if (!ctrl -> tls_pskid )
741
+ return 0 ;
742
+ return sysfs_emit (buf , "%08x\n" , ctrl -> tls_pskid );
743
+ }
744
+ static DEVICE_ATTR_RO (tls_key );
745
+
746
+ static struct attribute * nvme_tls_attrs [] = {
747
+ & dev_attr_tls_key .attr ,
748
+ };
749
+
750
+ static umode_t nvme_tls_attrs_are_visible (struct kobject * kobj ,
751
+ struct attribute * a , int n )
752
+ {
753
+ struct device * dev = container_of (kobj , struct device , kobj );
754
+ struct nvme_ctrl * ctrl = dev_get_drvdata (dev );
755
+
756
+ if (!ctrl -> opts || strcmp (ctrl -> opts -> transport , "tcp" ))
757
+ return 0 ;
758
+
759
+ if (a == & dev_attr_tls_key .attr &&
760
+ !ctrl -> opts -> tls )
761
+ return 0 ;
762
+
763
+ return a -> mode ;
764
+ }
765
+
766
+ const struct attribute_group nvme_tls_attrs_group = {
767
+ .attrs = nvme_tls_attrs ,
768
+ .is_visible = nvme_tls_attrs_are_visible ,
769
+ };
770
+ #endif
771
+
755
772
const struct attribute_group * nvme_dev_attr_groups [] = {
756
773
& nvme_dev_attrs_group ,
774
+ #ifdef CONFIG_NVME_TCP_TLS
775
+ & nvme_tls_attrs_group ,
776
+ #endif
757
777
NULL ,
758
778
};
759
779
0 commit comments