Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: RDMA/srp: Switch to attribute groups

struct device supports attribute groups directly but does not support
struct device_attribute directly. Hence switch to attribute groups.

Link: https://lore.kernel.org/r/20211012233558.4066756-5-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
a3cf94c9 5e88e67b

+30 -21
+30 -21
drivers/infiniband/ulp/srp/ib_srp.c
··· 1026 1026 */ 1027 1027 static void srp_del_scsi_host_attr(struct Scsi_Host *shost) 1028 1028 { 1029 - struct device_attribute **attr; 1029 + const struct attribute_group **g; 1030 + struct attribute **attr; 1030 1031 1031 - for (attr = shost->hostt->shost_attrs; attr && *attr; ++attr) 1032 - device_remove_file(&shost->shost_dev, *attr); 1032 + for (g = shost->hostt->shost_groups; *g; ++g) { 1033 + for (attr = (*g)->attrs; *attr; ++attr) { 1034 + struct device_attribute *dev_attr = 1035 + container_of(*attr, typeof(*dev_attr), attr); 1036 + 1037 + device_remove_file(&shost->shost_dev, dev_attr); 1038 + } 1039 + } 1033 1040 } 1034 1041 1035 1042 static void srp_remove_target(struct srp_target_port *target) ··· 3057 3050 3058 3051 static DEVICE_ATTR_RO(allow_ext_sg); 3059 3052 3060 - static struct device_attribute *srp_host_attrs[] = { 3061 - &dev_attr_id_ext, 3062 - &dev_attr_ioc_guid, 3063 - &dev_attr_service_id, 3064 - &dev_attr_pkey, 3065 - &dev_attr_sgid, 3066 - &dev_attr_dgid, 3067 - &dev_attr_orig_dgid, 3068 - &dev_attr_req_lim, 3069 - &dev_attr_zero_req_lim, 3070 - &dev_attr_local_ib_port, 3071 - &dev_attr_local_ib_device, 3072 - &dev_attr_ch_count, 3073 - &dev_attr_comp_vector, 3074 - &dev_attr_tl_retry_count, 3075 - &dev_attr_cmd_sg_entries, 3076 - &dev_attr_allow_ext_sg, 3053 + static struct attribute *srp_host_attrs[] = { 3054 + &dev_attr_id_ext.attr, 3055 + &dev_attr_ioc_guid.attr, 3056 + &dev_attr_service_id.attr, 3057 + &dev_attr_pkey.attr, 3058 + &dev_attr_sgid.attr, 3059 + &dev_attr_dgid.attr, 3060 + &dev_attr_orig_dgid.attr, 3061 + &dev_attr_req_lim.attr, 3062 + &dev_attr_zero_req_lim.attr, 3063 + &dev_attr_local_ib_port.attr, 3064 + &dev_attr_local_ib_device.attr, 3065 + &dev_attr_ch_count.attr, 3066 + &dev_attr_comp_vector.attr, 3067 + &dev_attr_tl_retry_count.attr, 3068 + &dev_attr_cmd_sg_entries.attr, 3069 + &dev_attr_allow_ext_sg.attr, 3077 3070 NULL 3078 3071 }; 3072 + 3073 + ATTRIBUTE_GROUPS(srp_host); 3079 3074 3080 3075 static struct scsi_host_template srp_template = { 3081 3076 .module = THIS_MODULE, ··· 3099 3090 .can_queue = SRP_DEFAULT_CMD_SQ_SIZE, 3100 3091 .this_id = -1, 3101 3092 .cmd_per_lun = SRP_DEFAULT_CMD_SQ_SIZE, 3102 - .shost_attrs = srp_host_attrs, 3093 + .shost_groups = srp_host_groups, 3103 3094 .track_queue_depth = 1, 3104 3095 .cmd_size = sizeof(struct srp_request), 3105 3096 };