Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2300507lqp; Sun, 24 Mar 2024 12:07:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdymPs2g0P4CSwn6+1rXlw/plsDwjG1TS3OD3bqaXnluuXcvlTrk9WaERbkvpXbYn24nIeYfgmzcoAjsnhtlkEy6kYnJKa+mOz9Jzitw== X-Google-Smtp-Source: AGHT+IHWx3VDd3++8bAcI72wrY3fgp9HjIQLkLbrX+Ukd9qjbbmo/4WwWSld3oeFjTGlg8P+k5I4 X-Received: by 2002:a92:c6c6:0:b0:368:6c2f:cedd with SMTP id v6-20020a92c6c6000000b003686c2fceddmr5108388ilm.27.1711307259710; Sun, 24 Mar 2024 12:07:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711307259; cv=pass; d=google.com; s=arc-20160816; b=xpHYCNHUEqKMOLALDDBHpT/FcpHuRo8twCAgThHt1gNRMiVzyn4M8XtWeEqkUToDG1 p6HsodhOvpiadok3iw0p4j79X7Sx6ll4IpB32oZGZq6O1pmwtXUcXKc+726YomCqdnU2 YmPhnmUf37XxbdU1TLvvZqNjVrYS/uH6TLMj+2FXkiRhceZijR/RL9auTFSnMI7JDGY3 VIydjf/5n1SAe956+r8+6Hc5OPL5qo2HZn9oCCNRDznl3Q+C0yqdxKwdMN/UxPtnphJd YEV2NfXcs1QBumvby1EVYDlR8m0f/2uNXtaukTSIoHLxOpm+RueLDB1tXRYpy5ri816b xRww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=pkEn4VNOIHeB/qPZaUAJWBjKMI7bAGuebMQs8wKwK+M=; fh=sHbVH6rqdwZwlD7UrUOcQbpCNlEpmKroV32cmbEiVq0=; b=YTe4Q9vZwl/CDV3WIxqG9LaKQTv+i9m97oNmtdcTPvVXNGFO1kihUUk7Hv/5ulb+iX MyOvI3i+4+JPVksDnmcx1JP4PfNROrnNtgYRxUVCin4/Fy5P/NsCz0PPLS7Tl6e0vgof YsISW6Tkq66nLq0z1qsFDP6keAVdOulxA4iGAkZr88drfRUa5pAvkNyPN1u/vY9cqBgR ZMr120WavD5dksmHEUaJOtlB007gAxx/r3x8fJbZq2dEwPDw1v/1/psIvYtSsH4KrVjh Qtaz/MwJOgqJ5ahi12PCTAYNeccuNIvc+jszyy66by7Xhws5lHqQZURzliy5YYTicfzP aypQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NXZeu3ou; 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-112817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112817-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g28-20020a63375c000000b005e840af67bbsi5769947pgn.755.2024.03.24.12.07.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 12:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112817-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=@gmail.com header.s=20230601 header.b=NXZeu3ou; 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-112817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112817-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 091FF281355 for ; Sun, 24 Mar 2024 19:07:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5003CDDA6; Sun, 24 Mar 2024 19:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NXZeu3ou" Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (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 EA3B4D2F0; Sun, 24 Mar 2024 19:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711307250; cv=none; b=f8XLz3aDe/HZFnFEnsYJ3cOanRPl3pAIDb40mPZi7rd1ImKIy0uusznU/y78EYsNS8ahpoN3KvkX9u1fmKCg93rziguVCLvjU5CPD0zoEqSy0QKwlabdnG+xkled8OjX/GOjvxJGJEwgI5DP4P2Vp7l7H3kKcnOTbWOkbiy0AJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711307250; c=relaxed/simple; bh=s6mc64AQ4pZX9KA5bgUlOT5O37aYYHT6vyIdf1+N8kU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VqUAc/Ku6wSOw1LFX817TDh8un0W3IwlUW4afSpMDXo7yd9s+Echc/kKMFcVyOQd0rAJAjYIiuI8+L7CD4R+zZ+t4B4hBKTrlz+79+aiePV4SbA8nABkbUIboE5yYhVs80WE0HnuMKxJhg+vuoC2vVfTYrdye7PvDVKkkNRSSyY= 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=NXZeu3ou; arc=none smtp.client-ip=209.85.219.171 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-yb1-f171.google.com with SMTP id 3f1490d57ef6-dcc80d6004bso3588165276.0; Sun, 24 Mar 2024 12:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711307248; x=1711912048; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pkEn4VNOIHeB/qPZaUAJWBjKMI7bAGuebMQs8wKwK+M=; b=NXZeu3ouHjIhlQt1SmM8stiROVb0+COKoygrwKh8KbBqfaL6qvjOh3cblNoA5y2Jzl 2tAzv0HSG5RjaBMPzNY30A0vuevR+1mIj+1J0GLbi28VTEQWsqnFPWb6qdUlFtqNCKU9 PYSP+sz0vQkLcMdANTFkAeJsKXFqc3l+jJ5DuISkPNIAk/U/CxFLp4+ppZ2hrLr2EqP4 A5CM1zeKadSglCugBRjqGknFHHw7mPPkQiAazNpOOm990ds1d85dHCR/18fDMCinNo0i kNSZIf99Cn8Gst3EJuJJRwRKqio+HTXXvLKkn6HnERqZvuOjU3mmNMlShUMN4SYpGuI3 ubpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711307248; x=1711912048; h=content-transfer-encoding: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=pkEn4VNOIHeB/qPZaUAJWBjKMI7bAGuebMQs8wKwK+M=; b=QQz13kwjcxCDnVXtlc5i0lgolIccxcTcoV5/JbP5VrvUrlp4mYJ1npo79+AEdTJJDh 5vimT3gm7OJLllUmB9l+9i98tWGWcEAUIhtOWVverugp52PYE+lOypsyc6PPQB3x/Iq3 yfZY+bTWASV60bpFKoayFckzuN041jHeCvTDBJ4g9/GtTfsqMWHEGN3m29uwNbEeyiG7 OJkPgDV4KFE7OLytUXuS3AP2T3gKg/ye9FCGu1kC9LpAFsqxuHfkBvQapdEUn3tlM0Lx mVZH5XQ81T1ycEAlfVRgK3re4z9kV/61un0BEbPKmeToEXfqC8P+0B8MnZkBBoZeH3sr ImHg== X-Forwarded-Encrypted: i=1; AJvYcCVPeZkAQ4vpUfi5nEd24dD7lBOI7rohO6QhoCV4ehYtmoplVBGE1WDfaEbzFud02rGJB9BBTvCH3tSOGWPueNsk5wRBs4AYbXWp3oZhNsfLefhojRZ49i7oJZKnhQ6h5z4Zege8OUlJ0Ke+xQNNfdp4yTn1xEvSUbHN01sLgVI+nBO+cw== X-Gm-Message-State: AOJu0Yzlmj5t0Iu0MZAKlwZ5BMgv0XikaelvtwkvRPzNxWpVuCnfZF/g EOiIFJRSdJAxNzPWjUaW76R4S0befGFGplkOfRyiYBkDVLBNHAWcUHCNfllzTa4VzeTaL0MUOtb 0bflDsFp1jyn390yX8Fqscyxf7hI= X-Received: by 2002:a25:870c:0:b0:dcf:56c3:336e with SMTP id a12-20020a25870c000000b00dcf56c3336emr3502881ybl.35.1711307247798; Sun, 24 Mar 2024 12:07:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240323122030.21800-1-l.rubusch@gmail.com> <20240323122030.21800-5-l.rubusch@gmail.com> <20240324133536.01067770@jic23-huawei> In-Reply-To: <20240324133536.01067770@jic23-huawei> From: Lothar Rubusch Date: Sun, 24 Mar 2024 20:06:51 +0100 Message-ID: Subject: Re: [PATCH v3 4/6] iio: accel: adxl345: Remove single info instances To: Jonathan Cameron Cc: lars@metafoo.de, Michael.Hennerich@analog.com, 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" Content-Transfer-Encoding: quoted-printable On Sun, Mar 24, 2024 at 2:35=E2=80=AFPM Jonathan Cameron = wrote: > > On Sat, 23 Mar 2024 12:20:28 +0000 > Lothar Rubusch wrote: > > > Add a common array adxl3x5_chip_info and an enum for > > indexing. This allows to remove local redundantly > > initialized code in the bus specific modules. > > > > Signed-off-by: Lothar Rubusch > > --- > > drivers/iio/accel/adxl345.h | 7 +++++++ > > drivers/iio/accel/adxl345_core.c | 12 ++++++++++++ > > drivers/iio/accel/adxl345_i2c.c | 20 +++++--------------- > > drivers/iio/accel/adxl345_spi.c | 20 +++++--------------- > > 4 files changed, 29 insertions(+), 30 deletions(-) > > > > diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h > > index 6b84a2cee..de6b1767d 100644 > > --- a/drivers/iio/accel/adxl345.h > > +++ b/drivers/iio/accel/adxl345.h > > @@ -26,11 +26,18 @@ > > */ > > #define ADXL375_USCALE 480000 > > > > +enum adxl345_device_type { > > + ADXL345, > > + ADXL375, > > +}; > > + > > struct adxl345_chip_info { > > const char *name; > > int uscale; > > }; > > > > +extern const struct adxl345_chip_info adxl3x5_chip_info[]; > > + > > int adxl345_core_probe(struct device *dev, struct regmap *regmap, > > int (*setup)(struct device*, struct regmap*)); > > > > diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl3= 45_core.c > > index 33424edca..e3718d0dd 100644 > > --- a/drivers/iio/accel/adxl345_core.c > > +++ b/drivers/iio/accel/adxl345_core.c > > @@ -62,6 +62,18 @@ struct adxl345_data { > > BIT(IIO_CHAN_INFO_SAMP_FREQ), \ > > } > > > > +const struct adxl345_chip_info adxl3x5_chip_info[] =3D { > > + [ADXL345] =3D { > > + .name =3D "adxl345", > > + .uscale =3D ADXL345_USCALE, > > + }, > > + [ADXL375] =3D { > > + .name =3D "adxl375", > > + .uscale =3D ADXL375_USCALE, > > + }, > > +}; > > +EXPORT_SYMBOL_NS_GPL(adxl3x5_chip_info, IIO_ADXL345); > > There is little advantage here form using an array. I'd just have > two exported structures. Then the name alone is enough in the > id tables. And probably no need for the enum definition. > > This use of arrays is an old pattern that makes little sense if the > IDs have no actual meaning and you aren't supporting lots of different > parts. For 2 parts I'd argue definitely not worth it. > Agree. I see your point. I drop the info array enum patch. (...) Btw. may I ask another question: The adxl345/75 driver is doing the configuration inside the probe(). Other Analog drivers moved that out into a xxx_setup() and call this function in the probe(). In general, is it better to keep all inside the probe() or separate? I mean, the probe is still quite short, and reading through severl call hierarchies feels a bit "sparghetti". On the other side I can see a certain idea of separation of functionality: dedicated chip configuration. Would you mind to give me a small statement/opinion on this please?