From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 18 14:26:41 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DB756BC3 for ; Tue, 18 Mar 2014 14:26:41 +0000 (UTC) Received: from mail-ie0-f177.google.com (mail-ie0-f177.google.com [209.85.223.177]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A3DC58BB for ; Tue, 18 Mar 2014 14:26:41 +0000 (UTC) Received: by mail-ie0-f177.google.com with SMTP id rl12so6824666iec.8 for ; Tue, 18 Mar 2014 07:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=VdaOyZCb9gAucD6vVBy8f5Veejxz/kviyH2SAy09Ts0=; b=SLI92PWEqMx90kQd/2JBz3tqGEOE2JKQa9cLmtjkA5xqw71/4aZV0+Rt80lch9NSML uGNwEN6QIpBLazGc9bZAWHCDLX4DX7pBviTAnKYORS1uBTk+HEyErl5+ifpw8wmzhbg+ 7QOsfHrxKE3NmMcZu2B22/RJ6XMCcZwOebAj8bw+rskUIHWBjywq+DZDdgV982bmVIst Q39mCkwXZ8zKuPh6JOJQ7GURTPR7kGf7xjrQnUcsmaAWi3o/0wok7N0MuPYM/7mS1SIk 5yRzPBFoeOwyia67X4AfOOTdEoFUDhVsf60hZHuPr+wmIsWK/3o0makTG8u4LcJkUFgS sjwA== X-Gm-Message-State: ALoCoQm5kJJwIzFXVmgMhdB7tbgDUcPiEMAO9YHBoQcicpMe6tOKhdzHaTLE/Vo1oGRftQE4bLUQ X-Received: by 10.42.62.143 with SMTP id y15mr24657440ich.14.1395152800982; Tue, 18 Mar 2014 07:26:40 -0700 (PDT) Received: from [172.29.91.92] (63-156-62-129.dia.static.qwest.net. [63.156.62.129]) by mx.google.com with ESMTPSA id r4sm26659469igh.1.2014.03.18.07.26.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 07:26:40 -0700 (PDT) Sender: Warner Losh Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: [RFC] lm75 kernel driver and bsnmp module From: Warner Losh In-Reply-To: Date: Tue, 18 Mar 2014 08:26:39 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <4B0E494C-A289-435C-89AA-29DEB1A4EAD9@gmail.com> References: To: Luiz Otavio O Souza X-Mailer: Apple Mail (2.1874) Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Mar 2014 14:26:41 -0000 On Mar 17, 2014, at 8:11 AM, Luiz Otavio O Souza = wrote: > +#ifdef FDT +static struct ofw_compat_data compat_data[] =3D { + { "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 =93national,lm75=94 bindings that are defined in the =93standard=94 FDT = spec. You can find it listed in the =91device-tree/Bindings/i2c/trivial-devices.txt=92= file in Linux, or in a similar location in the device-tree vendor tree in = FreeBSD. It isn=92t clear that both devices can=92t be handled with the same = driver, since the extra bits are supposed to be clear and so the extra if=92s here: + if (sc->sc_hwtype =3D=3D HWTYPE_LM75A) { + if (buf & LM75_0125C) + t +=3D 125; + if (buf & LM75_0250C) + t +=3D 250; + } + if (buf & LM75_0500C) + t +=3D 500; which just leaves device type reporting. The only reason I mention is is = that Linux doesn=92t seem to differentiate the two at the FDT level. + sc->sc_hwtype =3D ofw_bus_search_compatible(dev, = compat_data)->ocd_data; I don=92t think that the NULL binding is guaranteed to work that way, so I=92d 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