mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: add missing type cast's to safe_ops.h
Add the following type cast operations. - nvgpu_safe_cast_u64_to_s32 - nvgpu_safe_cast_u64_to_s64 - nvgpu_safe_cast_s64_to_s32 JIRA NVGPU-3485 Change-Id: I454bace8d65f6c0e65adfc722eae66fa55c6dc8f Signed-off-by: Antony Clince Alex <aalex@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2128466 Reviewed-by: Rajesh Devaraj <rdevaraj@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
1daaf83dce
commit
cc3b0467db
@@ -199,4 +199,30 @@ static inline s32 nvgpu_safe_cast_u32_to_s32(u32 ui_a)
|
||||
}
|
||||
}
|
||||
|
||||
static inline s32 nvgpu_safe_cast_u64_to_s32(u64 ul_a)
|
||||
{
|
||||
if (ul_a > INT_MAX) {
|
||||
BUG();
|
||||
} else {
|
||||
return (s32)ul_a;
|
||||
}
|
||||
}
|
||||
|
||||
static inline s64 nvgpu_safe_cast_u64_to_s64(u64 ul_a)
|
||||
{
|
||||
if (ul_a > LONG_MAX) {
|
||||
BUG();
|
||||
} else {
|
||||
return (s64)ul_a;
|
||||
}
|
||||
}
|
||||
|
||||
static inline s32 nvgpu_safe_cast_s64_to_s32(s64 sl_a)
|
||||
{
|
||||
if (sl_a > INT_MAX || sl_a < INT_MIN) {
|
||||
BUG();
|
||||
} else {
|
||||
return (s32)sl_a;
|
||||
}
|
||||
}
|
||||
#endif /* NVGPU_SAFE_OPS_H */
|
||||
|
||||
Reference in New Issue
Block a user