Re: [PATCH/RFC v10 08/19] leds: Add support for max77693 mfd flash cell

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi!

> >>+struct max77693_sub_led {
> >>+	/* related FLED output identifier */
> >
> >->flash LED, about 4x.
> >
> >>+/* split composite current @i into two @iout according to @imax weights */
> >>+static void __max77693_calc_iout(u32 iout[2], u32 i, u32 imax[2])
> >>+{
> >>+	u64 t = i;
> >>+
> >>+	t *= imax[1];
> >>+	do_div(t, imax[0] + imax[1]);
> >>+
> >>+	iout[1] = (u32)t / FLASH_IOUT_STEP * FLASH_IOUT_STEP;
> >>+	iout[0] = i - iout[1];
> >>+}
> >
> >Is 64-bit arithmetics neccessary here? Could we do the FLASH_IOUT_STEP
> >divisons before t *=, so that 64-bit division is not neccessary?
> 
> It is required. All these operations allow for splitting the composite
> current into both outputs according to weights given in the imax
>array.

I know.

What about this?

static void __max77693_calc_iout(u32 iout[2], u32 i, u32 imax[2])
{
	u32 t = i;

	t *= imax[1] / FLASH_IOUT_STEP;
	t = t / (imax[0] + imax[1]);
	t /= FLASH_IOUT_STEP

	iout[1] = (u32)t;
	iout[0] = i - iout[1];
}

Does it lack precision?

Thanks,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux