Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1129676imi; Fri, 1 Jul 2022 03:50:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tj5aDC+/UIB9nD3IHxJZ6mgrB0SIRAm3nJ5bPZVtwzUSJoPYNcVvdE/TcmSLIeClILiOiX X-Received: by 2002:a17:907:75ca:b0:726:313b:8b0d with SMTP id jl10-20020a17090775ca00b00726313b8b0dmr13177606ejc.214.1656672622357; Fri, 01 Jul 2022 03:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656672622; cv=none; d=google.com; s=arc-20160816; b=x9AECOHiFUZF5uswwb731WPtlzrhMEXQ3MuX2yq2yy2i8usDxv0qHw2LNp1KJXMCtZ TEFFunE/jd788UD3o6H+xjTyAu7sOrz/letCN2r9KlI6gseI4owLn05Fmnzkdn0VEmJM xj7i1+qfYqXZCPUDTKmHJuquq7WWSycKpSmwL7ySg41M6av0r+8jV3CySAMLIv6+J0wz 0MggFmqxC2DZPRKj6KNWFCSOABkv28R9scwpLiymXO11WE+kt4PZO77ko/hUYbiKkjuY RY8vIXIgXwgNSQmiJ3bMdjiQcLM5t5xDb6sYVZAbSYEKMqh1A03QVbt8wWgTms53smTz XxYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/iB+M+0hVpqsRqriYarOMDGWv0AtTyLwSJV6suVTYyw=; b=gnrkGILQPWUt+yapwHLgybXifQmbIsbggKvJAh4VeukwVX8LGMVO+NplS56zLP/jZM wT+l2PNGpKFmZ2k/cjG65qsv9n8wgnnwqIwXf2DGIVlxEaN2HKxMoOD64o1bqcAhiI7e YKFaZjlYpXyPTjkmhlM5+r4mPzSqFVC3bEyX6KsYc/24DZz8vgidK63GPB1Zd5BFUao+ IlMa0JWdUlrZbSkWACBQ1Obedc+MbkrG1op9YcEnIQ9plTTvtd5kyKtRPaxrprEUg0Ka 5C/1O1dQfGFPO0CANTzXrwZl6vaq9A+PBG42gzTRtne1Y0+55Efm+FukJdaINI/lQwyI s79g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RUa6GRZL; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb14-20020a1709076d8e00b00726b8e79284si7990ejc.763.2022.07.01.03.49.57; Fri, 01 Jul 2022 03:50:22 -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=@gmail.com header.s=20210112 header.b=RUa6GRZL; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234852AbiGAKOD (ORCPT + 99 others); Fri, 1 Jul 2022 06:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233303AbiGAKOC (ORCPT ); Fri, 1 Jul 2022 06:14:02 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5F4D7435F; Fri, 1 Jul 2022 03:14:01 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id p136so3228615ybg.4; Fri, 01 Jul 2022 03:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/iB+M+0hVpqsRqriYarOMDGWv0AtTyLwSJV6suVTYyw=; b=RUa6GRZLbe8sy+nguH+vxiUKCkl84S9pTY/kCbQf79AXErS1GwfwhMZUET04xWxhxD 4as4KgeOrC0AsNDqOdWV3LaiwxKcd7lqvHITR/M1j6WBtayFDtLWUe9STIgYIdNodo5e bue0IoxVFvDY3MPfmZRp3/0Cu/TxjObMuMgii6fIM2CFkAe+Uc8lkbTQxb/XmzMROoYX y/995itSu7ofu+tWc9b9996nbs/Gsab5ApfZMxhBoQQrFCGmBMCx+INZ1myrZOTSoWsB hIqdYQjYi7wT2sprqAoKVt35pW+UwW75QRkQVnX/Mp0b/P6xV6Fp1Ap/TO9cLaiY3e2k kDTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/iB+M+0hVpqsRqriYarOMDGWv0AtTyLwSJV6suVTYyw=; b=YQCP9M8oo1W5MLRmOh4RHScjASFnITgcydA7KyRCvLZkG25jYCZNfBgDa9ddeDYMRc cUceytEkXJIjbmUoF6HeECRsYy9s9TP0bL8RwtwrY5K5FRW6zeKg/VRcj6o0EdRAmNPY sPtSIiuqkzwUgZzXedNw1CK1ph1OM0D51zj7aZ1w3Z0XUKPMZjMlW7FOZz/DkhGnmpk8 KLob4FWOpZ4J2EO9eT3u8hM9UbNyS8JldIhnrwaaxVOBPNJ7CQ8ELbCLxnIlcOKvvkht Xeh7hgqXRZBhzVHaeDgqqZZAtBgU+g0UP+BIOOExYJy3EY7dv3oUcgknZPMINg8Lkd5w F9CA== X-Gm-Message-State: AJIora+2f4ROMt2mBgIPYEIPUrcbGJEC0Hk8kgClYjSF12uzAP+D93nr mG7Ny7jwlsQCUSTFMImT7X/0+CZC9cYFwgYl7CY= X-Received: by 2002:a25:187:0:b0:66c:eaea:71ec with SMTP id 129-20020a250187000000b0066ceaea71ecmr14896072ybb.570.1656670440998; Fri, 01 Jul 2022 03:14:00 -0700 (PDT) MIME-Version: 1.0 References: <20220630230107.13438-1-nm@ti.com> In-Reply-To: <20220630230107.13438-1-nm@ti.com> From: Andy Shevchenko Date: Fri, 1 Jul 2022 12:13:24 +0200 Message-ID: Subject: Re: [PATCH] iio: adc: ti-adc128s052: Fix number of channels when device tree is used To: Nishanth Menon Cc: Javier Martinez Canillas , =?UTF-8?B?TnVubyBTw6E=?= , Christophe JAILLET , Alexandru Ardelean , Lars-Peter Clausen , Jonathan Cameron , Linux Kernel Mailing List , linux-iio , Stable Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Fri, Jul 1, 2022 at 1:02 AM Nishanth Menon wrote: > > When device_match_data is called - with device tree, of_match list is device_get_match_data() ? > looked up to find the data, which by default is 0. So, no matter which > kind of device compatible we use, we match with config 0 which implies > we enable 8 channels even on devices that do not have 8 channels. > > Solve it by providing the match data similar to what we do with the ACPI > lookup information. > > Fixes: 9e611c9e5a20 ("iio: adc128s052: Add OF match table") > Cc: # 5.0+ > Signed-off-by: Nishanth Menon ... > + { .compatible = "ti,adc128s052", .data = 0}, No assignment, 0 _is_ the default here. > + { .compatible = "ti,adc122s021", .data = 1}, > + { .compatible = "ti,adc122s051", .data = 1}, > + { .compatible = "ti,adc122s101", .data = 1}, > + { .compatible = "ti,adc124s021", .data = 2}, > + { .compatible = "ti,adc124s051", .data = 2}, > + { .compatible = "ti,adc124s101", .data = 2}, What you need _ideally_ is rather use pointers to data structure where each of that chip is defined, then it will be as simple as const struct my_custom_drvdata *data; data = device_get_match_data(dev); Where my_custom_drvdata::num_of_channels will be already assigned to whatever you want on a per chip basis. If the number of channels is the only data you have, then yes, cast it to void * in the OF ID table and num = (uintptr_t)device_get_match_data(dev); will suffice. -- With Best Regards, Andy Shevchenko