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 245E23B0ADA; Wed, 8 Apr 2026 18:26:07 +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=1775672768; cv=none; b=eKWJOqTagMSyQO34omJo6kGc+G0qSiIElGOaw2CSMZl7AkVPVd0KY7wxkC0oNr+JfIyUoNstDclo8Pl6AvvAJuZ6O9s/uxik9qfq9dLjt6/rhZ/IXHnE+/IQewugSm90/0h75baTQJzeg1FwZqKFC+NlBEt9w1W+IRN0qjlGYU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672768; c=relaxed/simple; bh=WLzjzXC3KGDSoWq1gIgccvs15PA0Em7VA2Lnk478hfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f08gN5g4oNi0d5R4TZwJuyHBrGqLY4LeCe42wRhLo3Z8tYr2/yJuNZBbD9f/6E11O66r4AFFCORt2rWRlWgW/Le7MyoII9R9k0prNc+PwMJReMRk6ynIUjCK4u18vq6PvUh1VeYhSGBozqubAWSG7uQV17lZzmPsx4ZyrM0+jyA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WTY1FU7q; 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="WTY1FU7q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6443DC19421; Wed, 8 Apr 2026 18:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672767; bh=WLzjzXC3KGDSoWq1gIgccvs15PA0Em7VA2Lnk478hfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WTY1FU7qC8vBtlUhpfRREDd8WzRImZe3Un+bgpeYHy0MP9PEcJ1khjniHvNcRMzZJ F0JhDb6k0/kLlcIWwfw1V0lrwhKL5lieVKyGEXVw/3GIb0rqznhPvP8XRzxBagqLDT GvVBVYHEAVVPoWcXHWoH/dT3l+rrwyqgEW3RMma8= 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.6 102/160] iio: gyro: mpu3050: Move iio_device_register() to correct location Date: Wed, 8 Apr 2026 20:03:09 +0200 Message-ID: <20260408175916.993669500@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175913.177092714@linuxfoundation.org> References: <20260408175913.177092714@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.6-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 @@ -1236,12 +1236,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 */ @@ -1264,9 +1258,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); @@ -1279,13 +1284,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); }