@@ -664,19 +664,6 @@ static DEVICE_ATTR(dhchap_ctrl_secret, S_IRUGO | S_IWUSR,
664664 nvme_ctrl_dhchap_ctrl_secret_show , nvme_ctrl_dhchap_ctrl_secret_store ) ;
665665#endif
666666
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-
680667static struct attribute * nvme_dev_attrs [] = {
681668 & dev_attr_reset_controller .attr ,
682669 & dev_attr_rescan_controller .attr ,
@@ -703,9 +690,6 @@ static struct attribute *nvme_dev_attrs[] = {
703690#ifdef CONFIG_NVME_HOST_AUTH
704691 & dev_attr_dhchap_secret .attr ,
705692 & dev_attr_dhchap_ctrl_secret .attr ,
706- #endif
707- #ifdef CONFIG_NVME_TCP_TLS
708- & dev_attr_tls_key .attr ,
709693#endif
710694 & dev_attr_adm_passthru_err_log_enabled .attr ,
711695 NULL
@@ -737,11 +721,6 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
737721 if (a == & dev_attr_dhchap_ctrl_secret .attr && !ctrl -> opts )
738722 return 0 ;
739723#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
745724
746725 return a -> mode ;
747726}
@@ -752,8 +731,49 @@ const struct attribute_group nvme_dev_attrs_group = {
752731};
753732EXPORT_SYMBOL_GPL (nvme_dev_attrs_group );
754733
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+
755772const struct attribute_group * nvme_dev_attr_groups [] = {
756773 & nvme_dev_attrs_group ,
774+ #ifdef CONFIG_NVME_TCP_TLS
775+ & nvme_tls_attrs_group ,
776+ #endif
757777 NULL ,
758778};
759779
0 commit comments