The HK P30 is a perfect choice for both. I use it as both my primary concealed carry and primary home defense.
I have no issue with Glocks or M&Ps, as I own 2 M&Ps, but if you'd like to see what "perfect" ergonomics feel like, get your hands on a P30 and ask them to adjust the back and sides of the grip if necessary. I loved my M&P's ergos until I fired a P30 for the first time. Now, all of my other guns are sitting in the safe, unused. That's how much I think of the P30. Not to mention it's been torture tested to over 80,000 rounds with no serious issues.
You can't go wrong with a Glock or M&P either, however, just wanted to throw that option out there.