I've just sold a D90 (for £240, 30k shutter) in favour of a new D3200, so I've got some skin in this game. It has to be said I also have a D700 as my "big" camera, so I was looking for a smaller body in particular as a complement, but my comments still hold true.
Coming from the d40, you want a d90, d300s or d7000
The d3200 and d5100 are limited in terms of controls and if you are experienced, you will find this limiting.
This is oft-repeated, but it's not as clear cut as that. Something like a D3200 has a very conveniently-located ISO/Fn button (left side of lens mount, operated by thumb), better placed than the ISO button on the rear left of the D90, which I found very awkward in use, necessitating an unwanted hand movement. One could argue the D3200 is better-handling because of this one very important improvement. It's less-used controls like WB that don't have dedicated buttons, and in my experience the camera has to be taken from the eye to see what is being changed anyway when it comes to QUAL and WB, so the on-screen menu of the D3200 is little if any slower to operate than a hold-and-twirl body like a D90. And the D3200 has the bext DX sensor *ever*, which could command a decent premium over any other DX camera if it was in a flagship body. It seems to get overlooked because it's the entry level camera but - that sensor! But one's technique needs to be up to the challenge of using all those extra MPs otherwise it's just a waste of storage.
Where the D3200 does fall down is autofocus. It's not all that fast, and only the centre point is a cross point. It's not suitable for moving objects in my experience. In fact, given the high-res sensor and pedestrian autofocus, the D3200 is perfect for thoughtful landscapes and travel rather than kids, action, or sports (which is miles away from what Nikon's marketing BS says it's for). I use mine with a 24mm AI-S lens - full manual, no metering (!) - and it's a joy to use: small, powerful, ergonomically perfect.
However, since the OP says "often motorsport", even though the AF module is the same, I found the D90 to feel more responsive AF-wise, although still not really reliable for stuff that moves. If that's important, get a D300.
So really it boils down to what you're doing with it. Kids and motorsports? D300 for its AF. Travel and landscape with some higher ISO? D3200. Having said all that, the D90 is a decent upgrade from a D40 (I also made this jump as well, no regrets) so you can't go wrong there either, and it's the cheapest option. Good luck choosing.