Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp235974lqb; Tue, 28 May 2024 14:08:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRzkvYRB1o3hwKE7nH1KL2kLEDfWyvOC+HeZY+yywqqeB5wSQBUpKNQ5mOEnY2ScKVonK83DDMG7BcIZd4nU/K/MVaLHj3qul0r7nnLA== X-Google-Smtp-Source: AGHT+IG+gCX+JuseToph3tJjTurQozFuI/5OMf6WtCC84lMnqju+mCMT40r5tQxihY5lwKQv38a5 X-Received: by 2002:a62:8417:0:b0:701:e5f5:9f83 with SMTP id d2e1a72fcca58-701e5f5a387mr1908412b3a.3.1716930494825; Tue, 28 May 2024 14:08:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716930494; cv=pass; d=google.com; s=arc-20160816; b=Ek2GynEE+yHrFk1lUKChrpdaIE7yPQNEikr1DNRggwkQwip8I7xtmIxKvRX/V7bOLn 8KNn+JQDbTwGYfWJwzpGtWyhix20DqPDmQjGSE//AWdkZqmLdvu1jpCOwyGEoJBh1CMY LoQTi/VIX7WStEpi+NDhIfdsKPBHVIoGeSwrgCg6zDPKkr+wNQRTHDCIU5YHs9mxZzCe gua+J14t5d9+Yr9VbgtpVIS93ZNGL2wYwvGdc3MTBpvs1Nc9UZRO4La5LCNsfZL17G/G UAGovsEgElZG+W7/u9MrCUavaw9Ke28oz5WIa7YkTbIO+YYuUgnxbVGqk7zrwBtmZGhm jCvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DJcVjnT3Y+fa3GFrOB2JzbJ5P0OL0If51uzKi9rS3Z4=; fh=L18ko88ztPO7ITuyimjmNHkH3CdDwjUCN5BiWTf+3DQ=; b=wBw4pW79DjVOjGzcsKOnS0/4GXoUUTca03TWqB10VA7pkhjibIhzPO0EPFhtQ6omOw M3MZlM5ecUnjkdaYvhZkwtGwNkgTyHYiAiM5M/PMvJ/mX8MfdAbJqJsskiSKK6AXJ3DO 6GvcfUikqOtq92KfoAVoJQgCEmZkGoaaWml7yEx7lnroH7AgYqvTFHtIMaEcjzeey/KO iADR4MOAWsoFGi9d2QvpZhl3QNswdqf8cm46gWWXOfTtLh89EikMRyRG65nFQMzCLL3K xfVwjibSkx40BzJH2Pe+WwFT1BUQsfv5qBccbrxP7EGZsx2AsOMmvKrigsNo9htXHfyi e4eA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=qCPDioOo; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-193017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193017-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fc376648si8595603b3a.130.2024.05.28.14.08.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 14:08:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=qCPDioOo; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-193017-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193017-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 894102857EA for ; Tue, 28 May 2024 20:21:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE333178CFD; Tue, 28 May 2024 20:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qCPDioOo" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E1B63A1A8; Tue, 28 May 2024 20:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716927659; cv=none; b=SMwZTfWzPkQNNfVNYINmoDLuolFw42Mhs/nkZNCzLAH4K3LyJ/iXKf7wdFmgTkSkv3kHOoidwNbu1Pl91FNTwilU8V5w3DF9titJnqudVzj9aHTZ+XP3EwGM9NODJWwsIK+p77Vf2KvmLpwXJdnHI7rIWgas4Khf29PW74sCceU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716927659; c=relaxed/simple; bh=Cx19g39eIwMZcRAIH77mHZgMzukS6dMek4iKReia8hA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TYf1nmSgpW3B3M1ri8hsLisUL4ALpDD/3vA3S1SUaTBtyDBKWZtzJhRaay4yKVtJrw1dUeFuA6E5Novv/mGs+PcvEkVbMQHacsjIdQ4LyiVq2Lzj7haRqSuqKQNtlNOFNQIIuANaAZGV6TJ49Oivl5PwpPeehfWyGC1hihV2OPI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=qCPDioOo; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E4CE83A2; Tue, 28 May 2024 22:20:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1716927653; bh=Cx19g39eIwMZcRAIH77mHZgMzukS6dMek4iKReia8hA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qCPDioOoBLQSR7NJJyeAH/7ftfp/67Rlvsb1CHjM9Xlv8UKGv5M/kZqOOQyysRXUt +njglS/571LXM+UY4zee2bywQFqUTSYfSjzM6rR7ojOaSHe5KNeTeW/1kk5Mn82x6k MqDyCGhX19zSdSEZIAJ64l/Xlp/KRWiNR8hHc5+E= Date: Tue, 28 May 2024 23:20:44 +0300 From: Laurent Pinchart To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org, Bartosz Golaszewski , Conor Dooley , Krzysztof Kozlowski , Lee Jones , Linus Walleij , Rob Herring , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Haibo Chen Subject: Re: [PATCH v2 3/4] gpio: adp5585: Add Analog Devices ADP5585 support Message-ID: <20240528202044.GB8500@pendragon.ideasonboard.com> References: <20240528190315.3865-1-laurent.pinchart@ideasonboard.com> <20240528190315.3865-4-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Hi Andy, Thank you for the patch. On Tue, May 28, 2024 at 10:36:06PM +0300, Andy Shevchenko wrote: > Tue, May 28, 2024 at 10:03:13PM +0300, Laurent Pinchart kirjoitti: > > From: Haibo Chen > > > > The ADP5585 is a 10/11 input/output port expander with a built in keypad > > matrix decoder, programmable logic, reset generator, and PWM generator. > > This driver supports the GPIO function using the platform device > > registered by the core MFD driver. > > > > The driver is derived from an initial implementation from NXP, available > > in commit 451f61b46b76 ("MLK-25917-2 gpio: adp5585-gpio: add > > adp5585-gpio support") in their BSP kernel tree. It has been extensively > > rewritten. > > Why is this not using gpio-regmap? > > ... > > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + types.h > > ... > > > + bit = off * 2 + (off > 5 ? 4 : 0); > > Right, but can you use >= 6 here which immediately follows to the next > question, i.e. why not use bank in this conditional? The ADP5585_BANK() macro is meant to be used with ADP5585_BIT(), for a set of registers with the same layout. Here the layout is different, the registers contain multi-bit fields. I can't use ADP5585_BIT(), so I'd rather not use ADP5585_BANK() either. I have decided to use > 5 instead of >= 6 to match the R5 field name in the comment above: /* * The bias configuration fields are 2 bits wide and laid down in * consecutive registers ADP5585_RPULL_CONFIG_*, with a hole of 4 bits * after R5. */ > ... > > > + struct adp5585_dev *adp5585 = dev_get_drvdata(pdev->dev.parent); > > (see below) > > > + struct adp5585_gpio_dev *adp5585_gpio; > > + struct device *dev = &pdev->dev; > > struct adp5585_dev *adp5585 = dev_get_drvdata(dev->parent); I prefer keeping the current ordering, with long lines first, I think that's more readable. > > + struct gpio_chip *gc; > > + int ret; > > ... > > > + platform_set_drvdata(pdev, adp5585_gpio); > > Any use of driver data? In v1, not v2. I'll drop it. > ... > > > + device_set_of_node_from_dev(dev, dev->parent); > > Why not device_set_node()? Because device_set_of_node_from_dev() is meant for this exact use case, where the same node is used for multiple devices. It also puts any previous dev->of_node, ensuring proper refcounting when devices are unbound and rebound, without being deleted. -- Regards, Laurent Pinchart