diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2023-01-20 18:03:43 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-01-23 09:17:44 +0100 |
commit | e699600232e0ca6237b996aa1a94a056cf776582 (patch) | |
tree | 46c95171972109b5a877597bf755e48109357230 /drivers/firewire/core.h | |
parent | 13a55d6bb15fa6bf0dcaf997e0676f532f258f52 (diff) |
firewire: cdev: obsolete NULL check to detect IEC 61883-1 FCP region
In the character device, the listener to address space should distinguish
whether the request is to IEC 61883-1 FCP region or not. The user space
application needs to access to the object of request in enough later by
read(2), while the core function releases the object of request in the FCP
case after completing the callback to handler.
The handler guarantees the access safe by some way. It's done by
duplication of the object after NULL check to the request, since core
function passes NULL in the FCP case. It's inconvenient since the object
of request includes some helpful information. It's better to add another
way to check whether the request is to FCP region or not.
Conveniently the file of transaction layer includes local implementation
for the purpose. This commit moves it to module local file and use it
instead of the NULL check, then the result of check is stored to
per-client data for the inbound transaction so that the result can be
referred by later to release the data.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230120090344.296451-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'drivers/firewire/core.h')
-rw-r--r-- | drivers/firewire/core.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 78c99f1d27fa..eafa4eaae737 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -257,4 +257,10 @@ static inline bool is_ping_packet(u32 *data) return (data[0] & 0xc0ffffff) == 0 && ~data[0] == data[1]; } +static inline bool is_in_fcp_region(u64 offset, size_t length) +{ + return offset >= (CSR_REGISTER_BASE | CSR_FCP_COMMAND) && + offset + length <= (CSR_REGISTER_BASE | CSR_FCP_END); +} + #endif /* _FIREWIRE_CORE_H */ |