Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp322274lqs; Thu, 13 Jun 2024 10:59:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9cR+OX3ICQu4PovmpL2ZgwsDXVe8V+XjJCPB5F7d2B/LNU2ESUbg/pzsRdgPmrwElaDhzTbzWrZ9hJvSUesUAnfar0TvGh0MyGnCUbw== X-Google-Smtp-Source: AGHT+IHFKLJEu1w9YOGzWut3QLO4SJu59QR1lM3XR26vEh1oq633rtnYnrTSGJUionqJ0c2fVPi3 X-Received: by 2002:a50:aadd:0:b0:57c:740b:c87f with SMTP id 4fb4d7f45d1cf-57cbd651ca8mr413707a12.9.1718301573652; Thu, 13 Jun 2024 10:59:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718301573; cv=pass; d=google.com; s=arc-20160816; b=RczdHhE1G/XtqgeMkY/WgxZ6d7KUZIMn5nnZA3pXbJ591T7DZX0Rtz4jMjD6Kuwi4X o3rzfCsGMfhQCpQfDElIVNotxsNDpSzvZOdg+NaapLeDTWYYN9+BvDezUfmorbISUKLH EyR3/Ho0pesvugI/lTe9WXEsxc4EYDZGQWLPolwJVYUTAjikzIXaz1Yl3caO+HoLw7Ed YFgeWCkyLP41JjOqtu+csqyaACAW0l7et1ZaGxUzWzFTxSfYZhfAkYMKw9P2LWB3PwJd uyi1e5NO/QK1zn6Y4Q4YsZImBWH6+9KxJUeO0ve3JH0QTBGHWptXWB1i5F5WlA0WncHo 6pFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=8DxvYUGVHxRZE8NgyFyBxxrydXJ+gJq/RSG2sz2esD8=; fh=QME/cgvun1PS3OCBa/F0yk5RGoeWf+b+7IFPbGQqsU0=; b=o1zxPyQJ/skalxCjh4abfnGs+3kQ0628CWGH4Ss+VyIH4UQ7I7J8iGwj9dllNL8fcn knFXgeWF2Xd4UXyUv1sIQeQWZ/ko9qiepypjZ+0WQr00TvBXyN37vRf3FuRZQDmps24d QV0GulJqA6lRbailMi58tA99IP6h62totpu5JSr4JaPM/Mk/nz76QRUNwX3uxSUt13vE lX+Am2T7Dvpz8UV+XkkEl/O/SZyHMUyUBuls41miS7pW1EerqoMPYjIgSzH41Xb9mkMK E55orbu5eP3Ii2s7TkFwgzA2GbbXEy8adc8l58Ir0dPaOcyKsc75j2ZHUosbkc1CGY4+ Ow+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MWGtiwtB; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-213787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213787-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb7447ae5si974085a12.473.2024.06.13.10.59.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 10:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MWGtiwtB; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-213787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213787-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EF54E1F24569 for ; Thu, 13 Jun 2024 17:59:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D86014A4ED; Thu, 13 Jun 2024 17:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="MWGtiwtB" Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF17F14A4F0 for ; Thu, 13 Jun 2024 17:59:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718301564; cv=none; b=Y8Jd74kvRbwBBs3tM5CVtGsXXt46dxvBcnW5IV0Zci8m6yOfLpQXVy0xWrnfot/8S5lBTN/BkDmt0/9f4k5VzgDfXeNOXtwvx4FRtl3YkiWSfjkZi59jlPSvj9Lz4ODA1L+PZd1wMEFq1gDr7eXpnlgsYvms/0OM5dxp6c5m1cM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718301564; c=relaxed/simple; bh=MtUHYD2l4xxuwtdUTX926xYNHDRxYGGX0kXtv3HnGb8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=t2x/VMmySimzJB+LxgvSsGBf2eaYNo1dFtCohPE8OHzum3pgpvN0ngYTYUzTOKytmov5eGppqr7UHhAARqld/R3nnhuoWrQWSvtaM/W/pabGX+fGRcMe0X01bGbgUo8yeEsDetCWXzsQ/9I0kiyFtrG/39GIDWiQcHzsa5aX3bs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=MWGtiwtB; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7960454db4fso73406785a.2 for ; Thu, 13 Jun 2024 10:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718301561; x=1718906361; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=8DxvYUGVHxRZE8NgyFyBxxrydXJ+gJq/RSG2sz2esD8=; b=MWGtiwtBdurSak7iHInbxSCOdVMLkgIt4lhchazaQ0i7CU7at9pZ+oI1X2+tL4q+ZO eNniHYm/K9VSFerKCkSvPbEFl7ViYaIqq8lk0fpP5QyI6IBaBPvyIpcKOzjGMxpUjlCB BZazGGk35D12gW7QV5rxccO9v0pkO9NCFGDyO8Mekl446KMrBeZ+1CftoOfPr1EATfj9 l7BFHeja2dkVrbHLb9IjhZwXkip8KQc9i0uIlaKD7cr0VvC7GgEB1ZL9UG5MdeBs15v6 YqLJS1CGXkQYtuGSmYyHdpsFNwzUDe/RBsAafeL47ONyYrpI/EJoFAKm/gzAnas7djbO l8Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718301561; x=1718906361; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8DxvYUGVHxRZE8NgyFyBxxrydXJ+gJq/RSG2sz2esD8=; b=iSEV0P0mjDSSWixtkSa92Hl7PuyB/P+yqZZHpB/kqJZdJ4K4kbh3J7iB0BIbzrdWpu oNyzxE2/9N9JhwfohzEd0NkABTU1YMqD0KkL6Iqc41iA/GFoYFyfz2qNv7wnlJGKM+cU X6gIyzbwJyXe3jCmft2JEqcTfA4KE1bS/nO5rjiSwLVLcOe3EpMFCDoQvamGoErMkOYg EhA0rZ9E7bHMYt1qqCvoSulkrLXXJXa1bzW6OjxzMOnlG36H2PGYlWHatZ/2F99TGS6a o+9wMeITR89nwqkAl+q9S73hL5VET/JhI6XUrdfE0RAvOKRENXCCCEpgisgJE2dIztUp gY/g== X-Forwarded-Encrypted: i=1; AJvYcCVuHwP0MMBVg1vgYVDVg75mSIjMEiAXFfa2sb5lrFnjBEmQD9EKf9PNN6ZwHuTLjcuFKNWipLwujeAirKv7SQSOMXojAVUMHUcu6VT0 X-Gm-Message-State: AOJu0YxKv5gL1NLyPXTTaUDH9eNt4Kgw4nXBQshssx6ec9S6WvQNxUzv /qYZdk3q4Pn5FLeuI2FHf2+wOg+qAQZRy5FkKqI8bw6lBA0hnVtVo4JKYikeeek= X-Received: by 2002:a05:620a:44d1:b0:795:4d93:9e86 with SMTP id af79cd13be357-798d2411207mr28622885a.22.1718301560815; Thu, 13 Jun 2024 10:59:20 -0700 (PDT) Received: from [192.168.40.12] (d24-150-219-207.home.cgocable.net. [24.150.219.207]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798a9d8fb49sm73268185a.0.2024.06.13.10.59.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jun 2024 10:59:20 -0700 (PDT) Message-ID: <0003e57b-4c6a-470b-a0d8-20a13091d325@baylibre.com> Date: Thu, 13 Jun 2024 13:59:14 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND][PATCH] iio: simplify with regmap_set_bits(), regmap_clear_bits() To: Jonathan Cameron Cc: Lucas Stankus , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Dmitry Rokosov , Cosmin Tanislav , Chen-Yu Tsai , Hans de Goede , Ray Jui , Scott Branden , Broadcom internal kernel review list , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Saravanan Sekar , Orson Zhai , Baolin Wang , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , =?UTF-8?Q?Nuno_S=C3=A1?= , Linus Walleij , Jean-Baptiste Maneyrol , Crt Mori , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com References: <20240611165214.4091591-1-tgamblin@baylibre.com> <20240613182021.00005072@Huawei.com> Content-Language: en-US From: Trevor Gamblin In-Reply-To: <20240613182021.00005072@Huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-06-13 1:20 p.m., Jonathan Cameron wrote: > On Tue, 11 Jun 2024 12:52:06 -0400 > Trevor Gamblin wrote: > >> Simplify the way regmap is accessed in iio drivers. >> >> Instead of using regmap_update_bits() and passing the mask twice, use >> regmap_set_bits(). >> >> Instead of using regmap_update_bits() and passing val = 0, use >> regmap_clear_bits(). >> >> Suggested-by: Uwe Kleine-König >> Signed-off-by: Trevor Gamblin > Looks like a good change in general. However... > > The problem with a change like this is it results in > non trivial backporting if we need to due to a fix in related > code. > > As such, whilst it will obviously generate a lot of patches, I'd > like this split up into a series so each patch touches only one driver. > Fine to keep a single patch for the multiple module for a single > device cases though. > > Also some very long lines that need the line breaks put back. Thank you. I'll resubmit as a series of separate patches with those fixes soon. Trevor > > Jonathan > > >> diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c >> index b8ddbfd98f11..40e605c57adb 100644 >> --- a/drivers/iio/accel/msa311.c >> +++ b/drivers/iio/accel/msa311.c >> @@ -1034,10 +1034,8 @@ static int msa311_chip_init(struct msa311_priv *msa311) >> "failed to unmap map0/map1 interrupts\n"); >> >> /* Disable all axes by default */ >> - err = regmap_update_bits(msa311->regs, MSA311_ODR_REG, >> - MSA311_GENMASK(F_X_AXIS_DIS) | >> - MSA311_GENMASK(F_Y_AXIS_DIS) | >> - MSA311_GENMASK(F_Z_AXIS_DIS), 0); >> + err = regmap_clear_bits(msa311->regs, MSA311_ODR_REG, >> + MSA311_GENMASK(F_X_AXIS_DIS) | MSA311_GENMASK(F_Y_AXIS_DIS) | MSA311_GENMASK(F_Z_AXIS_DIS)); > Too long > >> diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c >> index b6c4ef70484e..8fabf748c36b 100644 >> --- a/drivers/iio/adc/cpcap-adc.c >> +++ b/drivers/iio/adc/cpcap-adc.c >> @@ -385,9 +385,8 @@ static irqreturn_t cpcap_adc_irq_thread(int irq, void *data) >> @@ -424,23 +423,17 @@ static void cpcap_adc_setup_calibrate(struct cpcap_adc *ddata, >> if (error) >> return; >> >> - error = regmap_update_bits(ddata->reg, CPCAP_REG_ADCC2, >> - CPCAP_BIT_ATOX_PS_FACTOR | >> - CPCAP_BIT_ADC_PS_FACTOR1 | >> - CPCAP_BIT_ADC_PS_FACTOR0, >> - 0); >> + error = regmap_clear_bits(ddata->reg, CPCAP_REG_ADCC2, >> + CPCAP_BIT_ATOX_PS_FACTOR | CPCAP_BIT_ADC_PS_FACTOR1 | CPCAP_BIT_ADC_PS_FACTOR0); > That one is over 100! >> if (error) >> diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c >> index a791ba3a693a..ff1c81553045 100644 >> --- a/drivers/iio/gyro/mpu3050-core.c >> +++ b/drivers/iio/gyro/mpu3050-core.c >> >> @@ -513,12 +513,8 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p) >> "FIFO overflow! Emptying and resetting FIFO\n"); >> fifo_overflow = true; >> /* Reset and enable the FIFO */ >> - ret = regmap_update_bits(mpu3050->map, >> - MPU3050_USR_CTRL, >> - MPU3050_USR_CTRL_FIFO_EN | >> - MPU3050_USR_CTRL_FIFO_RST, >> - MPU3050_USR_CTRL_FIFO_EN | >> - MPU3050_USR_CTRL_FIFO_RST); >> + ret = regmap_set_bits(mpu3050->map, MPU3050_USR_CTRL, >> + MPU3050_USR_CTRL_FIFO_EN | MPU3050_USR_CTRL_FIFO_RST); > Keep the line break to stay under 80 chars. > >> @@ -997,11 +991,8 @@ static int mpu3050_drdy_trigger_set_state(struct iio_trigger *trig, >> return ret; >> >> /* Reset and enable the FIFO */ >> - ret = regmap_update_bits(mpu3050->map, MPU3050_USR_CTRL, >> - MPU3050_USR_CTRL_FIFO_EN | >> - MPU3050_USR_CTRL_FIFO_RST, >> - MPU3050_USR_CTRL_FIFO_EN | >> - MPU3050_USR_CTRL_FIFO_RST); >> + ret = regmap_set_bits(mpu3050->map, MPU3050_USR_CTRL, >> + MPU3050_USR_CTRL_FIFO_EN | MPU3050_USR_CTRL_FIFO_RST); > For IIO stuff try and stay under 80 chars unless there is a strong > readability argument for going longer. Here there isn't one. > >> if (ret) >> return ret; >>