stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Lorenzo Bianconi <lorenzo.bianconi@st.com>,
	Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH 4.11 39/78] iio: imu: st_lsm6dsx: do not apply ODR configuration in write_raw handler
Date: Mon, 19 Jun 2017 23:15:39 +0800	[thread overview]
Message-ID: <20170619151030.880962491@linuxfoundation.org> (raw)
In-Reply-To: <20170619151029.408399976@linuxfoundation.org>

4.11-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

commit 2ccc15036d812e75f334c0fb813104ef765a2c77 upstream.

This patch allows to avoid a transitory that occurs when a given sensor
has been already enabled (e.g. gyroscope) and the user is configuring
the sample frequency of the other one (e.g. accelerometer).
The transitory lasts until the accelerometer is enabled.
During that time slice the gyroscope ODR is incorrectly modified as well.
At the end of the transitory both sensors work at the right frequency.
Fix it introducing st_lsm6dsx_check_odr() routine to check ODR consistency
in write_raw handler in order to apply frequency configuration just
in st_lsm6dsx_set_odr()

Fixes: 290a6ce11d93 (iio: imu: add support to lsm6dsx driver)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c |   41 +++++++++++++++++----------
 1 file changed, 26 insertions(+), 15 deletions(-)

--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -298,32 +298,40 @@ static int st_lsm6dsx_set_full_scale(str
 	return 0;
 }
 
-static int st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u16 odr)
+static int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr,
+				u8 *val)
 {
-	enum st_lsm6dsx_sensor_id id = sensor->id;
-	int i, err;
-	u8 val;
+	int i;
 
 	for (i = 0; i < ST_LSM6DSX_ODR_LIST_SIZE; i++)
-		if (st_lsm6dsx_odr_table[id].odr_avl[i].hz == odr)
+		if (st_lsm6dsx_odr_table[sensor->id].odr_avl[i].hz == odr)
 			break;
 
 	if (i == ST_LSM6DSX_ODR_LIST_SIZE)
 		return -EINVAL;
 
-	val = st_lsm6dsx_odr_table[id].odr_avl[i].val;
-	err = st_lsm6dsx_write_with_mask(sensor->hw,
-					 st_lsm6dsx_odr_table[id].reg.addr,
-					 st_lsm6dsx_odr_table[id].reg.mask,
-					 val);
-	if (err < 0)
-		return err;
-
+	*val = st_lsm6dsx_odr_table[sensor->id].odr_avl[i].val;
 	sensor->odr = odr;
 
 	return 0;
 }
 
+static int st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u16 odr)
+{
+	enum st_lsm6dsx_sensor_id id = sensor->id;
+	int err;
+	u8 val;
+
+	err = st_lsm6dsx_check_odr(sensor, odr, &val);
+	if (err < 0)
+		return err;
+
+	return st_lsm6dsx_write_with_mask(sensor->hw,
+					  st_lsm6dsx_odr_table[id].reg.addr,
+					  st_lsm6dsx_odr_table[id].reg.mask,
+					  val);
+}
+
 int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor)
 {
 	int err;
@@ -426,9 +434,12 @@ static int st_lsm6dsx_write_raw(struct i
 	case IIO_CHAN_INFO_SCALE:
 		err = st_lsm6dsx_set_full_scale(sensor, val2);
 		break;
-	case IIO_CHAN_INFO_SAMP_FREQ:
-		err = st_lsm6dsx_set_odr(sensor, val);
+	case IIO_CHAN_INFO_SAMP_FREQ: {
+		u8 data;
+
+		err = st_lsm6dsx_check_odr(sensor, val, &data);
 		break;
+	}
 	default:
 		err = -EINVAL;
 		break;

  parent reply	other threads:[~2017-06-19 15:19 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19 15:15 [PATCH 4.11 00/78] 4.11.7-stable review Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 01/78] fs: pass on flags in compat_writev Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 02/78] configfs: Fix race between create_link and configfs_rmdir Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 03/78] can: gs_usb: fix memory leak in gs_cmd_reset() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 04/78] ila_xlat: add missing hash secret initialization Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 06/78] [media] vb2: Fix an off by one error in vb2_plane_vaddr Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 07/78] [media] cec: race fix: dont return -ENONET in cec_receive() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 08/78] selinux: fix double free in selinux_parse_opts_str() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 09/78] mac80211: dont look at the PM bit of BAR frames Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 10/78] mac80211/wpa: use constant time memory comparison for MACs Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 11/78] drm: mxsfb_crtc: Reset the eLCDIF controller Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 12/78] drm/amdgpu: Fix overflow of watermark calcs at > 4k resolutions Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 13/78] drm/i915: Fix GVT-g PVINFO version compatibility check Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 15/78] drm/i915: Do not sync RCU during shrinking Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 16/78] mac80211: fix IBSS presp allocation size Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 17/78] mac80211: strictly check mesh address extension mode Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 18/78] mac80211: fix dropped counter in multiqueue RX Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 19/78] mac80211: dont send SMPS action frame in AP mode when not needed Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 20/78] drm/mediatek: fix mtk_hdmi_setup_vendor_specific_infoframe mistake Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 21/78] drm/vc4: Fix OOPSes from trying to cache a partially constructed BO Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 23/78] serial: 8250_lpss: Unconditionally set PCI master for Quark Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 24/78] serial: sh-sci: Fix (AUTO)RTS in sci_init_pins() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 25/78] serial: sh-sci: Fix late enablement of AUTORTS Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 26/78] x86/mm/32: Set the __vmalloc_start_set flag in initmem_init() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 27/78] mfd: omap-usb-tll: Fix inverted bit use for USB TLL mode Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 28/78] mfd: axp20x: Add support for dts property "xpowers,master-mode" Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 29/78] dt-bindings: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 30/78] mfd: cpcap: Fix interrupt to use level interrupt Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 31/78] mfd: cpcap: Use ack_invert interrupts Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 32/78] mfd: cpcap: Fix bad use of IRQ sense register Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 33/78] phy: rcar-gen3-usb2: fix implementation for runtime PM Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 34/78] mtd: physmap_of: really fix the physmap add-ons Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 35/78] powerpc/mm: Add physical address to Linux page table dump Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 36/78] staging: rtl8188eu: prevent an underflow in rtw_check_beacon_data() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 37/78] staging: bcm2835-camera: fix error handling in init Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 38/78] staging: iio: tsl2x7x_core: Fix standard deviation calculation Greg Kroah-Hartman
2017-06-19 15:15 ` Greg Kroah-Hartman [this message]
2017-06-19 15:15 ` [PATCH 4.11 40/78] iio: proximity: as3935: recalibrate RCO after resume Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 41/78] iio: adc: ti_am335x_adc: allocating too much in probe Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 42/78] ALSA: hda: Add Geminilake id to SKL_PLUS Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 43/78] ALSA: usb-audio: fix Amanero Combo384 quirk on big-endian hosts Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 44/78] usb: gadget: udc: renesas_usb3: fix pm_runtime functions calling Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 45/78] usb: gadget: udc: renesas_usb3: fix deadlock by spinlock Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 46/78] usb: gadget: udc: renesas_usb3: lock for PN_ registers access Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 47/78] USB: hub: fix SS max number of ports Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 48/78] usb: core: fix potential memory leak in error path during hcd creation Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 49/78] USB: usbip: fix nonconforming hub descriptor Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 50/78] usb: dwc3: gadget: Fix ISO transfer performance Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 51/78] [media] pvrusb2: reduce stack usage pvr2_eeprom_analyze() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 52/78] USB: gadget: dummy_hcd: fix hub-descriptor removable fields Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 53/78] usb: r8a66597-hcd: select a different endpoint on timeout Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 54/78] usb: r8a66597-hcd: decrease timeout Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 55/78] [media] coda: restore original firmware locations Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 56/78] drivers/misc/c2port/c2port-duramar2150.c: checking for NULL instead of IS_ERR() Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 57/78] usb: xhci: Fix USB 3.1 supported protocol parsing Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 58/78] usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk Greg Kroah-Hartman
2017-06-19 15:15 ` [PATCH 4.11 59/78] USB: gadget: fix GPF in gadgetfs Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 60/78] USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 61/78] mm/memory-failure.c: use compound_head() flags for huge pages Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 62/78] swap: cond_resched in swap_cgroup_prepare() Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 63/78] mm: numa: avoid waiting on freed migrated pages Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 64/78] userfaultfd: shmem: handle coredumping in handle_userfault() Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 65/78] iio: imu: inv_mpu6050: add accel lpf setting for chip >= MPU6500 Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 66/78] staging: iio: ad7152: Fix deadlock in ad7152_write_raw_samp_freq() Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 67/78] iio: adc: meson-saradc: fix potential crash in meson_sar_adc_clear_fifo Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 68/78] sched/core: Idle_task_exit() shouldnt use switch_mm_irqs_off() Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 69/78] genirq: Release resources in __setup_irq() error path Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 70/78] alarmtimer: Prevent overflow of relative timers Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 71/78] alarmtimer: Rate limit periodic intervals Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 72/78] virtio_balloon: disable VIOMMU support Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 73/78] MIPS: Fix bnezc/jialc return address calculation Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 74/78] MIPS: .its targets depend on vmlinux Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 75/78] crypto: Work around deallocated stack frame reference gcc bug on sparc Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 76/78] ARM: dts: am335x-sl50: Fix card detect pin for mmc1 Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 77/78] ARM: dts: am335x-sl50: Fix cannot claim requested pins for spi0 Greg Kroah-Hartman
2017-06-19 15:16 ` [PATCH 4.11 78/78] mm: larger stack guard gap, between vmas Greg Kroah-Hartman
2017-06-19 22:48 ` [PATCH 4.11 00/78] 4.11.7-stable review Guenter Roeck
2017-06-20  0:54   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170619151030.880962491@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.bianconi@st.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).