RE: [PATCH v2] regulator: ad5398: Fix min/max current limitboundary checking

From: Axel Lin
Date: Tue Jul 03 2012 - 07:36:27 EST



> >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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/