Skip to content

Commit 7c23fb2

Browse files
committed
Merge tag 'device_is_big_endian-6.8-rc1' into driver-core-next
Tag for the device_is_big_endian() addition to property.h For others to be able to pull from in a stable way. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 parents 7c41da5 + 826a5d8 commit 7c23fb2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

include/linux/property.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,38 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode,
8080

8181
bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
8282

83+
static inline bool fwnode_device_is_big_endian(const struct fwnode_handle *fwnode)
84+
{
85+
if (fwnode_property_present(fwnode, "big-endian"))
86+
return true;
87+
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
88+
fwnode_property_present(fwnode, "native-endian"))
89+
return true;
90+
return false;
91+
}
92+
8393
static inline
8494
bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char *compat)
8595
{
8696
return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
8797
}
8898

99+
/**
100+
* device_is_big_endian - check if a device has BE registers
101+
* @dev: Pointer to the struct device
102+
*
103+
* Returns: true if the device has a "big-endian" property, or if the kernel
104+
* was compiled for BE *and* the device has a "native-endian" property.
105+
* Returns false otherwise.
106+
*
107+
* Callers would nominally use ioread32be/iowrite32be if
108+
* device_is_big_endian() == true, or readl/writel otherwise.
109+
*/
110+
static inline bool device_is_big_endian(const struct device *dev)
111+
{
112+
return fwnode_device_is_big_endian(dev_fwnode(dev));
113+
}
114+
89115
/**
90116
* device_is_compatible - match 'compatible' property of the device with a given string
91117
* @dev: Pointer to the struct device

0 commit comments

Comments
 (0)