Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp224080lqb; Tue, 28 May 2024 13:41:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8+X9HLU1CDhUtYmPBrZxLTUqoWBSiTyn9J8glO5mzL6Fnc83+FvQG78iNW7rbUhpe9ftxREi40kfJ49nPj0UDzlzJQiTyBOn7zV6Ebw== X-Google-Smtp-Source: AGHT+IF2vj83tF2fQBt9tAi+ls77V25FfkCVdNU0RPZr9vJXIJn9hwfVN5FnYQ1x1fL6Mcarosx1 X-Received: by 2002:a05:6a20:de14:b0:1af:ab09:c555 with SMTP id adf61e73a8af0-1b212f34c55mr10605675637.47.1716928866107; Tue, 28 May 2024 13:41:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716928866; cv=pass; d=google.com; s=arc-20160816; b=dQuf+voxkxM7yNX2m8M9g12hQ8LsZDjILnvU3WwwP3+t8pjPy57DidKUr+gZR6Lof1 2fu34uoComj1VEV3B/Udox23ZE/AEx3hJpx+o0SHsOeMfSSd+G4dSApg4Syen3I9aXHl mXA82DvQ3BQXIDYIv3i5XrHtLUQgTlf0s2XY3ALSFyPYTLNJj1YvdWL0DTWSBzmMYqLG Y2yfKJ645GmWdHgcA+quhogOtiJwD/0KMP9sGQe+2iS8BNfCGKUKae8o1p0T0dK8LCcM /LdPFmtY5q55r3rV0MR2QBYIuWNKRnwlPNzAG2DS9D85WF+5QdZTKALpAAd9wuUnGImK zeJQ== 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=kcPlEqo+W0Jua24/gT7HCvEB6QVaVxRNhCMFCFv+UWg=; fh=L18ko88ztPO7ITuyimjmNHkH3CdDwjUCN5BiWTf+3DQ=; b=z0Qimu+Y2nm6GlKUjRM0FtnrVsP7+5WazOvVBFUNvSEHRNkOGmhh3LhMj/vzbYPDvn sSXufiNXOoNndB0ri8aFPWjfrkNqYlcVvwejLfQIu41DG9q4zluLubHoj6zhYeuTIqym 6ootdhXUkHLsWFxjIVatQwte3eIgp9rLQZelwoc3JThCoCIDCiAxK8aDNrDrbCnLLF5A gHCLKtMAuBRBvrnTyi0fb0DwvEPdCAXY4X+N72NxtdUElZU21GPmIgStl70CObmDwDIL wsZlMsmFhlxx6g4vZbQS664LNW8eT1V7txaIB2SZJqIS3KJ9+gDR2n6UVq6crSSQlSEz AlgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=U01JkwXn; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-193032-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193032-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-694f625cffdsi5761559a12.663.2024.05.28.13.41.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 13:41:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193032-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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=U01JkwXn; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-193032-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193032-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 7F68728FB41 for ; Tue, 28 May 2024 20:24:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2087517966F; Tue, 28 May 2024 20:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="U01JkwXn" 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 AF9CA13A89E; Tue, 28 May 2024 20:24:03 +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=1716927845; cv=none; b=X5YkU37gJWv+4u0PirmK+4ac5DQh0FvNL2MBDVSZt9Dd83r2z7/Qv1Fmj1vT2hNfQbi/MJpWKTmQGKsnWYt1YiMpumswhzaQW3P66tW1CyOMptxrcA6xUfwPKjNUYWHNqITcmSxdw3LB9Xtjvv5/s/a38ZWICCYsbklycofi3xw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716927845; c=relaxed/simple; bh=QEA3LdlsKTXB5zo/JeUVOYRKQ65PZUx0xbgATCF+K0U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fwbbF7Mh/23riy4NYTNM30DWbdyR/ZdhupQlH3msWpKObHJ8RoH7skNZ5YBCRY7ZhuWsNqbe3bCzLhlT7irjm/kM+0R6wOhSe3hMojAW0Gite9TEEj6r0va8webiMAqHB3ua4G8lZWmgsG6cEi7T7VyMWryZW5SS+Wk23UmZD2M= 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=U01JkwXn; 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 1EBB63A2; Tue, 28 May 2024 22:23:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1716927839; bh=QEA3LdlsKTXB5zo/JeUVOYRKQ65PZUx0xbgATCF+K0U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U01JkwXnk1dRTvYfhtVQzGrg9dtxI3GSal2GcjNgoQVvMhnIcGE63L/rFlgEu9TI9 1iWw257HR0g041lF4355jgn0wTtY3Yf+UaCLqn36RbVEefWK5xnEjz+CapBIwVkfbT ivdAc+nrtC+YvticzlVFd8ekJILRZNBMqWB+vzhQ= Date: Tue, 28 May 2024 23:23:50 +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: <20240528202350.GA17310@pendragon.ideasonboard.com> References: <20240528190315.3865-1-laurent.pinchart@ideasonboard.com> <20240528190315.3865-4-laurent.pinchart@ideasonboard.com> <20240528202044.GB8500@pendragon.ideasonboard.com> <20240528202216.GC8500@pendragon.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: <20240528202216.GC8500@pendragon.ideasonboard.com> On Tue, May 28, 2024 at 11:22:18PM +0300, Laurent Pinchart wrote: > On Tue, May 28, 2024 at 11:20:45PM +0300, Laurent Pinchart wrote: > > Hi Andy, > > > > Thank you for the patch. I meant for the review. It's getting late. > > 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? > > I forgot to answer this: > > I don't think it's a good match for the hardware. > > > > ... > > > > > > > +#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 > > -- > Regards, > > Laurent Pinchart -- Regards, Laurent Pinchart