Skip to content

Commit 7e53f03

Browse files
arndbgregkh
authored andcommitted
watchdog: kempld: fix gcc-4.3 build
[ Upstream commit 3736d4eb6af37492aeded7fec0072dedd959c842 ] gcc-4.3 can't decide whether the constant value in kempld_prescaler[PRESCALER_21] is built-time constant or not, and gets confused by the logic in do_div(): drivers/watchdog/kempld_wdt.o: In function `kempld_wdt_set_stage_timeout': kempld_wdt.c:(.text.kempld_wdt_set_stage_timeout+0x130): undefined reference to `__aeabi_uldivmod' This adds a call to ACCESS_ONCE() to force it to not consider it to be constant, and leaves the more efficient normal case in place for modern compilers, using an #ifdef to annotate why we do this hack. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 28eab3d commit 7e53f03

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/watchdog/kempld_wdt.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,19 @@ static int kempld_wdt_set_stage_timeout(struct kempld_wdt_data *wdt_data,
140140
unsigned int timeout)
141141
{
142142
struct kempld_device_data *pld = wdt_data->pld;
143-
u32 prescaler = kempld_prescaler[PRESCALER_21];
143+
u32 prescaler;
144144
u64 stage_timeout64;
145145
u32 stage_timeout;
146146
u32 remainder;
147147
u8 stage_cfg;
148148

149+
#if GCC_VERSION < 40400
150+
/* work around a bug compiling do_div() */
151+
prescaler = READ_ONCE(kempld_prescaler[PRESCALER_21]);
152+
#else
153+
prescaler = kempld_prescaler[PRESCALER_21];
154+
#endif
155+
149156
if (!stage)
150157
return -EINVAL;
151158

0 commit comments

Comments
 (0)