Here is the problem:

To illustrate the double marginalization problem, letís assume that a manufacturer, m, and a retailer, r, use linear pricing
Inverse demand: p = 10 - q
Marginal cost of the manufacturer: c = 2
Marginal cost of the retailer: w
The timing of decisions
m sells to r at a wholesale price w
r sells to end-consumers at a price p
This game needs to be solved backward starting with the maximization problem of r

Here is where I'm stuck:

Profit(retailer) = (10-q)q-qw
= 10q - q^2 -qw
now I need to take the derivative of profit with respect to qantity so I can maximize profit:
\tfrac{dProfit(retailer)}{dQuantity} = 10 - 2q - w = 0
 q = \tfrac{10-w}{2}

That's as far as I got before the prof started going to fast and lost me. I know that I'm supposed to now find the profit of the manufacturer; which would be the demand multiplied by margin. So, would that be:
Profit(manufacturer) =  (w-2)(\tfrac{10-2}{2}) since that would be demand (which I previously found times his margin)?
If that's true, then should I take the derivative of that? I don't know what to do... please help! Thanks