From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F4AE2641FC; Wed, 8 Apr 2026 18:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775673963; cv=none; b=BRPM5xwcd9MXwzypSKNBpF3Cvc40fmyNHCpLxCP7znf1Waah6Qchx4F/PO4CnJgvapYYAssWqKms5npxXAAHnMEida5UzlvC23q1o5lnAqXiax8Z0h9Q4XgAkRj2vBUr89KMBXASIF82FQjIQoy+m9Q/lj2hFy9nzT0KTNk7mGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775673963; c=relaxed/simple; bh=l4dirZbB1J6mxyx80NF36EVZVcH/IjPjht/OqTclBGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O7slgXvc4/6O5481mThlPgFpvnbqv4O2Lqn5mZgxRPJwiZ+QTUDgUpQyUpYshzQxms/awqaauv/FEU/3OY3vLJ8fWJyNC2heKZuymU+IdxF9G6oUB8V8f6/3xLhbqiy4RHnL+zYuqYKP4nfZcjkKFAMUWMXer0O4jGzhpMnVjrs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OoEr4i70; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="OoEr4i70" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13465C19421; Wed, 8 Apr 2026 18:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775673963; bh=l4dirZbB1J6mxyx80NF36EVZVcH/IjPjht/OqTclBGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OoEr4i701lDmRTJxd+cXmbnwm2VnOcmoQ99hsO4InAxgxKfU+niuXzFryw13ghnNB SqEoFJgRF34lcnLhuzbW4c2btWQDcsLUUOYFtaebMsHkKj+aPcVxj10Ejz7yD3vTLi RXM05clPuj8XtamA/9/A2unQ2bM2J7TpAfaJNHEc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jonathan Cameron , Linus Walleij , Ethan Tidmore , Andy Shevchenko , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 6.12 157/242] iio: gyro: mpu3050: Move iio_device_register() to correct location Date: Wed, 8 Apr 2026 20:03:17 +0200 Message-ID: <20260408175932.966091757@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175927.064985309@linuxfoundation.org> References: <20260408175927.064985309@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ethan Tidmore commit 4c05799449108fb0e0a6bd30e65fffc71e60db4d upstream. iio_device_register() should be at the end of the probe function to prevent race conditions. Place iio_device_register() at the end of the probe function and place iio_device_unregister() accordingly. Fixes: 3904b28efb2c7 ("iio: gyro: Add driver for the MPU-3050 gyroscope") Suggested-by: Jonathan Cameron Reviewed-by: Linus Walleij Signed-off-by: Ethan Tidmore Reviewed-by: Andy Shevchenko Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/gyro/mpu3050-core.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) --- a/drivers/iio/gyro/mpu3050-core.c +++ b/drivers/iio/gyro/mpu3050-core.c @@ -1229,12 +1229,6 @@ int mpu3050_common_probe(struct device * goto err_power_down; } - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(dev, "device register failed\n"); - goto err_cleanup_buffer; - } - dev_set_drvdata(dev, indio_dev); /* Check if we have an assigned IRQ to use as trigger */ @@ -1257,9 +1251,20 @@ int mpu3050_common_probe(struct device * pm_runtime_use_autosuspend(dev); pm_runtime_put(dev); + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(dev, "device register failed\n"); + goto err_iio_device_register; + } + return 0; -err_cleanup_buffer: +err_iio_device_register: + pm_runtime_get_sync(dev); + pm_runtime_put_noidle(dev); + pm_runtime_disable(dev); + if (irq) + free_irq(mpu3050->irq, mpu3050->trig); iio_triggered_buffer_cleanup(indio_dev); err_power_down: mpu3050_power_down(mpu3050); @@ -1272,13 +1277,13 @@ void mpu3050_common_remove(struct device struct iio_dev *indio_dev = dev_get_drvdata(dev); struct mpu3050 *mpu3050 = iio_priv(indio_dev); + iio_device_unregister(indio_dev); pm_runtime_get_sync(dev); pm_runtime_put_noidle(dev); pm_runtime_disable(dev); iio_triggered_buffer_cleanup(indio_dev); if (mpu3050->irq) free_irq(mpu3050->irq, mpu3050->trig); - iio_device_unregister(indio_dev); mpu3050_power_down(mpu3050); }