[RFC] lm75 kernel driver and bsnmp module

Warner Losh imp at bsdimp.com
Tue Mar 18 14:26:41 UTC 2014


On Mar 17, 2014, at 8:11 AM, Luiz Otavio O Souza <lists.br at gmail.com> wrote:

> <lm75.diff>

+#ifdef FDT
+static struct ofw_compat_data compat_data[] = {
+	{ "freebsd,lm75",	HWTYPE_LM75 },
+	{ "freebsd,lm75a",	HWTYPE_LM75A },
+	{ NULL,			HWTYPE_NONE },
+};
+#endif

Is there a FDT standard here? It seems like they would fall under the
“national,lm75” bindings that are defined in the “standard” FDT spec. You
can find it listed in the ‘device-tree/Bindings/i2c/trivial-devices.txt’ file in
Linux, or in a similar location in the device-tree vendor tree in FreeBSD.

It isn’t clear that both devices can’t be handled with the same driver, since
the extra bits are supposed to be clear and so the extra if’s here:

+	if (sc->sc_hwtype == HWTYPE_LM75A) {
+		if (buf & LM75_0125C)
+			t += 125;
+		if (buf & LM75_0250C)
+			t += 250;
+	}
+	if (buf & LM75_0500C)
+		t += 500;

which just leaves device type reporting. The only reason I mention is is that
Linux doesn’t seem to differentiate the two at the FDT level.

+	sc->sc_hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data;

I don’t think that the NULL binding is guaranteed to work that way, so
I’d suggest dropping the NULL line above and testing explicitly for NULL
here instead.

Finally, is pausing for hz on read/write errors the right thing to do? Seems like a very
long time...

Warner



More information about the freebsd-hackers mailing list