From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751724Ab2GCLgX (ORCPT ); Tue, 3 Jul 2012 07:36:23 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:40212 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156Ab2GCLgW (ORCPT ); Tue, 3 Jul 2012 07:36:22 -0400 Message-ID: <1341315373.3158.3.camel@phoenix> Subject: RE: [PATCH v2] regulator: ad5398: Fix min/max current limit boundary checking From: Axel Lin To: "Zhang, Sonic" Cc: Lars-Peter Clausen , Mark Brown , "linux-kernel@vger.kernel.org" , Liam Girdwood Date: Tue, 03 Jul 2012 19:36:13 +0800 In-Reply-To: References: <1341301353.12050.1.camel@phoenix> <4FF2A7F9.3090307@metafoo.de> <4FF2AC24.7090906@metafoo.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >The equation to calculate the selector does not depend on max_uA. > >So I think we don't need to set the requested max_uA. > > > > But, ad5398_set_current_limit() behaves different for min_uA and max_uA with you patch. Is this expected? > What we want is to set the smallest current supported by this hardware within the range you requested. Current code uses below equation to choose selector: selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip->current_level, range_uA); With this equation, we need to ensure min_uA >= chip->min_uA, otherwise it returns a negative selector. That is why we need to add: if (min_uA < chip->min_uA) min_uA = chip->min_uA; Axel