Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp624411pxf; Wed, 7 Apr 2021 07:53:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRBxAAEeHYw+j+Ex3KLjl+atFY9n3QsTIOVT6/O8e8WlodaqZR0Ma2HwwDyNVZ698uwvE/ X-Received: by 2002:a05:6402:882:: with SMTP id e2mr4902290edy.358.1617807192981; Wed, 07 Apr 2021 07:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617807192; cv=none; d=google.com; s=arc-20160816; b=z9athQRjvLo+vz70G4INgfY3/0Y0Gum/6Ir/lDSTYa46T0Koy8YPOE4AcwwYU/ybSW qruZhZgM2jAyoBYP7fy2fovjbsnl/yYJJKbYZ47RIIon2sS+CCS5LkK6MdPDygsO1juP eJIO63Ur2ipTwE19pbp9KfvkSvPW8oWNtBDJVcZfGjLBqjqCeKiYUhhazd5ro5I2+9w8 bdjd6YZuw7Zqf3kCsFKEATAV+f4LEvUhfvQ+PXDuP9JqQPEwaXE5BLAv2iFIjR1MRKyF cMACFOimK93BSjF3g487qQiVmTQZAY2JRcFFFz9cjH7XQBhA4wN+zM0cci+fwKvvHSp/ O3Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=6m79t4KqjSmyWU+kO5vFeIFmBj27k4tFAVtia74FpsQ=; b=tDhVZwV1QQ1NeVmB3b9+TV3OwOChosl7IYJqSTKrWsmfotuVxbYUdGUwvN0n5hIp0p bFHY0AfHTRUdjoKfVIVIJSOEvFsynwhMWEPYe5P3vGJ3CH2hoLkNDFI3xN4C4GtikkgR G4wZdsURMStRYdhviEZxk2Nw5C/H9H8a1rQK12nZBVPWgegYccDqbHeF/GvGmhxw4+DM NY1Insol+20pCvI1QK+YqgnJXITjUc35Y+YHGZu7smg7VAHdjLotIDZ6dgqnEfyCLr20 3SbvEqJiuaO4lqeNeTa9Cm2iHGnDZl+sAvMKRT26nNyuHBfmjhkYF4DcT/vCWMnXxRz4 /1Lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp16si20498781ejc.480.2021.04.07.07.52.49; Wed, 07 Apr 2021 07:53:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345510AbhDGGQd (ORCPT + 99 others); Wed, 7 Apr 2021 02:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239344AbhDGGQd (ORCPT ); Wed, 7 Apr 2021 02:16:33 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65637C061756 for ; Tue, 6 Apr 2021 23:16:24 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lU1UC-0005bW-LU; Wed, 07 Apr 2021 08:16:20 +0200 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lU1UC-0004OE-31; Wed, 07 Apr 2021 08:16:20 +0200 Date: Wed, 7 Apr 2021 08:16:19 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Clemens Gruber Cc: linux-pwm@vger.kernel.org, Thierry Reding , Sven Van Asbroeck , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 8/8] pwm: pca9685: Add error messages for failed regmap calls Message-ID: <20210407061619.fl6ffos6csvgtnjh@pengutronix.de> References: <20210406164140.81423-1-clemens.gruber@pqgruber.com> <20210406164140.81423-8-clemens.gruber@pqgruber.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vfnjmoawnycporzw" Content-Disposition: inline In-Reply-To: <20210406164140.81423-8-clemens.gruber@pqgruber.com> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --vfnjmoawnycporzw Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 06, 2021 at 06:41:40PM +0200, Clemens Gruber wrote: > Regmap operations can fail if the underlying subsystem is not working > properly (e.g. hogged I2C bus, etc.) > As this is useful information for the user, print an error message if it > happens. > Let probe fail if the first regmap_read or the first regmap_write fails. >=20 > Signed-off-by: Clemens Gruber > --- > Changes since v6: > - Rebased >=20 > drivers/pwm/pwm-pca9685.c | 83 ++++++++++++++++++++++++++++----------- > 1 file changed, 59 insertions(+), 24 deletions(-) >=20 > diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c > index cf0c98e4ef44..8a4993882b40 100644 > --- a/drivers/pwm/pwm-pca9685.c > +++ b/drivers/pwm/pwm-pca9685.c > @@ -107,6 +107,30 @@ static bool pca9685_prescaler_can_change(struct pca9= 685 *pca, int channel) > return test_bit(channel, pca->pwms_enabled); > } > =20 > +static int pca9685_read_reg(struct pca9685 *pca, unsigned int reg, unsig= ned int *val) > +{ > + struct device *dev =3D pca->chip.dev; > + int err; > + > + err =3D regmap_read(pca->regmap, reg, val); > + if (err !=3D 0) > + dev_err(dev, "regmap_read of register 0x%x failed: %d\n", reg, err); Please use %pe to emit the error code instead of %d. > + > + return err; > +} > + > +static int pca9685_write_reg(struct pca9685 *pca, unsigned int reg, unsi= gned int val) > +{ > + struct device *dev =3D pca->chip.dev; > + int err; > + > + err =3D regmap_write(pca->regmap, reg, val); > + if (err !=3D 0) > + dev_err(dev, "regmap_write to register 0x%x failed: %d\n", reg, err); > + > + return err; > +} > + > /* Helper function to set the duty cycle ratio to duty/4096 (e.g. duty= =3D2048 -> 50%) */ > static void pca9685_pwm_set_duty(struct pca9685 *pca, int channel, unsig= ned int duty) > { > @@ -115,12 +139,12 @@ static void pca9685_pwm_set_duty(struct pca9685 *pc= a, int channel, unsigned int > =20 > if (duty =3D=3D 0) { > /* Set the full OFF bit, which has the highest precedence */ > - regmap_write(pca->regmap, REG_OFF_H(channel), LED_FULL); > + pca9685_write_reg(pca, REG_OFF_H(channel), LED_FULL); You didn't check all return codes? How did you select the calls to check? Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --vfnjmoawnycporzw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmBtTjEACgkQwfwUeK3K 7AmlpAf/Ys9OlGLMDV++TA9VDwM/Ywp0P7HPN+Pw/FaEO5wvTM9HBvACUwWOpBV7 iX50S3rqBwBpi4oy0eOEmKVibWWKwIIbLdVqq9Emaccl742KZ2Gt4ItW4qdKHkw/ q8hPbEBYLB5ZdgdCOnsiOj75nWcwoOrCH1d8szRAONN7fuNeV20ESF7FcurS44Xz 2UD+MyEZWui9deKSNE6JhzEWLYJQwtyhba0/bqD0++rhp4spKVrTb7df3YRi6EFv bJvMAahRP8I2FItnzsCmyCbrFkkhWnJL062wuMC745ZrCXTzp/1bNd4wXN3P27Dt VuYwFFqn/MFPgpnXX07s7Jk1QPTwCQ== =Gk6O -----END PGP SIGNATURE----- --vfnjmoawnycporzw--