After plummeting in 2011 and 2012, shares of Hewlett-Packard Company (HPQ 1.25%) have rebounded in the last year and a half. In fact, Hewlett-Packard stock has nearly tripled since bottoming out in November, 2012, and reached a new multiyear high just last week.

HPQ Chart

Hewlett-Packard Five-Year Stock Chart. Source: YCharts.

During 2013, even as other tech powerhouses like International Business Machines (IBM 0.86%) started to lose steam, HP made significant progress in its turnaround. In the last few quarters, HP has seen solid results from the printing and enterprise group business units, its two main profit drivers. (Those two segments accounted for about 75% of HP's pretax segment profit last year.)

If Hewlett-Packard can demonstrate progress this year in fixing its enterprise services business -- which is the real "problem child" at HP today -- the stock could reach $40 by next year. That represents more than 20% upside to the current price.

Margin growth in printing
The first part of Hewlett-Packard to return to health was the printing business, which historically has been HP's biggest cash cow. Printing revenue slipped 2.6% last year due to deflation for many printer components and supplies, but pretax profit for the printing business segment grew 8.5% year over year.

HP's printing segment has returned to earnings growth.

Printing segment earnings continued to increase last quarter, albeit at a more modest 1.2% pace. However, HP is paving the way for stronger earnings growth in this business unit in the next few years. Since the middle of FY13, HP has posted robust growth in printer unit sales, particularly for business customers. This will drive higher long-term sales of high-margin ink and toner.

Enterprise hardware starts moving again
HP's enterprise group, which sells hardware like servers, storage, and networking gear (and related support services), was the second part of HP to start showing signs of life. Through the first three quarters of FY13, enterprise group revenue was down 7.8% and pretax earnings had declined nearly 20%.

However, enterprise group revenue has grown modestly for the last two quarters, and the rate of earnings decline has quickly dropped into the single digits. Obviously, this is still not good. That said, HP's enterprise group is made up of a variety of distinct product lines. A few of these are in long-term decline, but others are growing rapidly. The growth product lines include Moonshot low-power servers and 3PAR storage systems.

The growth businesses are just starting to overtake the declining businesses in terms of importance. As this process plays out in the next year or two, revenue growth should strengthen and the enterprise group will return to earnings growth.

While HP's enterprise hardware business is not where it needs to be yet, competitors like IBM are struggling even more. IBM's overall revenue declined 5% last year, and hardware was the biggest drag on its results.

Recently, IBM has had far more trouble in the hardware business than HP.

In fact, IBM disclosed that its hardware segment profit declined $1.7 billion year over year in 2013. IBM lost money in its hardware business last year, and evidently didn't think all of its problems were fixable. In January, IBM sold off its low-end server business to Lenovo for the bargain price of $2.3 billion. By comparison to IBM, HP's enterprise hardware business outlook is rosy.

Looking ahead
As long as HP's printing and enterprise group business segments stay on track, HP investors should have nothing to worry about. However, for HP to return to robust earnings growth, it needs improvement in its troubled enterprise services segment. (The personal systems segment brings in a lot of revenue but is not very profitable and will -- at best -- stagnate in the long run.)

The services business has been overstaffed and was one of the main targets of HP's ongoing job cuts. It still has an imbalance of revenue compared to its staffing level, and as a result its pretax profit margin has plummeted to 4% in FY12, 3% in FY13 and just 1% last quarter, well below the long-term target of 7%-9%.

Nevertheless, HP executives reiterated on the most recent earnings call that they expect a 3.5%-4.5% operating margin for the enterprise services division in FY14. That implies that they expect rapid improvement in the next few quarters, presumably driven by HP's almost-completed cost-cutting program.

Management also appears confident that the long-term 7%-9% margin target is achievable. That could be worth more than $1 billion in incremental pretax profit, even with no revenue growth.

Foolish bottom line
HP has already brought its printing business back to profit growth. The recent return to revenue growth in its enterprise group is also promising. If HP's new enterprise hardware products stay on their current trajectory, the enterprise group will start contributing to earnings growth within the next year, even as problems linger at other competitors like IBM.

The one other thing HP needs to complete its turnaround is a revival in its enterprise services segment. This is a $20 billion business that has the potential to generate high single-digit margins, but it has been making virtually no contribution to HP's earnings recently. If HP starts making real progress in enterprise services, a $40 stock price will be well within reach.