From: Bryan Freed Date: Tue, 21 Jun 2011 22:54:56 +0000 (-0700) Subject: iio: light sensor: Fix a panic in the tsl2563 driver. X-Git-Tag: MMI-PSA29.97-13-9~18845^2~433 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8f518d71f392b597832653f9438332ae27019da1;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git iio: light sensor: Fix a panic in the tsl2563 driver. Add a wrapper for this driver around the IIO_CHAN() wrapper to make channel parameters more readable. This fixes a panic caused by the info_masks being accidentally passed in as channel2 parameters which easily surpass the size of the iio_modifier_names_light array. Signed-off-by: Bryan Freed Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 9cffa2ecb0ee..c47341212382 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -548,15 +548,16 @@ error_ret: return ret; } +#define INFO_MASK (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) +#define EVENT_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \ + IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) +#define IIO_CHAN_2563(type, mod, proc, chan, imask, emask) \ + IIO_CHAN(type, mod, 1, proc, NULL, chan, 0, imask, 0, 0, {}, emask) + static const struct iio_chan_spec tsl2563_channels[] = { - IIO_CHAN(IIO_LIGHT, 0, 1, 1, NULL, 0, 0, 0, 0, 0, {}, 0), - IIO_CHAN(IIO_INTENSITY, 1, 1, 0, "both", 0, - (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE), 0, 0, 0, {}, - IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | - IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)), - IIO_CHAN(IIO_INTENSITY, 1, 1, 0, "ir", 1, - (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE), 0, 0, 0, {}, - 0) + IIO_CHAN_2563(IIO_LIGHT, 0, 1, 0, 0, 0), + IIO_CHAN_2563(IIO_INTENSITY, 1, 0, 0, INFO_MASK, EVENT_MASK), + IIO_CHAN_2563(IIO_INTENSITY, 1, 0, 1, INFO_MASK, 0), }; static int tsl2563_read_thresh(struct iio_dev *indio_dev,