sysfs: Invoke iomem_get_mapping() from the sysfs open callback
Defer invocation of the iomem_get_mapping() to the sysfs open callback
so that it can be executed as needed when the binary sysfs object has
To do that, convert the "mapping" member of the struct bin_attribute
from a pointer to the struct address_space into a function pointer with
a signature that requires the same return type, and then updates the
sysfs_kf_bin_open() to invoke provided function should the function
pointer be valid.
Also, convert every invocation of iomem_get_mapping() into a function
pointer assignment, therefore allowing for the iomem_get_mapping()
invocation to be deferred to when the sysfs open callback runs.
Thus, this change removes the need for the fs_initcalls to complete
before any other sub-system that uses the iomem_get_mapping() would be
able to invoke it safely without leading to a failure and an Oops
related to an invalid iomem_get_mapping() access.
Suggested-by: Dan Williams <email@example.com>
Reviewed-by: Dan Williams <firstname.lastname@example.org>
Acked-by: Bjorn Helgaas <email@example.com>
Signed-off-by: Dan Williams <firstname.lastname@example.org>
Signed-off-by: Krzysztof Wilczyński <email@example.com>
Signed-off-by: Greg Kroah-Hartman <firstname.lastname@example.org>
3 files changed