Re: [PATCH v2 -next] RDMA/srp: use DEVICE_ATTR_*() macro

From: Jason Gunthorpe
Date: Fri May 28 2021 - 08:33:39 EST


On Fri, May 28, 2021 at 08:30:39PM +0800, YueHaibing wrote:
> @@ -3040,22 +3040,22 @@ static ssize_t show_allow_ext_sg(struct device *dev,
> return sysfs_emit(buf, "%s\n", target->allow_ext_sg ? "true" : "false");
> }
>
> -static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
> -static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
> -static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
> -static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
> -static DEVICE_ATTR(sgid, S_IRUGO, show_sgid, NULL);
> -static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
> -static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL);
> -static DEVICE_ATTR(req_lim, S_IRUGO, show_req_lim, NULL);
> -static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
> -static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL);
> -static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL);
> -static DEVICE_ATTR(ch_count, S_IRUGO, show_ch_count, NULL);
> -static DEVICE_ATTR(comp_vector, S_IRUGO, show_comp_vector, NULL);
> -static DEVICE_ATTR(tl_retry_count, S_IRUGO, show_tl_retry_count, NULL);
> -static DEVICE_ATTR(cmd_sg_entries, S_IRUGO, show_cmd_sg_entries, NULL);
> -static DEVICE_ATTR(allow_ext_sg, S_IRUGO, show_allow_ext_sg, NULL);
> +static DEVICE_ATTR_RO(id_ext);
> +static DEVICE_ATTR_RO(ioc_guid);
> +static DEVICE_ATTR_RO(service_id);
> +static DEVICE_ATTR_RO(pkey);
> +static DEVICE_ATTR_RO(sgid);
> +static DEVICE_ATTR_RO(dgid);
> +static DEVICE_ATTR_RO(orig_dgid);
> +static DEVICE_ATTR_RO(req_lim);
> +static DEVICE_ATTR_RO(zero_req_lim);
> +static DEVICE_ATTR_RO(local_ib_port);
> +static DEVICE_ATTR_RO(local_ib_device);
> +static DEVICE_ATTR_RO(ch_count);
> +static DEVICE_ATTR_RO(comp_vector);
> +static DEVICE_ATTR_RO(tl_retry_count);
> +static DEVICE_ATTR_RO(cmd_sg_entries);
> +static DEVICE_ATTR_RO(allow_ext_sg);

can you also organize this so the ATTR's are placed after their
functions, as is normal?

Thanks,
Jason