Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1038889rwd; Sun, 14 May 2023 11:09:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7e5bAC0eMb71qKexZtTQhmaEtXbIF7GpO3rRiKfJbjr/n/gV0wgjqYKrgBNT5YRxW+F7Ui X-Received: by 2002:a05:6a00:1a56:b0:646:2e83:6b2e with SMTP id h22-20020a056a001a5600b006462e836b2emr29047612pfv.31.1684087764923; Sun, 14 May 2023 11:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684087764; cv=none; d=google.com; s=arc-20160816; b=WJ0u/1WvI2bhR87xegWE6h3NRxLk+6aqVxHkJyK6C+moECGcuIuvTgcSV3BI8gP9dk d2UMpbndJWgUltk44afD0N2PngtfopOPSlrbTFLPqvcWQc89Wvtn7DxTLeDk6AeFkvQJ p3kF1rdMLIqqMUaEBkbSYCR7h/QRJRUepefBAYHM6Jv8vqGMDuCjHmtOx+aqHlyMVuaS Yayj9chcUtomjyh+h9KYhvegVoHJtkKB2+oZljDT0EMBXCD5JUuxopaDCCJibaR/6+IN U4d3ocyTVqyKech56+V/F6zDqvx54DxGWgluK6WYxNAfEFWhEt+zNRL28UUEQqwRXDZ1 BsHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=o7Wb9Nzy7ixWGZ3HTplehZpFcvi01YLrUg+/j0a/lBI=; b=twG6c+KFWJWLTBKO2K4rC57FjzIKeBIcMZwpmrqnxojwPHNxSVktVbjXDT6PSKVmDk sR+E0k2pEWcKWkll7vku7o+PIa1IFCRbXhfT1H0l4F/qme/OszoQj49OBMxC+GqnIsa+ OoDqxjKtTpCRNl913723PS1ciApm3hk4sHzy0ACJU9IFOtya/MR6sdA83I7RaPtcXBom stZqGi96oEFtmsbGLAtE+Tdjmd+gNiuDUBV3ibPekO8FXuBpsnTej21wIYqfxzsrIWka QydPBioiLPZ+rSVfV8gs5AlEOtFOjKPMX8pRYixelPULaw75jF3vGUI+enUYGiEZyFR2 zn0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IloqxDI4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a63eb45000000b0052cc0b8d59dsi14241044pgk.798.2023.05.14.11.09.05; Sun, 14 May 2023 11:09:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IloqxDI4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233666AbjENRDS (ORCPT + 99 others); Sun, 14 May 2023 13:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232122AbjENRDO (ORCPT ); Sun, 14 May 2023 13:03:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3355F3C07; Sun, 14 May 2023 10:03:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9F89361880; Sun, 14 May 2023 17:03:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B4C6C4339C; Sun, 14 May 2023 17:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684083792; bh=dLiXJ8klvtan12DVAdAPECTlmGSDJesL1J33oOFSHoE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IloqxDI4jEVQJoTfBhtoqO27fRnpm0lstlfAx+kklSNKb3mqAquLfeTeANJVlI58v hlY6y3FHxvhKPk666U/n+se6+hpb4jLYC7UU7Hxo0fKWRVf6syO5plRPDEEFyqWIZu +4vP1K9MCbQ+dsDf14DnGvUqqG76gEx/TY2+Ppq9dlXBWAsxLMn4UgMEud4iAkSMlP +J84SGOVK5ouHq9lVr7UqAgXULGKcgTG/AtqacHbXRhlN6wd/zbL03c8gitBpMwOoe kUPGIEr4k2DZBpeJ/pefKd/Uzo4tpkh91ftBG9lYFbYii6UOqw1A3UQ1PTIIQlMQJN /970wI/w1eX0g== Date: Sun, 14 May 2023 18:19:12 +0100 From: Jonathan Cameron To: Herve Codina Cc: Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: Re: [PATCH v4 2/3] iio: potentiometer: Add support for the Renesas X9250 potentiometers Message-ID: <20230514181912.314ef781@jic23-huawei> In-Reply-To: <20230514163233.0c048256@bootlin.com> References: <20230509160852.158101-1-herve.codina@bootlin.com> <20230509160852.158101-3-herve.codina@bootlin.com> <20230513193525.43a4475f@jic23-huawei> <20230514163233.0c048256@bootlin.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 14 May 2023 16:32:33 +0200 Herve Codina wrote: > Hi Jonathan, >=20 > On Sat, 13 May 2023 19:35:25 +0100 > Jonathan Cameron wrote: >=20 > > On Tue, 9 May 2023 18:08:51 +0200 > > Herve Codina wrote: > > =20 > > > The Renesas X9250 integrates four digitally controlled potentiometers. > > > On each potentiometer, the X9250T has a 100 kOhms total resistance and > > > the X9250U has a 50 kOhms total resistance. > > >=20 > > > Signed-off-by: Herve Codina =20 > >=20 > > As I only noticed one trivial thing I made the change whilst applying. > > diff --git a/drivers/iio/potentiometer/x9250.c b/drivers/iio/potentiome= ter/x9250.c > > index 3d4ca18d1f14..7e145d7d14f1 100644 > > --- a/drivers/iio/potentiometer/x9250.c > > +++ b/drivers/iio/potentiometer/x9250.c > > @@ -176,10 +176,7 @@ static int x9250_probe(struct spi_device *spi) > > =20 > > x9250 =3D iio_priv(indio_dev); > > x9250->spi =3D spi; > > - x9250->cfg =3D device_get_match_data(&spi->dev); > > - if (!x9250->cfg) > > - x9250->cfg =3D &x9250_cfg[spi_get_device_id(spi)->drive= r_data]; > > - > > + x9250->cfg =3D spi_get_device_match_data(spi); > > x9250->wp_gpio =3D devm_gpiod_get_optional(&spi->dev, "wp", GPI= OD_OUT_LOW); > > if (IS_ERR(x9250->wp_gpio)) > > return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio), > > =20 >=20 > Are you sure about your modification ? >=20 > I am not sure (maybe I am wrong) that > x9250->cfg =3D spi_get_device_match_data(spi); > is equivalent to > x9250->cfg =3D &x9250_cfg[spi_get_device_id(spi)->driver_data]; >=20 > The spi_get_device_id(spi)->driver_data value I used is a simple integer > (X9250T or X9250U) and not the x9250_cfg item. > Maybe the x9250_id_table should be modified to replace X9250T by > &x9250_cfg[X9250T] to have your modification working. Excellent point. I'm was clearly half asleep. The mod should have included switching them over to be pointers. >=20 > The data defined in the driver are the following: > --- 8< --- > static const struct x9250_cfg x9250_cfg[] =3D { > [X9250T] =3D { .name =3D "x9250t", .kohms =3D 100, }, > [X9250U] =3D { .name =3D "x9250u", .kohms =3D 50, }, > }; >=20 > ... >=20 > static const struct of_device_id x9250_of_match[] =3D { > { .compatible =3D "renesas,x9250t", &x9250_cfg[X9250T]}, > { .compatible =3D "renesas,x9250u", &x9250_cfg[X9250U]}, > { } > }; > MODULE_DEVICE_TABLE(of, x9250_of_match); >=20 > static const struct spi_device_id x9250_id_table[] =3D { > { "x9250t", X9250T }, > { "x9250u", X9250U }, So these should be (kernel_ulong_t)&x9250_cfg[X9250T] etc for the data. I've tweaked it so that is now the case. Oops and thanks for sanity checkin= g. Sometimes we see what we expect to see rather than what is there. Tweak on top of original tweak is: diff --git a/drivers/iio/potentiometer/x9250.c b/drivers/iio/potentiometer/= x9250.c index 7e145d7d14f1..0cc7f72529be 100644 --- a/drivers/iio/potentiometer/x9250.c +++ b/drivers/iio/potentiometer/x9250.c @@ -198,8 +198,8 @@ static const struct of_device_id x9250_of_match[] =3D { MODULE_DEVICE_TABLE(of, x9250_of_match); =20 static const struct spi_device_id x9250_id_table[] =3D { - { "x9250t", X9250T }, - { "x9250u", X9250U }, + { "x9250t", (kernel_ulong_t)&x9250_cfg[X9250T] }, + { "x9250u", (kernel_ulong_t)&x9250_cfg[X9250U] }, { } }; Jonathan > { } > }; > MODULE_DEVICE_TABLE(spi, x9250_id_table); >=20 > static struct spi_driver x9250_spi_driver =3D { > .driver =3D { > .name =3D "x9250", > .of_match_table =3D x9250_of_match, > }, > .id_table =3D x9250_id_table, > .probe =3D x9250_probe, > }; > --- 8< --- >=20 >=20 > Best regards, > Herv=C3=A9 >=20