Hi,

On Tue, Dec 17, 2024 at 02:51:47PM +0800, Sandor Yu wrote:
> +static ssize_t firmware_version_show(struct device *dev,
> +                                  struct device_attribute *attr, char *buf);
> +static struct device_attribute firmware_version = 
> __ATTR_RO(firmware_version);
> +
> +ssize_t firmware_version_show(struct device *dev,
> +                           struct device_attribute *attr, char *buf)
> +{
> +     struct cdns_mhdp8501_device *mhdp = dev_get_drvdata(dev);
> +
> +     u32 version = readl(mhdp->base.regs + VER_L) | readl(mhdp->base.regs + 
> VER_H) << 8;
> +     u32 lib_version = readl(mhdp->base.regs + VER_LIB_L_ADDR) |
> +                       readl(mhdp->base.regs + VER_LIB_H_ADDR) << 8;
> +
> +     return sprintf(buf, "FW version %d, Lib version %d\n", version, 
> lib_version);
> +}
> +
> +static void cdns_mhdp8501_create_device_files(struct cdns_mhdp8501_device 
> *mhdp)
> +{
> +     if (device_create_file(mhdp->dev, &firmware_version)) {
> +             DRM_ERROR("Unable to create firmware_version sysfs\n");
> +             device_remove_file(mhdp->dev, &firmware_version);
> +     }
> +}

sysfs files are part of the uABI, and need to be stable and documented.

For these kind of things, you should use debugfs.

Maxime

Attachment: signature.asc
Description: PGP signature

Reply via email to