OSDN Git Service

staging: iio: ad5933: Protect DIRECT mode using claim/release helpers
authorNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Sun, 9 Apr 2017 10:40:07 +0000 (13:40 +0300)
committerJonathan Cameron <jic23@kernel.org>
Fri, 14 Apr 2017 14:09:06 +0000 (15:09 +0100)
commit984fb2443091d51e196662cdaddfe2823b2778ec
treea27fa15aa9850a522c2ae8a0272110ae74cca13f
parenta9e9c7153e96ee7f2777b3d5d99a23bf74dcaa21
staging: iio: ad5933: Protect DIRECT mode using claim/release helpers

This device operates in DIRECT_MODE and BUFFER_HARDWARE mode.
Replace usages of iio_dev->mlock with iio_device_{claim|release}_direct_mode()
helper functions to guarantee DIRECT mode and consequently protect
BUFFER mode too.

Add and use a device private lock to protect against conflicting access of the
state data.
This helps with IIO subsystem redefining iio_dev->mlock to be used by
the IIO core only for protecting device operating mode changes.
ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.

Protect changing of attributes inside ad5933_store(). Attributes
can no longer be changed while in buffered mode.

Remove lock from ad5933_work() because buffer mode should be enabled
when we reach this, and claiming DIRECT mode in all the other places
should protect it.

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/impedance-analyzer/ad5933.c