Control of resistive wall modes in tokamak plasmas