From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 12 20:38:00 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7AA40106566B for ; Mon, 12 Jul 2010 20:38:00 +0000 (UTC) (envelope-from andreast-list@fgznet.ch) Received: from smtp.fgznet.ch (mail.fgznet.ch [81.92.96.47]) by mx1.freebsd.org (Postfix) with ESMTP id 1A8848FC16 for ; Mon, 12 Jul 2010 20:37:59 +0000 (UTC) Received: from deuterium.andreas.nets (dhclient-91-190-8-131.flashcable.ch [91.190.8.131]) by smtp.fgznet.ch (8.13.8/8.13.8/Submit_SMTPAUTH) with ESMTP id o6CKH1Pc031523 for ; Mon, 12 Jul 2010 22:17:02 +0200 (CEST) (envelope-from andreast-list@fgznet.ch) Message-ID: <4C3B783D.5050200@fgznet.ch> Date: Mon, 12 Jul 2010 22:17:01 +0200 From: Andreas Tobler User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.4) Gecko/20100608 Lightning/1.0b2 Thunderbird/3.1 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.64 on 81.92.96.47 Subject: sysctl question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2010 20:38:00 -0000 Dear all, I have an issue here, I do read a temperature sensor and I got a value back, in integer. This value is 'encoded', it contains the integer and the fractional part of the temperature I read. This is inside a kernel module. I offer a sysctl interface to read this value. Currently the access is done with sysctl_handle_int. In my userland application I can print this value with the following macro: FIX32TOPRINT(f) ((f) >> 16),((((f) & 0xffff) * 1000) >> 16) But now I wonder how can I teach the sysctl to print my tempreature the same way as my userland app does. Right now it looks this way: dev.sm.1.sensor.cpu_b_ad7417_amb.temp: 2736128 If I feed this 2736128 into the macro above I get this: 41.750 this is what I expect. Is this even possible? TIA for any pointer. Andreas