devm_ioremap() in a sysfs show method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,

I'm trying to create a simple sysfs node that prints the content of a
register. The code looks like this

static ssize_t
my_read_reg(struct device *pdev, struct device_attribute *attr, char *buf)
{
    u32 __iomem *reg;

    reg = devm_ioremap(pdev, 0x581018C4, 4);
    return scnprintf(buf, PAGE_SIZE, "0x%02x\n", ioread8(reg));
}

Is it ok to use devm_ioremap() on the device that I get here? If so, may
I assume that devm_ioremap() re-uses an existing mapping and it's ok to
call it for each sysfs access?

The physical address that I pass to devm_ioremap() is not page-aligned.
This seems to work on arm. Is there a recommended (i.e. more portable)
way of doing this? Should I map a larger area and use PAGE_ALIGN()?

Thanks for your feedback,

   Martin

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux