Re: [PATCH] DS2781 Maxim Stand-Alone Fuel Gauge battery and w1slave drivers

From: Evgeniy Polyakov
Date: Wed Feb 29 2012 - 18:25:01 EST


On Thu, Mar 01, 2012 at 12:17:30AM +0100, Renata Sayakhova (rsayakhova@xxxxxxxxx) wrote:
> w1_process (w1.c line 982) holds mutex. If during w1_search_process (w1.c
> line 983) slave is found and battery initcall is already done at this
> moment than battery probe() is called. This call leads to
> power_supply_register() and device_add() which does among other things call
> battery properties. battery_get_property() should normally results in
> w1_ds2781_read() and w1_ds2781_io(), but w1_ds2781_io() calls itself
> mutex_lock.
>
> So this weird function is a workaround to avoid a second mutex_lock during
> battery probe(). mutex_holder is set before power_supply_register() and
> unset when probe is done.
>
> This is very brief, if it's not clear I'll try to explain in more details.
> I found this workaround in implementation of ds2780 battery and w1 slave
> drivers.

So basically IO routins caled from ->probe() are already locked so we
protect against deadlock. Ok, I see.

I have no objections, patch looks good
Greg, please pull it into your tree
Thank you

Acked-by: Evgeniy Polyakov <zbr@xxxxxxxxxxx>


--
Evgeniy Polyakov
--
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/