Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1693927lqp; Sat, 23 Mar 2024 05:17:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmHSI+c7SGNvqK3XH+GrfrUKHjav2v0ks+k4+zzaYJ5yQcoMeNQA8UyYeaJWf/tuEBlv5tM/p5XQ67B98T47CbQ5QnM/VaIDYNPzhvoA== X-Google-Smtp-Source: AGHT+IFF1v/ouZDwxou4RcAzVLclCWgAjtXoc5R1P7AT6fU091Sz6uC0V2HmSh6X5pPAvXrTQnLp X-Received: by 2002:a05:6214:2522:b0:696:57b1:1582 with SMTP id gg2-20020a056214252200b0069657b11582mr2350846qvb.5.1711196265099; Sat, 23 Mar 2024 05:17:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711196265; cv=pass; d=google.com; s=arc-20160816; b=TR2Lfg3Pu3d8Gh3kU3P2qNTG0pmV3ZOz3yiL93dv1Kqq+XPEEn0frlJh1c9imtI6Um TwjO3hFmRhFwWFldQrq0+ccesuhLO33Ew8hNUD/Zy3s/vm2+rr77mZiQnvpPjYd2ht99 923yb8sLGbjvpx2iULxFIvOMVtN7a0aqgJUrsnDPQSSIEyjCyjsw18x1Ev06xUWI7x6N tmiM0f/hCxk0cSiD1AfCB1RJGn2R+5oZDRlU/ym8UkuCYoBIZ2hDQBrxWZlZHsxWyqpE bLEKrD9XeZAZt6IhGD0gUZcWBIdbwhZsTBNOfV3tXVfD6q9EySgB85J56+woc0TRlXVt n8Cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=N9muYwrr5siQd/JSyRtkrxFkYsG9VIDfFrsB3T/A7s8=; fh=VC1KMVqWuXQbHmW1I+n/YBO8g/YaypsV3rh5CFL0Xwk=; b=mONr8V7cof++HhUej/EhOqtIBcbww37XeNzyNqvIArhkcmlO7rrSoLscbUe4Ik9hnJ i9SlibCVrOtoBhUPCaBA5y2mrOCRfyK5KZMYMSQVlmmuAvw4RzcTwZeyPvZ05306C16O 0O0mopAr+vtyKNuNIymixuD5mtbf2O3JjwhzIlgvLMwiY0u9wHMBQFNn7P0plo9WPxWq f5QU0vchra4W3dUfhaDJhZUvdDj3xYYqzxva+ATwRkQ232m9U7k3IaThRAT7O4jx4JAW Yo1BqGzNwDGI6GYRhnU/lFqtD4Vna0l9SCNHRrQVJFrSLO2JJZqiBOnpZ8JzV5Nh4sM/ t4pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aU9xrwqE; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112332-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gi9-20020a056214248900b0068fa310bfddsi3908556qvb.343.2024.03.23.05.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 05:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aU9xrwqE; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112332-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CB6991C21DEB for ; Sat, 23 Mar 2024 12:17:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB0111B957; Sat, 23 Mar 2024 12:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aU9xrwqE" Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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 90CE1C157; Sat, 23 Mar 2024 12:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711196255; cv=none; b=h0a6DBHIbtldYiOFAecRltDLilG1n24RVdIegbD72rskobwikqaH0ypPhDxoBIHTc3Xzi3np0Eew2rNk8FCM7lXHU8GRLOpAPwumZyK6eciaYh9Iha0DS0XnAUNSwLt5bn9KbMXnmIYRdeoUdzHHAUclZ7boS/3k+s26OFnQ5d0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711196255; c=relaxed/simple; bh=IPM7SrXbcPNHecQTdTFyVqK8ijt6QdlNkXGPW1J/fE4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ue0ILaGVmmzl1PSDI1e4FoIbl8JCQo+WQkF0qo6bo2TOorAZfhSSbRDp4eYbvYDt5q3cWjA7kGotflGdfYasMoyl5olVZbpi92QWXv/dIDWY79mBYbNiUtHPqIOMmjA4xuej7FrcFm+YgEM0tsYZ9Edx6quwxgImVxIYhRXiCdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aU9xrwqE; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-60a104601dcso34184057b3.2; Sat, 23 Mar 2024 05:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711196252; x=1711801052; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=N9muYwrr5siQd/JSyRtkrxFkYsG9VIDfFrsB3T/A7s8=; b=aU9xrwqEESepGKVHB2aNoxMziLBcyf12m6LQfwJ0igaG7EgH9HqLACjcFTS7gSYgkJ bBJW9TR8FIdAQ0ZwgBt/vSQObjqk9/piP8HhSy/GIo4IKL5VxAhRqMeALE2TBZTlDIpz d2PxqhaIllcdk6ruWz5K7k8fDKtRfw4v9K0YfGuKX9TO7JIrQ70FY/ux7lPJBbf3vHZh ZfsS1A4YuRzofL59/qa+k+erFyA2gqd8xg0m6i5Q0JCEiWLil0P3xsJKnLWuIQ9eR4dj D732yEOPqNAjE8tDCOUglOyDk8UHvJeCHsvXbA4o8wo0sFXeFzSjY+obR2pO6SGkt7Ln bjcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711196252; x=1711801052; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=N9muYwrr5siQd/JSyRtkrxFkYsG9VIDfFrsB3T/A7s8=; b=tYkWzK/U79H/DiAvYsVDw2Iq2pybZv4piHXTafinb4SKBr4YkRgHUxMtLWtt5VHLKM Rhtxw6e01Wq8rUKBm4TAzrqvWAj9erSiy8zmlu0l0J2GIljOzG9lT0Lop3JSGohmkcnf x2xKeweVBOwZjKAmCJI5kvh0IvxhS1ZGC1bfzrswgB8VwwANHkX8te2PiijrbdbRAv5s YNhBlRIHRPgJrt5pI3K0r2k6vM6pjYO1FlnY+UqgO1iuU5QDdR55AnReDYOLId2SOdke aFOBS1yIv09IDwuWBURwCEEQQAbTC4dgGAIxXJIIXei2CJzy43Q2KywOeRYOAz6cDsRJ P3Hw== X-Forwarded-Encrypted: i=1; AJvYcCWzHihc0JJrAZShgJSROmTCtn6lsfekB0SxBH0HoZuijY1VDiAQWHblSrfaJeL7hnS1jb7/mmBA7igEXsg6fLVv/fvAucuF34oo3gzcxvSIM6fbbuzo2x2DwRWJtKqqytN1dwOt8kvKgr/i9j4QTRA4JXt0m72U3cIUPeCY280e6lGmEA== X-Gm-Message-State: AOJu0YwEgYwqxPgKFXRf/bOCpC1ZWSfw6ljN64ClxRqEAV2WMKNioWY7 CTP6y+CtSkIArFrX863FwLwa6v7xkp4uZytqIFRaLrqgRvjAXeYfW1LDIYLlfN14h/7apOMnona EYqOd4N5yCTnOWdX5nmWqeeGXv5c= X-Received: by 2002:a25:1941:0:b0:dd0:2076:4706 with SMTP id 62-20020a251941000000b00dd020764706mr1328550ybz.31.1711196252566; Sat, 23 Mar 2024 05:17:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240322003713.6918-1-l.rubusch@gmail.com> <20240322003713.6918-2-l.rubusch@gmail.com> <51e3683f-be53-4bb7-a994-ffd05744a745@linaro.org> In-Reply-To: <51e3683f-be53-4bb7-a994-ffd05744a745@linaro.org> From: Lothar Rubusch Date: Sat, 23 Mar 2024 13:16:56 +0100 Message-ID: Subject: Re: [PATCH v2 1/3] iio: accel: adxl345: Update adxl345 To: Krzysztof Kozlowski Cc: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com Content-Type: text/plain; charset="UTF-8" (...) > > Signed-off-by: Lothar Rubusch > > --- > > drivers/iio/accel/adxl345.h | 44 +++++++++++- > > drivers/iio/accel/adxl345_core.c | 117 +++++++++++++++++-------------- > > drivers/iio/accel/adxl345_i2c.c | 30 ++++---- > > drivers/iio/accel/adxl345_spi.c | 28 ++++---- > > 4 files changed, 134 insertions(+), 85 deletions(-) > > > > diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h > > index 284bd387c..01493c999 100644 > > --- a/drivers/iio/accel/adxl345.h > > +++ b/drivers/iio/accel/adxl345.h > > @@ -8,6 +8,39 @@ > > #ifndef _ADXL345_H_ > > #define _ADXL345_H_ > > > > +#include > > + > > +/* ADXL345 register definitions */ > > +#define ADXL345_REG_DEVID 0x00 > > +#define ADXL345_REG_OFSX 0x1E > > +#define ADXL345_REG_OFSY 0x1F > > +#define ADXL345_REG_OFSZ 0x20 > > +#define ADXL345_REG_OFS_AXIS(index) (ADXL345_REG_OFSX + (index)) > > +#define ADXL345_REG_BW_RATE 0x2C > > +#define ADXL345_REG_POWER_CTL 0x2D > > +#define ADXL345_REG_DATA_FORMAT 0x31 > > +#define ADXL345_REG_DATAX0 0x32 > > +#define ADXL345_REG_DATAY0 0x34 > > +#define ADXL345_REG_DATAZ0 0x36 > > +#define ADXL345_REG_DATA_AXIS(index) \ > > + (ADXL345_REG_DATAX0 + (index) * sizeof(__le16)) > > + > > +#define ADXL345_BW_RATE GENMASK(3, 0) > > +#define ADXL345_BASE_RATE_NANO_HZ 97656250LL > > + > > +#define ADXL345_POWER_CTL_MEASURE BIT(3) > > +#define ADXL345_POWER_CTL_STANDBY 0x00 > > + > > +#define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ > > +#define ADXL345_DATA_FORMAT_SPI BIT(6) /* spi-3wire */ > > +#define ADXL345_DATA_FORMAT_2G 0 > > +#define ADXL345_DATA_FORMAT_4G 1 > > +#define ADXL345_DATA_FORMAT_8G 2 > > +#define ADXL345_DATA_FORMAT_16G 3 > > +#define ADXL345_DATA_FORMAT_MSK ~((u8) BIT(6)) /* ignore spi-3wire */ > > + > > +#define ADXL345_DEVID 0xE5 > > + (...) I think I see your point. My patch has more noise and lacks a logic structure in proceding. I will resubmit, but may I ask one question in particular. I moved the entire list of register defines from the adxl345_core.c to the common adxl345.h. For setting spi-3wire with my approach, only two of those defines are needed. I think it is nicer for readability to keep the defines together, though, in a commonly shared header. Nevertheless most of the defines are just used locally in the .._core.c Should I move them for refactory? I feel there is no reason to move them. On the other hand I see many drivers keep them in a common header. Hence, is there a best practice which justifies moving them to a header?