Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3736268ioo; Wed, 25 May 2022 07:11:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxueD0P1NIN4aipuwmT+xsmSdi9YubqBpJFJjGcwPpbicaWg9Yqq+89eJ0gvWq/ldp2/fwS X-Received: by 2002:a63:5d21:0:b0:3fa:387b:7b44 with SMTP id r33-20020a635d21000000b003fa387b7b44mr14775074pgb.48.1653487862791; Wed, 25 May 2022 07:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653487862; cv=none; d=google.com; s=arc-20160816; b=E5H+mPmz82nTV2AaWy0u20rqIBTH/Q1G6+iSrSHlJFedEXtP8CXGlZaBDsNpQ6RnV9 /QkDyA6ujbR/4yUzpb63YIgJWfFTe2bxPCKQQDSUfzpGMGzYFxZfWe6gM/G/Zl1X05dq 9jf4xCQzNjFms8EYl1JCtsiQFHCw7/SohhbtzUh2UDX9NZ0JAaBaS6Jn3dmoZj6/E0NQ w66aQXUqdAhCZBTvBrIAm79UiYFVUQhc8GYFA7INyDm7SKEqlx1yEZIBNj0mN+fZlA8S 4B8Pv6JYJ/YTgN37P0hwlN+AYoeaU1JqxLrNYeRhAndU7PZnQ/Z/mrHGi+m1YxBynUaz yKug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=2bodCbSR+Lke58kXxKWNOJUHCYJmuNt9Z6ipS+Ekcts=; b=OFW6Z5/XWBgm7CDjaXFl1mrZD8dT5Ic+E26z/UjOTYT1cu95UegqlTdU2wyJQBR+5c FKEbIk3BjWzyHrlCg3YhCvxD8yOMAYpPQJ7CFhdWlFQWEMdeN3UX5k8MtQfkdiEj1YOT BCMtILkjzmt4InU2HD8c6db8ajm2eOlUpX5hMm+xNpc/YMKP/rXFvXG3GnHPS4hisVgU SBBuKBFRbsRpNdHxQLK2F56aTi5OHcEAmnnGVs5yKeuT3u3sCm7Cl5bWbzVOixgein0n nmwJ7QBl7CxasgB7bNNsgCGr7ETfZc4L6FnqGmLYdMYbGT/lQ2lsGHfk4JYqsAlPDlLu p6Cg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 26-20020a630f5a000000b003fa387b9ac8si14992680pgp.513.2022.05.25.07.10.44; Wed, 25 May 2022 07:11:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244342AbiEYHfm (ORCPT + 99 others); Wed, 25 May 2022 03:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234157AbiEYHff (ORCPT ); Wed, 25 May 2022 03:35:35 -0400 Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EB3B454BDE for ; Wed, 25 May 2022 00:35:30 -0700 (PDT) X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from spf.mail.chinamobile.com (unknown[172.16.121.3]) by rmmx-syy-dmz-app05-12005 (RichMail) with SMTP id 2ee5628ddc3e068-037c0; Wed, 25 May 2022 15:35:27 +0800 (CST) X-RM-TRANSID: 2ee5628ddc3e068-037c0 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from [192.168.26.114] (unknown[10.42.68.12]) by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee2628ddc3e16d-c8e67; Wed, 25 May 2022 15:35:27 +0800 (CST) X-RM-TRANSID: 2ee2628ddc3e16d-c8e67 Subject: Re: [PATCH] ASoC: stm32: sai: Use of_device_get_match_data()tosimplify code To: Olivier MOYSAN , Mark Brown Cc: arnaud.pouliquen@foss.st.com, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, alsa-devel@alsa-project.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220519124235.21100-1-tangbin@cmss.chinamobile.com> <69d5cef3-57c0-9bc7-a83b-a85ef1c4cf29@foss.st.com> <3fb8d7f8-4506-3b28-22cb-863bda1f21c8@cmss.chinamobile.com> From: tangbin Message-ID: Date: Wed, 25 May 2022 15:36:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,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 Hi Olivier: On 2022/5/24 22:30, Olivier MOYSAN wrote: > Hi Tang, > > On 5/24/22 03:44, tangbin wrote: >> Hi Mark & Olivier: >> >> On 2022/5/24 2:57, Mark Brown wrote: >>> On Mon, May 23, 2022 at 03:28:48PM +0200, Olivier MOYSAN wrote: >>> >>>> The current patch requires a change in the driver. >>>> Either changing STM_SAI_x_ID enums, or replacing data by a struct. >>>> For instance: >>>> struct stm32_sai_comp_data { >>>>     unsigned int id; >>>> } >>>> struct stm32_sai_comp_data stm32_sai_comp_data_a = { >>>>     .id = STM_SAI_A_ID; >>>> } >>>> struct of_device_id stm32_sai_sub_ids[] = { >>>>     .data = &stm32_sai_comp_data_a}, >>>> } >>> Either approach works for me (or a revert for that matter). >> >>      Thanks for your advice, I was thoughtless. >> >>      I think change the date of STM_SAI_x_ID maybe simple. But if we >> don't change the id, >> >> what about add a "#define" like the line 47: >> >> #define STM_SAI_IS_SUB(x) ((x)->id == STM_SAI_A_ID || (x)->id == >> STM_SAI_B_ID) >> >> then in the judgement, wu use: >> >>      sai->id = (uintptr_t)of_device_get_match_data(&pdev->dev); >> >>      if (!STM_SAI_IS_SUB(sai)) >> >>              return -EINVAL; >> >> >> if you think that's ok, I will send patch v2 for you . >> > > If we allow null value in STM_SAI_IS_SUB(sai) check, we can miss real > NULL pointer error from of_device_get_match_data(). > > The simplest way is to change STM_SAI_x_ID enums I think. > But honnestly, I feel more comfortable to let the driver unchanged. > Oh,you are right, I am sorry. Please forget this patch, I'm sorry to have wasted your time. But I saw some codes is useless in the line 48 & line 49, I think we can remove it. If you think so, I will send this patch for you. Thanks Tang Bin > BRs > Olivier > >> Thanks >> >> Tang Bin >> >>