Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp464925lqp; Mon, 10 Jun 2024 09:15:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUou3pSf3vbaBZT8H+WNLxQ7o8Edx0xBQwSybFB4DK5CLpUdceaifM2OYYsO3XNgSc80kRsG45clrTy7VEFYPR4E1WxR4Q1k1wGIBYW/w== X-Google-Smtp-Source: AGHT+IHPVrjKcVXont4CqwrLU4Kq2BlXXDxgs03kzbBkjrIZX2QrnK/bdm0d/pACmLeowF6xEEZZ X-Received: by 2002:a05:6a20:4307:b0:1b6:db6c:11ea with SMTP id adf61e73a8af0-1b6db6c1339mr3608455637.26.1718036106260; Mon, 10 Jun 2024 09:15:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718036106; cv=pass; d=google.com; s=arc-20160816; b=sns8Q+XUccNT+Gnxn0SWnEIWSZXFvgsbsfGXJHJdvF5k/XrFVwedr1SW1Qn7K+DZUk NS55cCixdRIxTYwXqDylh05fp9rRnzBWrieepgfDIJuyqkjBpX5GCjmcV7l7Gn4Vh6u1 YCTOvD41MZdJU+uIorb9cX2GyBR5H3vhFhP/Fmmd3UH72QvCvjDxMBTXL62byAkrFApP 1U+TAIYP2WVhGeyOyaFNJh8kUE2GqlCKRPhiVtopDEq8fCu4Y95BrP+FabX1xf4QzpN8 LIwF5822Gq8yvkiaR7LE1Bd0GNysKmPFn+oglbfHRJQ8AohAdGWCbigfIIMrr7TrRJpS U8YA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zAs4hsJX3PV5nJX7wEgbdoyArf9/hHZMvb4DwAkLNH0=; fh=+465D1LN26nuOg876XEWVEkeW1wvfEQWUSe57GNYMbE=; b=q949xhMbtWCxODJBi6WBe9sOXEu5yZs+H0lsgZHsiUtHJtxRsGXDbyUFpiaRLCPbNE GzlDFmDtn58RtbYJecgP5vVSMBIsLRam014Y/SJ2WTaUQItMZxKQg2mdJ+iyjnclRCkY PGNVHdjkp7BLtDUPrQgNRs5P5OcMsDB0/tWJ9vdHKYQeZ22lDVY0BZtB6496Ug5+t97Y EqfqLCS+m+/0td5C/vI4Df7H7JdJ5/J8w+IsuwnDNQr2hQLlrNPzqJX0l2NYk/ZGFxk0 VF3uZLOM95OpB4Y7IlU1K6Z33gzWZQXrZBWXFPhvNAubIOKJxirVPUBN2pH5ARl6C63q wF6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=okom6Ki0; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-208487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208487-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de275fbb06si4516006a12.504.2024.06.10.09.15.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=okom6Ki0; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-208487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208487-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E2760B2D6C5 for ; Mon, 10 Jun 2024 15:30:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BC4D142E8D; Mon, 10 Jun 2024 15:28:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="okom6Ki0" 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 2BC11142624; Mon, 10 Jun 2024 15:28:54 +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=1718033336; cv=none; b=i4bWdB9JZU4Q6L0IUnc1pMbuJzHBg6TBMZ1gjnHrm12xlniXx3/vJ3OZVvbZP0wHjzeBwlwVWI67Hm61rnL++RsQanA2m2Ry2kyYfdqwWui5AgaupWpUHDO7RHiBkERbNNJVulGM5ELLvrR+DEYCpikmCRSDEFVLSKfJgvBAJ40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718033336; c=relaxed/simple; bh=zRnGYwKBxb8rEXOmr0bMdweQrWUjhdVu2QR81He6TCQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a3FzQLkOMkwJmKsqs+qBRXQFFbik1cL6FB5qmqWVWx4P+14yw3z7clr/VnFx0Hhkd5IbP/MDl/6Nz6ZW+84N01rSA27clS5Vx76lG8B/3O4WXeYglR5NAhI923/08UvwhBXJoban/vfeDotfLhS4XQOejIoYrqom4yXFfflsvUc= 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=okom6Ki0; 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 241A539F; Mon, 10 Jun 2024 17:28:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718033321; bh=zRnGYwKBxb8rEXOmr0bMdweQrWUjhdVu2QR81He6TCQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=okom6Ki06UsNkQzHrakvp2IpuXLO6LDdjKvRpt6Jy5/5O6u+EFC5kx/sXmAV+Oj6K FLhHcFOK5DMRRzGKmFb2b3JaE/6ME9d+CHAD83O6I49KFNFhpKCR/Ri+m2uW4Db8si uzQKYD3fzLH09PyUIkqycEqoCr+pxo+ZHEqZ97jg= Date: Mon, 10 Jun 2024 18:28:33 +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?= , Clark Wang Subject: Re: [PATCH v4 4/4] pwm: adp5585: Add Analog Devices ADP5585 support Message-ID: <20240610152833.GW18479@pendragon.ideasonboard.com> References: <20240608141633.2562-1-laurent.pinchart@ideasonboard.com> <20240608141633.2562-5-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 Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jun 10, 2024 at 06:06:51PM +0300, Andy Shevchenko wrote: > Sat, Jun 08, 2024 at 05:16:33PM +0300, Laurent Pinchart kirjoitti: > > From: Clark Wang > > > > 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 PWM function using the platform device > > registered by the core MFD driver. > > > > The driver is derived from an initial implementation from NXP, available > > in commit 113113742208 ("MLK-25922-1 pwm: adp5585: add adp5585 PWM > > support") in their BSP kernel tree. It has been extensively rewritten. > > ... > > > +#define ADP5585_PWM_OSC_FREQ_HZ 1000000U > > (1 * HZ_PER_MHZ) ? > > Variant to use MEGA. Or even #define MHz in units.h if you wish. > Putting a few 0:s in a row is error prone. Feel free to send follow-up patches. Andy, we're reaching a level of nitpicking and yakshaving that even I can't deal with. I will have to simply ignore the comments I disagree with. > ... > > > + ret = regmap_write(regmap, ADP5585_PWM_OFFT_LOW, > > + off & 0xff); > > + if (ret) > > + return ret; > > + ret = regmap_write(regmap, ADP5585_PWM_OFFT_HIGH, > > + (off >> 8) & 0xff); > > + if (ret) > > + return ret; > > This is regular I²C regmap, why do you avoid using regmap bulk APIs? > > > + ret = regmap_write(regmap, ADP5585_PWM_ONT_LOW, > > + on & 0xff); > > + if (ret) > > + return ret; > > + ret = regmap_write(regmap, ADP5585_PWM_ONT_HIGH, > > + (on >> 8) & 0xff); > > + if (ret) > > + return ret; > > Ditto. > > ... > > > +static int pwm_adp5585_get_state(struct pwm_chip *chip, > > + struct pwm_device *pwm, > > + struct pwm_state *state) > > +{ > > + struct regmap *regmap = pwmchip_get_drvdata(chip); > > + unsigned int on, off; > > + unsigned int val; > > + > > + regmap_read(regmap, ADP5585_PWM_OFFT_LOW, &off); > > + regmap_read(regmap, ADP5585_PWM_OFFT_HIGH, &val); > > + off |= val << 8; > > Ditto. > > > + regmap_read(regmap, ADP5585_PWM_ONT_LOW, &on); > > + regmap_read(regmap, ADP5585_PWM_ONT_HIGH, &val); > > + on |= val << 8; > > Ditto. > > > + state->duty_cycle = on * (NSEC_PER_SEC / ADP5585_PWM_OSC_FREQ_HZ); > > + state->period = (on + off) * (NSEC_PER_SEC / ADP5585_PWM_OSC_FREQ_HZ); > > + > > + state->polarity = PWM_POLARITY_NORMAL; > > + > > + regmap_read(regmap, ADP5585_PWM_CFG, &val); > > + state->enabled = !!(val & ADP5585_PWM_EN); > > + > > + return 0; > > Besides that, how do you guarantee that no IO may happen in between of those > calls? Probably you want a driver explicit lock? In that case, would you still > want to have a regmap internal lock? > > > +} > > ... > > > +static int adp5585_pwm_probe(struct platform_device *pdev) > > +{ > > + struct device *dev = &pdev->dev; > > + struct adp5585_dev *adp5585 = dev_get_drvdata(dev->parent); > > + struct pwm_chip *chip; > > + int ret; > > + > > + chip = devm_pwmchip_alloc(dev, ADP5585_PWM_CHAN_NUM, 0); > > + if (IS_ERR(chip)) > > + return PTR_ERR(chip); > > > + device_set_of_node_from_dev(dev, dev->parent); > > Still unclear to me why only few drivers use this. > > > + pwmchip_set_drvdata(chip, adp5585->regmap); > > + chip->ops = &adp5585_pwm_ops; > > + > > + ret = devm_pwmchip_add(dev, chip); > > + if (ret) > > + return dev_err_probe(dev, ret, "failed to add PWM chip\n"); > > + > > + return 0; > > +} > > ... > > > +static const struct platform_device_id adp5585_pwm_id_table[] = { > > + { "adp5585-pwm" }, > > + { /* Sentinel */ }, > > Drop comma. Otherwise it's not a sentinel strictly speaking. > > > +}; -- Regards, Laurent Pinchart