From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EBCBC28E83 for ; Fri, 4 Sep 2020 11:35:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 502FD206B7 for ; Fri, 4 Sep 2020 11:35:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EFpav4wU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730158AbgIDLdy (ORCPT ); Fri, 4 Sep 2020 07:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729297AbgIDLX7 (ORCPT ); Fri, 4 Sep 2020 07:23:59 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AF9CC061247 for ; Fri, 4 Sep 2020 04:12:35 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id mm21so3035670pjb.4 for ; Fri, 04 Sep 2020 04:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+wP+hTfHw3tFWF69FWuDIBtcVlOWelrnovHW8JL/Z34=; b=EFpav4wUW88JS+tQ/U0d9ZsC0A4R0fvGWc05kBkPJdEehiMUnpD6XarbOJkUr6Mbhi A8yngsVXQnUILWJX0qID9Ez4BEoyXPQX/5IxHzvhdbbbWe6/sg1+4jx6jkPW86zXhMuh XcQc/JDhaDnMO8UftkA7ImE5+2Iud+Q5wPJog6XHSKxMglZvDjhoSElUpl+RLXkElY6W abs/79kUVSlVY2YiYsa8qioTtpkulT0AHQcUbWd0O39mhAS+aclTbeATSBGiVenPDUNp +IDKyS9HSMSPrcT7leE7NhJZE/QXL0xYZ3z+fNjHIRjocTlwoDs/XXxFVDPFUIUEOH2x 1GBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+wP+hTfHw3tFWF69FWuDIBtcVlOWelrnovHW8JL/Z34=; b=jeXhHz62JOIauESnM3Gxelhxzz0GpatVeRi8k3xR/7tjGdUB7rHvC15OlgBPyxSkA4 J8+biGYFxY8CbeTpX5QoabtoHR+p6sbYfDWWdJBW7PbxbUJ80yXTmH8qz4kogqgofo8w FeIbz4/BuAZ4pXQTyW5yCfOfk3pSwzp6J1vXoHKiTFiJq+hJbI1SxoQe5WDNoYSb8X+x zY6uCdJmKEwe2ed5IwQEc69kvZ1FLZ0MHbEPeFeMmwh16nAhP0jn+7j2XAFIm6ptZeJ7 XvWMYX3KTIIUXN0Aeq++2Lj0V9G6F/MzRvUoOeamSpIdDrVZ486YpFcYcLuqYJfjkVDe V9Bg== X-Gm-Message-State: AOAM533J3u21bkWRLTjT6iUblAP9woX+wmRIsCG6dGluj1z89pErCKUI TU21pgQI/UCH9HbdV2r9VlD6 X-Google-Smtp-Source: ABdhPJxzQziJffgqrKM2Bdo+9xFsr0/Mrl5dmbLD/H9MMnY6rkl08uJ6vsvMXWeeQzFvVFEhyaeO1Q== X-Received: by 2002:a17:90b:693:: with SMTP id m19mr7452832pjz.111.1599217953011; Fri, 04 Sep 2020 04:12:33 -0700 (PDT) Received: from mani ([103.59.133.81]) by smtp.gmail.com with ESMTPSA id r144sm6874730pfc.63.2020.09.04.04.12.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Sep 2020 04:12:32 -0700 (PDT) Date: Fri, 4 Sep 2020 16:42:23 +0530 From: Manivannan Sadhasivam To: Dmitry Baryshkov Cc: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org Subject: Re: [PATCH v2 6/9] iio: adc: qcom-spmi-adc5: use of_device_get_match_data Message-ID: <20200904111223.GB4056@mani> References: <20200903132109.1914011-1-dmitry.baryshkov@linaro.org> <20200903132109.1914011-7-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903132109.1914011-7-dmitry.baryshkov@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On 0903, Dmitry Baryshkov wrote: > Use of_device_get_match_data() instead of hand-coding it manually. > > Signed-off-by: Dmitry Baryshkov > --- > drivers/iio/adc/qcom-spmi-adc5.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c > index c2da8f068b87..0ac0b81bab7d 100644 > --- a/drivers/iio/adc/qcom-spmi-adc5.c > +++ b/drivers/iio/adc/qcom-spmi-adc5.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -807,8 +808,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node) > struct adc5_channel_prop prop, *chan_props; > struct device_node *child; > unsigned int index = 0; > - const struct of_device_id *id; > - const struct adc5_data *data; > int ret; > > adc->nchannels = of_get_available_child_count(node); > @@ -827,24 +826,19 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node) > > chan_props = adc->chan_props; > iio_chan = adc->iio_chans; > - id = of_match_node(adc5_match_table, node); > - if (id) > - data = id->data; > - else > - data = &adc5_data_pmic; > - adc->data = data; > + adc->data = of_device_get_match_data(adc->dev); I think you're missing the else condition to fallback to default dev data incase the device is not part of of_device_id. Thanks, Mani > > for_each_available_child_of_node(node, child) { > - ret = adc5_get_dt_channel_data(adc, &prop, child, data); > + ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data); > if (ret) { > of_node_put(child); > return ret; > } > > prop.scale_fn_type = > - data->adc_chans[prop.channel].scale_fn_type; > + adc->data->adc_chans[prop.channel].scale_fn_type; > *chan_props = prop; > - adc_chan = &data->adc_chans[prop.channel]; > + adc_chan = &adc->data->adc_chans[prop.channel]; > > iio_chan->channel = prop.channel; > iio_chan->datasheet_name = prop.datasheet_name; > -- > 2.28.0 >