Re: [RFC V1] lib: cordic: add library module for cordic anglecalculation

From: Arend van Spriel
Date: Thu May 26 2011 - 05:31:14 EST


On 05/25/2011 10:35 PM, Larry Finger wrote:
On 05/25/2011 02:40 PM, Arend van Spriel wrote:
The brcm80211 driver in the staging tree has a cordic function to
determine cosine and sine for a given angle. Feedback received from
John Linville suggested that these kind of functions should be made
available to others as a library function in the kernel tree.
There is a similar routine in b43, thus this library function will likely have
at least 2 users.

I know (forgot to mention it in the commit message). Henry Ptasinski (broadcom colleague) actually verified both functions against Matlab implementation (or Scilab, if you prefer open-source ;-) ). The b43 version has a more limited range of the angle input in which the calculation is accurate.

+static const s32 AtanTbl[] = {
In Documentation/CodingStyle, variables with mixed-case names are frownid upon.

No frowning needed. I will change it ;-)


+/*
+ * cordic_calc_iq() - calculates the i/q coordinate for given angle
+ *
+ * theta: angle in degrees for which i/q coordinate is to be calculated
+ * coord: function output parameter holding the i/q coordinate
+ */
+void cordic_calc_iq(s32 theta, struct cordic_iq *coord)
As "coord" is only for output, why not have this be a function returning a
struct cordic_iq?

Only to avoid passing the structure over the stack. Given the fact that it is only 8 bytes (4 bytes extra) I think it is ok to change it.

Gr. AvS

--
Almost nobody dances sober, unless they happen to be insane.
-- H.P. Lovecraft --


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/