Skip to content

Compile time error "invalid operands to binary / " #9

@lefamz

Description

@lefamz

During make on Raspberry Pi 3, kernel 4.9.35-v7+, gcc (Raspbian 4.9.2-10+deb8u2) 4.9.2, I've encountered following error:
make -C /usr/src/linux-headers-4.9.35-v7+ M=/home/pi/soft_uart modules make[1]: Entering directory '/usr/src/linux-headers-4.9.35-v7+' CC [M] /home/pi/soft_uart/raspberry_soft_uart.o /home/pi/soft_uart/raspberry_soft_uart.c: In function ‘handle_rx_start’: /home/pi/soft_uart/raspberry_soft_uart.c:185:50: error: invalid operands to binary / (have ‘ktime_t’ and ‘int’) hrtimer_start(&timer_rx, ktime_set(0, period / 2), HRTIMER_MODE_REL); ^ scripts/Makefile.build:293: recipe for target '/home/pi/soft_uart/raspberry_soft_uart.o' failed

Issue is caused by line 185:
hrtimer_start(&timer_rx, ktime_set(0, period / 2), HRTIMER_MODE_REL);

I've fixed this with ktime_to_ns function:
hrtimer_start(&timer_rx, ktime_set(0, ktime_to_ns(period) / 2), HRTIMER_MODE_REL);

Hope that helps if anyone faces the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions