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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 A9E29C433B4 for ; Tue, 20 Apr 2021 07:25:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79D6160238 for ; Tue, 20 Apr 2021 07:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbhDTHZe (ORCPT ); Tue, 20 Apr 2021 03:25:34 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:60289 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhDTHZd (ORCPT ); Tue, 20 Apr 2021 03:25:33 -0400 Received: from mail-ed1-f70.google.com ([209.85.208.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lYkkn-00071k-Ee for linux-omap@vger.kernel.org; Tue, 20 Apr 2021 07:25:01 +0000 Received: by mail-ed1-f70.google.com with SMTP id l22-20020a0564021256b0290384ebfba68cso8778515edw.2 for ; Tue, 20 Apr 2021 00:25:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QlkzODqs3de/2r7bFY21pvtdX8g0owN/7v3UKLodqFM=; b=kNTC4gpZIiRxY6slNiYeEA8g81PfYQlwkpJy+idlSLQC5dw88OzXhoQz/sM1Kq03Vl I9QAFmt8+2nQkZ9yLbPPxbD3xq7smCJhpM/1aqON8wZd/dB7UxJkkQGB17rbhVR7Krjb 2NHrXuV6q6idz6fKwLxzJTGdX3L74yMSNyDwt9gdNk8Ahcp9GOyrnfffeoZE07FREZ12 U8LirvvJShgucY0efuqimv+FckWUWdVbV/0RfYkgcVbTSdoI5jdFdRo2s08/Lr6OidHw rh+lrdMhF7ngpdwdzUBbOD4B6LWVnm5W7/rRXUBcczuLN/lInijsmnehZniih+5OHJHg Pjuw== X-Gm-Message-State: AOAM532szpudajkg897r7H/AGv7vpB3mTlTn7LokVo0yoJ3FtFADbJxy 4J+Rwn8bIL1rn2GSs0ZsYUCwSV+ni0G+8CxPF/JNJucv7UN+zpTGoBhg3gKSKVyoPkIdRE+Fq46 gOXq43bRoTi8Fj6IIvvD49GfQ9J5cEIYOXQ73Dcg= X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr30143967edb.329.1618903501149; Tue, 20 Apr 2021 00:25:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR0xQR3SxmpcZ02bhOq0nxAtZaxu1UiEvZpH8gjyloyiAJbhjG9+cavdaccyCaffHvyXDN5g== X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr30143954edb.329.1618903501005; Tue, 20 Apr 2021 00:25:01 -0700 (PDT) Received: from [192.168.1.115] (xdsl-188-155-180-75.adslplus.ch. [188.155.180.75]) by smtp.gmail.com with ESMTPSA id ca1sm15147826edb.76.2021.04.20.00.25.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Apr 2021 00:25:00 -0700 (PDT) Subject: Re: [PATCH 5/7] mfd: sec: Simplify getting of_device_id match data To: Marek Szyprowski , Support Opensource , Lee Jones , Bartlomiej Zolnierkiewicz , Tony Lindgren , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-omap@vger.kernel.org, patches@opensource.cirrus.com References: <20210419081726.67867-1-krzysztof.kozlowski@canonical.com> <20210419081726.67867-5-krzysztof.kozlowski@canonical.com> <64fb91ae-c754-fb25-0ef7-17b2f1b8a1e4@samsung.com> <4a5e80c0-653e-a4d6-630e-0d75e3779f6d@canonical.com> From: Krzysztof Kozlowski Message-ID: Date: Tue, 20 Apr 2021 09:25:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org On 20/04/2021 09:12, Marek Szyprowski wrote: > On 20.04.2021 09:03, Krzysztof Kozlowski wrote: >> On 20/04/2021 07:25, Marek Szyprowski wrote: >>> On 19.04.2021 10:17, Krzysztof Kozlowski wrote: >>>> Use of_device_get_match_data() to make the code slightly smaller. >>>> >>>> Signed-off-by: Krzysztof Kozlowski >>>> --- >>>> drivers/mfd/sec-core.c | 9 +++------ >>>> 1 file changed, 3 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c >>>> index 8d55992da19e..3126c39f3203 100644 >>>> --- a/drivers/mfd/sec-core.c >>>> +++ b/drivers/mfd/sec-core.c >>>> @@ -10,6 +10,7 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> #include >>>> #include >>>> #include >>>> @@ -324,12 +325,8 @@ static inline unsigned long sec_i2c_get_driver_data(struct i2c_client *i2c, >>>> const struct i2c_device_id *id) >>>> { >>>> #ifdef CONFIG_OF >>>> - if (i2c->dev.of_node) { >>>> - const struct of_device_id *match; >>>> - >>>> - match = of_match_node(sec_dt_match, i2c->dev.of_node); >>>> - return (unsigned long)match->data; >>>> - } >>>> + if (i2c->dev.of_node) >>>> + return (unsigned long)of_device_get_match_data(&i2c->dev); >>>> #endif >>> Does it make any sense to keep the #ifdef CONFIG_OF after this change? >> Good point, it was only to hide usage of of_device_id table. >> >>> I would also skip (i2c->dev.of_node) check, because >>> of_device_get_match_data() already does that (although indirectly). >> First, the enum sec_device_type would need to be changed so it starts >> from 1, not 0. It's because the value returned by this function is later >> assigned to that enum and there is no way currently to differentiate >> between NULL and S5M8767X. >> >> Second, it wouldn't make the code smaller; >> >> unsigned long data; >> data = of_device_get_match_data(&i2c->dev); >> if (data) >> return data; > > Then maybe one should go further and remove legacy, non-of based > initialization, because it is not used at all. This will simplify it > even more. Indeed maybe it's the time to get rid of board-file support... Thanks for the feedback! Best regards, Krzysztof