smartmax: unify code for different devices and kernel version