You can select all visible pixels on a layer or deselect any selected pixels.
Choose Select > Deselect.
If you are using the Rectangle Marquee tool, the Elliptical Marquee tool, or the Lasso tool, click anywhere in the image outside the selected area.