The NetBSD Project

CVS log for src/sys/dev/i2c/ds2482ow.c

[BACK] Up to [cvs.NetBSD.org] / src / sys / dev / i2c

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.2: download - view: text, markup, annotated - select for diffs
Wed Nov 6 15:49:36 2024 UTC (2 months, 2 weeks ago) by riastradh
Branches: MAIN
CVS tags: HEAD
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +282 -180 lines
ds2482ow(4): KNF

No functional change intended.

Non-whitespace changes:

1. Sort includes.

2. Say `if (sc->sc_is_800)', not `if (sc->sc_is_800 == true)'; no
   need to have multiple redundant verbs and boolean tests in this
   phrasing.

3. Use __nothing (a statement that has no effect), not empty token
   sequence, for macros that have no effect.  This avoids potential
   confusion in places that expect exactly one statement.  (If this
   change does have a functional effect, well, something must have
   been broken before!)

4. Omit needless `return;' at the end of void functions.
   (ds2482_attach still needs something after `out:', though, and
   `out: return;' is a little less obscure than `out:;'.)

Some of this nesting is a little excessive.  It would help legibility
and avoid excessive nesting depth to rephrase things like

	error = foo();
	if (!error)
		error = bar();
	if (!error) {
		error = baz();
		if (!error)
			error = quux();
		if (!error) {
			error = zot();
			if (!error) {
				error = mumble();
				if (!error) {
					error = frotz();
					if (!error) {
						*obuf = xbuf;
					}
				}
			}
		}
	}

as

	error = foo();
	if (error)
		goto out;		/* or break, in this case */
	error = bar();
	if (error)
		goto out;
	error = baz();
	if (error)
		goto out;
	error = quux();
	if (error)
		goto out;
	error = zot();
	if (error)
		goto out;
	error = mumble();
	if (error)
		goto out;
	error = frotz();
	if (error)
		goto out;
	*obuf = xbuf;

so that the indentation level doesn't grow indefinitely and the
expected-taken normal path remains unindented while the
expected-not-taken error branches get indentation.  (But that's a lot
more churn to the code, and more error-prone, than seemed appropriate
here.)

Revision 1.1: download - view: text, markup, annotated - select for diffs
Mon Nov 4 20:43:38 2024 UTC (2 months, 2 weeks ago) by brad
Branches: MAIN


Add a driver for the Maxim DS2482-100 and DS2482-800 I2C to 1-Wire
bridge.

This chip provides a I2C device that then has 1 or 8 1-Wire busses on
the other side.  The 1-Wire buses show up as onewire(4) buses in the
NetBSD.

The chip can be used in situations where:

* You have a I2C bus extended a long distance, say with a LTC4311
  active terminator / extender or one of the differential I2C
  extenders and you would like to have a 1-Wire device on the far end
  and it isn't possible to add wiring to get to the far end.

* You are either out of GPIO pins or the GPIO pins are not reliable
  enough to use gpioow(4), but you do have working I2C.

The DS2482 does all of the 1-Wire signals in hardware and provides for
a couple of pullup options for the 1-Wire devices.

All of the functions of the DS2482-100 and -800 are supported except
for overdrive speed support.  To do this will likely require some API
changes to onewire(4).

Breakout boards exist for the DS2482 for both variants, but they
appear to be more expensive than expected.  The chip itself is quiet
cheap and wasn't all that hard to SMD solder to a board.  No other
components are really needed.

There are other members in the same family, the DS2482-101, DS2484 and
DS2485.  The DS2482-101 has a sleep pin, but from the datasheet
appears to program the same as the -100 variant.  The DS2484 has a
slightly different way to set configuration information and probably
won't quite work with the driver, but isn't far off.  The DS2485 is
very different and would require a new driver to function.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>