From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796295766; b=CgjSyn5An5l760ayr2MB9I2lHYpy3N5tpza2K4jfoaBdsbEE/tbD96yHU7PyDJjPJFnn MGw+XLGpFYPebREJAXrUUYevDuRpszSpYgDgaS6Fzdp5pETCr9N1fIOcPvKDYrLaomTFN GARkWWrrVQ56eXS65us1NWReBZjDGqiR3K/a+H0G5/mZTgCg5JXA5kLfamcn33aKOZEl6 yyYTdsLLabzCgyITeu0ixGWuvkJpl/hxXr/vNHMlqQnZ1OHqj5kNcVtNTPQWkf6//wgr2 bODte6wh+6AkoUoBSEymbtBdGj51sbLP3SgsUPH/A39vmY67bpqgAzGvz4leHMlZzaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796295766; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=F1Vqzl+eYWzLEyaJ/HR3vj4dLFzHFlJauKrLAm+GJ6o=; b=Z4gEcBYvSn3FVjNMHjvRSyd4r/GpiyZfeHorQZchqNaijdZQm/LWCDq1aC5Ojw8HOOh1 W/WRLjhD+oEZISTW+6kShjtA0QknVdP2aWcO08s/bAl8nupA4VgCo1eeAEbxEZMiJ12EW LIVOw3kgLtjGUS0462/0hQMXZUbwZgpKHnMEMST+fWee7E+PA8V7xjuHhbzRSL4u5YJ6u xZUd6Z/PFMwVjiqDOYwnu9ikMueuyUdfAbd+w4XQ71H3y0kajX5UIDckipp6vI8JfgFxq oTtBib8jOfQQRvKoCzMC7Ktd2cgc8lsGk3xC1vIJaz32haA9JKM0vpg/zpli765gNgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LdC2VMwz; arc=none smtp.remote-ip=198.175.65.11 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F562606A322; Thu, 3 Dec 2026 11:02:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0F562606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LdC2VMwz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796295767; x=1827831767; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=F1Vqzl+eYWzLEyaJ/HR3vj4dLFzHFlJauKrLAm+GJ6o=; b=LdC2VMwzCFLichFW/uGfOjxX81OrmdkejhtTltBgTD0pLZKyQtrwqdXs RYk5vAVLOlAKv2CeH6xAQyNRG/8F5qNPp+/n4YQLOIITwd66SXoUv6phv rx6+oefl6BJTxSaWLcW8CK9Grv+cZXr+QI6wSWLPJmj8O2gzLPqQAPloH qXamDEHTHZ6Sk3c/HTQShnXgATJnoe0H7p9qceANb7BM5B8HVi2ePZnWi 3psnzSo92VYtGD5fdeAOm604xuj08npNe6TFd65wAQw8JRL5n7qaaNSyo ZU9gXgRPQodV++vY4fIf5RoSgUwOyIWWnYp17h1/54VTAuwIk//vQCJsq w==; X-CSE-ConnectionGUID: vXT8qNLoQvSxT1ZOGOAYEw== X-CSE-MsgGUID: dt3ARy3kTdC99FVsXg+bTQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5150491" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5150491" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 03:02:46 -0800 X-CSE-ConnectionGUID: ZMx3OYHDQyyZcNHcc3TWEg== X-CSE-MsgGUID: b/9iBIIoRjqLa/YYfTOT0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="13919153" Received: from inaky-mobl1.amr.corp.intel.com (HELO localhost) ([10.245.244.115]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 03:02:41 -0800 Date: Thu, 3 Dec 2026 13:02:38 +0200 From: Andy Shevchenko To: Muchamad Coirul Anwar Cc: Jonathan Cameron , Miguel Ojeda , Igor Korotin , Danilo Krummrich , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , Andi Shyti , Daniel Almeida , Alice Ryhl , Mark Brown , Joshua Crofts , Markus Probst , Shuai Liu <847807867@qq.com>, linux-iio@vger.kernel.org, linux-i2c@vger.kernel.org, rust-for-linux@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v8 4/4] iio: position: add Rust driver for ams AS5600 Message-ID: References: <20261201165508.39336-1-muchamadcoirulanwar@gmail.com> <20261201165508.39336-5-muchamadcoirulanwar@gmail.com> X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201165508.39336-5-muchamadcoirulanwar@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Tue, Dec 01, 2026 at 11:55:08PM +0700, Muchamad Coirul Anwar wrote: > Add a Rust driver for the ams AS5600 12-bit magnetic rotary position > sensor. > > Expose the raw angle and scale through the IIO sysfs interface in direct > mode. Read the status register before each angle sample and return > ENODATA when the magnet-detected bit is clear. Serialize the status and > angle transaction sequence with a mutex and propagate I2C transport > errors directly to userspace. > > Capture a bound I2C client reference during probe and store it in the > IIO private data. The registered IIO device carries the same bound > lifetime, keeping the client valid throughout read_raw callbacks. > > The AS5600 stores the raw angle with the high byte at register 0x0c. > Use the byte-swapped SMBus word helper and mask the result to 12 bits. > > Add usize bit and mask helpers for constructing the IIO channel > information mask. > Suggested-by: Shuai Liu <847807867@qq.com> > Link: https://lore.kernel.org/all/tencent_173B7731E90B9624F9F82613DC3031B70907@qq.com/ > Link: https://lore.kernel.org/all/179286358623.55649.5397316745104390556@linux.dev/ Again, do not put unreferred Link tags. ... > + tristate "ams AS5600 magnetic rotary position sensor" Make this line to be the same or very similar to the top comment in the file. (or other way around) > +//! Driver for ams AS5600 12-bit magnetic rotary position sensor. > + description: "I2C Driver for ams OSRAM AS5600 Magnetic Rotary Position Sensor", Same for these. ... > + depends on IIO=y && I2C=y && RUST Huh?! ... > + help > + Support for the ams OSRAM AS5600 12-bit magnetic rotary > + position sensor. Provides in_angl_raw (0-4095) and > + in_angl_scale (radians per LSB) via sysfs. Unneeded details, what we need is something like top level parameters (12-bit, for example, that's already mentioned). Sysfs and related Linux kernel pieces are usually not being interested to the users here. > + To compile this driver as a module, choose M here: the > + module will be called as5600. ... > + // Scale factor: radians per LSB = 2*pi / 4096 ~= 0.001533981 > + IioChanInfo::Scale => Ok(IioVal::IntPlusNano(0, 1533981)), Please try to provide calculations based on the proper constants, use PI constant (for now open coded) with desired precision and shift it right by log2(2048). I believe you want 9-sign (yes, 9 in the fraction part) PI == 3141592654 (or ...53 if mentioned in the datasheet). -- With Best Regards, Andy Shevchenko