Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp921472lqp; Thu, 21 Mar 2024 22:53:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOyQ0e0kgBm+jQcGnAGzESP3uMiSi36/vXKgYKnV+Vj9SxQQGx5/EOc5aFxQcNv2kmVu3924fW2vQNr7ImbZHYDSummRUFhpFZI7P+qg== X-Google-Smtp-Source: AGHT+IFUZ7J9zlzIb286rFIekggsFqH7d4YM8O7AqFSLJZzM8MbIBuWKcMOWsAAPt6ms2/ASH+LF X-Received: by 2002:a05:6a00:17a2:b0:6e7:2e76:5358 with SMTP id s34-20020a056a0017a200b006e72e765358mr1798480pfg.29.1711086833062; Thu, 21 Mar 2024 22:53:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711086833; cv=pass; d=google.com; s=arc-20160816; b=ZHxWrgmCTD2Qlqto7RcZuEV70SDPmjjxWXc7jmhekRCj3rXEDVKFC9D326w2z7vRZp NpMyl5xsUbQXTDdLGpgyWaZVFBvMhxHZln0W+CmnKQ1edqFusuG1y6HU/8lMI1Lr/r1S P85xEi7kbJDzUAo1EbAAG0RHXP+YV9r4P/tWLTEsHjQiKJSkHe5NNgqNYXxbhpSwyQfp 4z/FDlObCD/t0FtMnXrpxcV9H1hB6gRCSWGMXlo9cwsv3WWDwWkvQeV1WRXvWM6QbkUn nivUuaM71/JLEu0/sE7VyphZ/Ye2ijznuIIx6TdEOKga9i52MddsG8gEoYajTT6yBkzi j1qA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=lvjjIMgrLj2t99LvBKSf+/6gq3yKKlLGxdAZIjikVqg=; fh=qL7c4zcQExlJEkNx1Yr88GreIVRKpst+P2CrTstytlw=; b=GvWs2I1E6jDIcCcB0QDCoNTeyptGVDlvgr0UOfY2rBvaTvh6leeUXybsZGxXNyGkk+ JhQG8YmxRvH4VlYsfXXbS7HV1atLsIVQwsDfHpoNRDJ639dBhCU4btcqsUS79cwunm+b KX34Avtm2U/7DZ/pWSKCfbW4UXauY+nDBEeQ/w5onSnMAbsYTPhU2rpYz8Nxe7rVbrms KyuYJ81YcbGz5cvsK0mYUDH699xRHvSxX4MShZf2YELbQT+D7OiMx0dmfGw2Uaqs+ElE EE4ev8CizhQzFrfOqbDWu3KjBjMb6DrUPDUqNlGH+0vkQGYV3ByZWo9VXBMOnMkqmYIO DJkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AtvEoIyZ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-110972-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k13-20020a634b4d000000b005d8c18c7c65si1230477pgl.671.2024.03.21.22.53.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 22:53:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110972-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AtvEoIyZ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-110972-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B0CDC281EEE for ; Fri, 22 Mar 2024 05:53:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C23EAC133; Fri, 22 Mar 2024 05:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AtvEoIyZ" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 ED5E94436 for ; Fri, 22 Mar 2024 05:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711086824; cv=none; b=CrPFtLY5PE4VoBF5iujXns3GoF52s1Jeg0vLlN0aVcSZHZSnGu9Wjf8yAO4ZnlaGkBM/rhsw3t4vIgyLjHHZ9YYk1KhTME3czQn2Q6hwHjUdYywlw7GAFbJM7KxEQISYzRycxutCZ7ADVG8mXrCWEODTQR/0XQWwj99jUt6bBlc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711086824; c=relaxed/simple; bh=JV7W9Ku7IWOPbssxkeHzsvNBP5t7FxanPEnEHuoDtn4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kaQHtwhx2Pp5d3lhboWh+D/LIYCDALJ5ddXdvWDgjJF5tpjDg1qAzecrHc4XDifk0al8ePGEwYlTnWS2d/AWNXkfSmBzs07GHOnt6PQQyUpYpj8YTkWdfzXlZQC3FCqNoQ76n3UdvB07qlmiYlZyoKOY0y9QOB2zZCZxg4+TS44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=AtvEoIyZ; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a46dec5d00cso230816966b.0 for ; Thu, 21 Mar 2024 22:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711086821; x=1711691621; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=lvjjIMgrLj2t99LvBKSf+/6gq3yKKlLGxdAZIjikVqg=; b=AtvEoIyZ2nggQ1rjR0KfHS0j+VWnC6Ftq6OFhXlyqWkSIu/1T8nF5Th8Sv6Zz/MNeH PI0+s1yA0hpPafFbzSJOxiev+nOcpny5sVuHL+kdsIIGW6TawM00K84FoTDoKTgkKCF2 0m0YwUn5ujoScoKILO8Xfl+/jBtdY0sZD22jAzrHnfppZb+XrlDQzbYnUmawVh/vPrH0 ZfWMOWdEtChMwnnTjfAAFsFaBanSjriJzM/x0iY8bR/iHufbu65mgecqw6DKFB1iWpT5 iRSbFBDKTT8wy5puFcegGVU6DgDYKs9tDbxzSgWeNVby4eVudkC6+egegBzpb8XJlPIh jPxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711086821; x=1711691621; h=content-transfer-encoding:in-reply-to:autocrypt: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=lvjjIMgrLj2t99LvBKSf+/6gq3yKKlLGxdAZIjikVqg=; b=LUhcuJkdyC7tJXu3BUq+ekXwOA5Y05S39n2IKWEzDSIlfUDfjxo5kBt7ir94OwmVMi 2ZQg+dPI4sLCTyw8ZZo3IhLroLCbCC6gnjb9qcpRq3w3OM8w6j835RxxuQeVtSPr9Y5m U5xQIZBPiD3i+4fFAiK0ar+mGeI6keybnAeTCKSEdUvK6ZtgVZtZB5pzLaSBxFFYTzLV ZgMK9wRopRQdnJHKj7w1bdqpN9reGC1H6kjDO5fC7aiVK2u82ExAo+HPcOBgDmXdF3HD nNEC9nXzMkKgkTDz2YvaAgZe5fr//q1Qwnuek6oXtKMKbfifSOy8jS0LSBpI1D1Z8HCd S/pQ== X-Forwarded-Encrypted: i=1; AJvYcCXIbfpzReWByFBT9se5bdJSBh+xlnCpjrZqTLkf57SEhAB5OhdboQn/YJFDi5cnxMUEVh0UsadS+SuUiWZFePhbuUXhYD0Hu0o9StJ8 X-Gm-Message-State: AOJu0Yw8lybk6wOWDtZz4xDfPlSckQF9o/gRN1boXaxDS5u7hYOiMM2T 4M7hwoVV3s9ugb9fp9CGtyPSdqA70DBe5cckUwmP2cXpnneuussrwCr2ZLzXKtI= X-Received: by 2002:a17:906:e0d1:b0:a46:eaa6:ce88 with SMTP id gl17-20020a170906e0d100b00a46eaa6ce88mr832218ejb.55.1711086821264; Thu, 21 Mar 2024 22:53:41 -0700 (PDT) Received: from [192.168.1.20] ([178.197.222.97]) by smtp.gmail.com with ESMTPSA id jt19-20020a170906ca1300b00a46a9cdcfa5sm634053ejb.162.2024.03.21.22.53.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Mar 2024 22:53:40 -0700 (PDT) Message-ID: <51e3683f-be53-4bb7-a994-ffd05744a745@linaro.org> Date: Fri, 22 Mar 2024 06:53:38 +0100 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: [PATCH v2 1/3] iio: accel: adxl345: Update adxl345 To: Lothar Rubusch , lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com References: <20240322003713.6918-1-l.rubusch@gmail.com> <20240322003713.6918-2-l.rubusch@gmail.com> Content-Language: en-US From: Krzysztof Kozlowski Autocrypt: addr=krzysztof.kozlowski@linaro.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5GduRLhQU vK4tU7ojoem/G23PcowM1CwPurC8sAVsQb9KmwTGh7rVz3ks3w/zfGBy3+WmLg++C2Wct6nM Pd8/6CBVjEWqD06/R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Y qc+rJggwMQcJL9F+oDm3wX47nr6jIsEB5ZftdybIzpMZ5V9v45lUwmdnMrSzZVgC4jRGXzsU EViBQt2CopXtHtYfPAO5nAkIvKSNp3jmGxZw4aTc5xoAZBLo0OV+Ezo71pg3AYvq0a3/oGRG KQ06ztUMRrj8eVtpImjsWCd0bDWRaaR4vqhCHvAG9iWXZu4qh3ipie2Y0oSJygcZT7H3UZxq fyYKiqEmRuqsvv6dcbblD8ZLkz1EVZL6djImH5zc5x8qpVxlA0A0i23v5QvN00m6G9NFF0Le D2GYIS41Kv4Isx2dEFh+/Q== In-Reply-To: <20240322003713.6918-2-l.rubusch@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 22/03/2024 01:37, Lothar Rubusch wrote: > Move driver wide constants and fields into the header. Why? > Let probe call a separate setup function. Provide Why? > possibility for an SPI/I2C specific setup to be passed > as function pointer to core. Why? Your commit message *MUST* explain why you are doing things. > > 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 > + > /* > * In full-resolution mode, scale factor is maintained at ~4 mg/LSB > * in all g ranges. > @@ -23,11 +56,20 @@ > */ > #define ADXL375_USCALE 480000 > > +enum adxl345_device_type { > + ADXL345, > + ADXL375, > +}; > + > struct adxl345_chip_info { > const char *name; > int uscale; > }; > > -int adxl345_core_probe(struct device *dev, struct regmap *regmap); > +extern const struct adxl345_chip_info adxl3x5_chip_info[]; > + > +int adxl345_core_probe(struct device *dev, struct regmap *regmap, > + const struct adxl345_chip_info *chip_info, > + int (*setup)(struct device*, struct regmap*)); Last setup argument is entirely unused. Drop this change, it's not related to this patchset. Neither explained. Best regards, Krzysztof