A pinhole camera is a very simple theoretical device for generating perspective images on a plane that a distance $z_0$ from the pinhole (a point) and whose normal vector is the direction vector at which the camera is pointing. Using standard simple related frames, we can relate the world coordinate system with a local camera coordinate system attached to the camera.
If the world coordinates of a point are given by $P$ and the local coordinates of its image are $Q$ then
$P = P_0 + t R Q $
where $P_0$ are the world coordinates of the pinhole point, $R$ is the rotation matrix specifying the orientation of the axes of the local coordinate frame of the camera. Vector $Q$ has the form $Q = [x, y, z_0]$ where $z_0$ is the constant parameter specific to the camera specified above. To completely specify the camera, $z_0$ has to be known.
Suppose you have a camera with an unknown $z_0$, then the question is how to find it using a single image of a point with known coordinates, from a camera location $P_0$ that is known, and a known orientation $R$.
My Solution:
From the camera equation above, everything is known, except for the scalar $t$ and the third coordinate of $Q$ which is $z_0$.
From the equation we have
$ P - P_0 = t R Q $
The left side is a known vector. Applying $R^T $ to both sides
$R^T (P - P_0) = t Q = [ t x, t y , t z_0 ]^T$
Since the left hand side is known, then we can solve for $t$ from the first or second coordinate, and then from the third coordinate we can solve for $z_0$.
I guess you're asking whether your procedure is correct or not. If that is the case, then yes, your calibration procedure leads almost always to finding $z_0$, with a caveat: if the local coordinates $Q$ are in the form $Q = [0,0,z_0]$, then you cannot solve for $t$ alone, meaning that you would only be able to find the product $tz_0$. Unless you're allowed to change and/or choose the local coordinates $Q$, it's impossible to calibrate the camera in this case.