From patchwork Mon Feb 7 14:38:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12737355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10573C4167E for ; Mon, 7 Feb 2022 14:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358842AbiBGO5L (ORCPT ); Mon, 7 Feb 2022 09:57:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240672AbiBGOiu (ORCPT ); Mon, 7 Feb 2022 09:38:50 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F20C0401C6 for ; Mon, 7 Feb 2022 06:38:48 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 06D3110000E; Mon, 7 Feb 2022 14:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1644244726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ry6myupu84aZtV75/bByECo3fbRZ0TuCh6kABlxb/PY=; b=bmiVsAz3MWX8KQ7mYH+touwwaRBKjFtuGOGj4jWPHUvwisXJLMJs3/GcDz6TmZ4pmfSPad GeNG3n+4QNpK7RLoAu2tuYXcK8nRd4vSpYvG8t+dPVJV+CI+T5zgolVhcvFRbpJWjl+cfp rStdnF+Fe8A4DbCGBYL9fb7tmBvbTQtAYvpTkfTfpDuQ8iR0Eq9UqfftE8x17dHwHM5kaX 7jTt51kPABsXb9lv+n1TsHDOcjwsEj09HaNW28elq7MLjEEq4BMcyIJ4FUrUnU0R+a4GKl BJ7WpGk5UmUKfG4KSragaJ167bX5xUGz1bDO085L+QxAVlVv3w1g/2TfmaEL7Q== From: Miquel Raynal To: linux-iio@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen Cc: Thomas Petazzoni , Alexandru Ardelean , Miquel Raynal , Denis Ciocca Subject: [PATCH v3 04/13] iio: st_sensors: Return as early as possible from the _write_raw() callbacks Date: Mon, 7 Feb 2022 15:38:31 +0100 Message-Id: <20220207143840.707510-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220207143840.707510-1-miquel.raynal@bootlin.com> References: <20220207143840.707510-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org As there is no cleanup to do, let's return as early as possible in the various ST sensor drivers _write_raw() callback functions. There is no functional change. Suggested-by: Jonathan Cameron Cc: Denis Ciocca Signed-off-by: Miquel Raynal --- drivers/iio/accel/st_accel_core.c | 5 +---- drivers/iio/gyro/st_gyro_core.c | 7 ++----- drivers/iio/magnetometer/st_magn_core.c | 7 ++----- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 31ea19d0ba71..ae0e6414e8f4 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -1133,8 +1133,7 @@ static int st_accel_write_raw(struct iio_dev *indio_dev, int gain; gain = val * 1000000 + val2; - err = st_sensors_set_fullscale_by_gain(indio_dev, gain); - break; + return st_sensors_set_fullscale_by_gain(indio_dev, gain); } case IIO_CHAN_INFO_SAMP_FREQ: if (val2) @@ -1146,8 +1145,6 @@ static int st_accel_write_raw(struct iio_dev *indio_dev, default: return -EINVAL; } - - return err; } static ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL(); diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index 201050b76fe5..f574ee7aca95 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -410,8 +410,7 @@ static int st_gyro_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SCALE: - err = st_sensors_set_fullscale_by_gain(indio_dev, val2); - break; + return st_sensors_set_fullscale_by_gain(indio_dev, val2); case IIO_CHAN_INFO_SAMP_FREQ: if (val2) return -EINVAL; @@ -420,10 +419,8 @@ static int st_gyro_write_raw(struct iio_dev *indio_dev, mutex_unlock(&indio_dev->mlock); return err; default: - err = -EINVAL; + return -EINVAL; } - - return err; } static ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL(); diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 0806a1e65ce4..34a0503bc571 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -544,8 +544,7 @@ static int st_magn_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SCALE: - err = st_sensors_set_fullscale_by_gain(indio_dev, val2); - break; + return st_sensors_set_fullscale_by_gain(indio_dev, val2); case IIO_CHAN_INFO_SAMP_FREQ: if (val2) return -EINVAL; @@ -554,10 +553,8 @@ static int st_magn_write_raw(struct iio_dev *indio_dev, mutex_unlock(&indio_dev->mlock); return err; default: - err = -EINVAL; + return -EINVAL; } - - return err; } static ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL();