Re: [PATCH v4 10/10] ufs: sysfs: attributes

From: Greg KH
Date: Thu Feb 01 2018 - 12:03:23 EST


On Thu, Feb 01, 2018 at 06:15:46PM +0200, Stanislav Nijnikov wrote:
> +#define UFS_LUN_ATTRIBUTE(_name, _uname) \
> +static ssize_t _name##_attribute_show(struct device *dev, \
> + struct device_attribute *attr, char *buf) \
> +{ \
> + u32 value; \
> + struct scsi_device *sdev = to_scsi_device(dev); \
> + struct ufs_hba *hba = shost_priv(sdev->host); \
> + u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); \
> + if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, \
> + QUERY_ATTR_IDN##_uname, lun, 0, &value)) \
> + return -EINVAL; \
> + return sprintf(buf, "0x%08X\n", value); \
> +} \
> +static DEVICE_ATTR_RO(_name##_attribute)
> +
> +UFS_LUN_ATTRIBUTE(dyn_cap_needed, _DYN_CAP_NEEDED);

Why create a macro when you only have one instance of its use?

thanks,

greg k-h