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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27011C43334 for ; Tue, 12 Jul 2022 13:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbiGLNdT (ORCPT ); Tue, 12 Jul 2022 09:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbiGLNdS (ORCPT ); Tue, 12 Jul 2022 09:33:18 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D94CB6294 for ; Tue, 12 Jul 2022 06:33:17 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id bk26so11172342wrb.11 for ; Tue, 12 Jul 2022 06:33:16 -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:content-transfer-encoding:in-reply-to; bh=1FNQrGGLfgdOgMRKiUwsbzE3SGEjtGBgzxsXljwQUHE=; b=hTDsqLoXRixjt/Sxz4pnsbxPZ2ChVkl5G3Efink/BugEruXacu1c14dFTFwKa0c3gY o/+eryoGjW9zyuyJ7wemDQirD4D04/nXfYPkHa1G3NtRldyCDQ/2zs/zyzMfMEI8HTWr iYlsUd6VZ1BdSYB6OpRejTRfbS/3+NfNcv56pt8/W3na5GXCHJ5oq4VO25FksgV9cQFP OOzwUmFoXuLhNwWST4eb5B14ImeEhE4+FdqOm1DF6nMbC5rCYGWDPXDwqd7SkScILR7N gec2/C7+2gfE3s/eAraUC8ItcbP1D33rLOfkl66gtcp/BtJDaEyGPr/I+63MxweebsQZ wKaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=1FNQrGGLfgdOgMRKiUwsbzE3SGEjtGBgzxsXljwQUHE=; b=gptUD+4+xikpqffDIS8PXsiBFTvWab4wt/sUcOLpOw4Rcs4MuDTlH/KC6XewTERGgc 6mgvoFIZRB1exdFK11KJ3C2+4672MUMld2WK6VPpGskLxzCnRJ7ltFW/0FhMuvRfRlfb RNrmXJ02tg9KoSSm6+G8higcIMFVHvqnuCCrlq0/SHEjHYz4Z2kx50PlqXzVrf2lA4s4 Sx/1JXjIYTXLCUdl4/3PWedRAviMmrj21oTqNOYvZuPdxuroqqU4glDq3Za8T8HmRyDb Hqx48soxQ2Fs02+5c2nNksHYGez1PTOo7iM0ZxXnn9jX9maVK+Kh6e0xC4ibTwIRmABN gjgQ== X-Gm-Message-State: AJIora/OK1lqB8IhkBsFnNomRSlU1EWoU7U5CL4KQ2CvCnpZsVhlz3kQ QN97oaIK9r2we/VT3vTusrLL8g== X-Google-Smtp-Source: AGRyM1tDxqUM6cVCSs98mVzMblL7DYw1ebw4b5m50i0FuBi3jTzjyS1F+201+kxSFQ4/IZUzwFtrpw== X-Received: by 2002:a05:6000:178c:b0:21d:b6d0:11a8 with SMTP id e12-20020a056000178c00b0021db6d011a8mr1741057wrg.547.1657632795572; Tue, 12 Jul 2022 06:33:15 -0700 (PDT) Received: from google.com (cpc155339-bagu17-2-0-cust87.1-3.cable.virginm.net. [86.27.177.88]) by smtp.gmail.com with ESMTPSA id g4-20020adff404000000b0021d87798237sm8320371wro.20.2022.07.12.06.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 06:33:14 -0700 (PDT) Date: Tue, 12 Jul 2022 14:33:13 +0100 From: Lee Jones To: Francesco Dolcini Cc: Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ahmad Fatoum Subject: Re: [PATCH v1 1/4] mfd: stmpe: Probe sub-function by compatible Message-ID: References: <20220712110232.329164-1-francesco.dolcini@toradex.com> <20220712110232.329164-2-francesco.dolcini@toradex.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220712110232.329164-2-francesco.dolcini@toradex.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Tue, 12 Jul 2022, Francesco Dolcini wrote: > Use sub-function of_compatible during probe, instead of using the node > name. The code should not rely on the node names during probe, in > addition to that the previously hard-coded node names are not compliant > to the latest naming convention (they are not generic and they use > underscores), and it was broken by mistake already once [1]. > > While doing this change `rotator` entry was removed, it is not > used in any device tree file, there is no cell defined, it's just dead > non-working code with no of_compatible for it. > > [1] commit 56086b5e804f ("ARM: dts: imx6qdl-apalis: Avoid underscore in node name") > > Suggested-by: Ahmad Fatoum > Signed-off-by: Francesco Dolcini > --- > drivers/mfd/stmpe.c | 31 +++++++++++++++++-------------- > 1 file changed, 17 insertions(+), 14 deletions(-) > > diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c > index aeb9ea55f97d..90a07a94455f 100644 > --- a/drivers/mfd/stmpe.c > +++ b/drivers/mfd/stmpe.c > @@ -23,6 +23,12 @@ > #include > #include "stmpe.h" > > +#define STMPE_GPIO_COMPATIBLE "st,stmpe-gpio" > +#define STMPE_KEYPAD_COMPATIBLE "st,stmpe-keypad" > +#define STMPE_PWM_COMPATIBLE "st,stmpe-pwm" > +#define STMPE_TS_COMPATIBLE "st,stmpe-ts" > +#define STMPE_ADC_COMPATIBLE "st,stmpe-adc" This is horrible. Please refrain from defining device/compatible strings. > /** > * struct stmpe_platform_data - STMPE platform data > * @id: device id to distinguish between multiple STMPEs on the same board > @@ -321,14 +327,14 @@ static struct resource stmpe_gpio_resources[] = { > > static const struct mfd_cell stmpe_gpio_cell = { > .name = "stmpe-gpio", > - .of_compatible = "st,stmpe-gpio", > + .of_compatible = STMPE_GPIO_COMPATIBLE, > .resources = stmpe_gpio_resources, > .num_resources = ARRAY_SIZE(stmpe_gpio_resources), > }; > > static const struct mfd_cell stmpe_gpio_cell_noirq = { > .name = "stmpe-gpio", > - .of_compatible = "st,stmpe-gpio", > + .of_compatible = STMPE_GPIO_COMPATIBLE, > /* gpio cell resources consist of an irq only so no resources here */ > }; > > @@ -350,7 +356,7 @@ static struct resource stmpe_keypad_resources[] = { > > static const struct mfd_cell stmpe_keypad_cell = { > .name = "stmpe-keypad", > - .of_compatible = "st,stmpe-keypad", > + .of_compatible = STMPE_KEYPAD_COMPATIBLE, > .resources = stmpe_keypad_resources, > .num_resources = ARRAY_SIZE(stmpe_keypad_resources), > }; > @@ -376,7 +382,7 @@ static struct resource stmpe_pwm_resources[] = { > > static const struct mfd_cell stmpe_pwm_cell = { > .name = "stmpe-pwm", > - .of_compatible = "st,stmpe-pwm", > + .of_compatible = STMPE_PWM_COMPATIBLE, > .resources = stmpe_pwm_resources, > .num_resources = ARRAY_SIZE(stmpe_pwm_resources), > }; > @@ -461,7 +467,7 @@ static struct resource stmpe_ts_resources[] = { > > static const struct mfd_cell stmpe_ts_cell = { > .name = "stmpe-ts", > - .of_compatible = "st,stmpe-ts", > + .of_compatible = STMPE_TS_COMPATIBLE, > .resources = stmpe_ts_resources, > .num_resources = ARRAY_SIZE(stmpe_ts_resources), > }; > @@ -484,7 +490,7 @@ static struct resource stmpe_adc_resources[] = { > > static const struct mfd_cell stmpe_adc_cell = { > .name = "stmpe-adc", > - .of_compatible = "st,stmpe-adc", > + .of_compatible = STMPE_ADC_COMPATIBLE, > .resources = stmpe_adc_resources, > .num_resources = ARRAY_SIZE(stmpe_adc_resources), > }; > @@ -1362,19 +1368,16 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata, > pdata->autosleep = (pdata->autosleep_timeout) ? true : false; > > for_each_available_child_of_node(np, child) { > - if (of_node_name_eq(child, "stmpe_gpio")) { > + if (of_device_is_compatible(child, STMPE_GPIO_COMPATIBLE)) > pdata->blocks |= STMPE_BLOCK_GPIO; > - } else if (of_node_name_eq(child, "stmpe_keypad")) { > + else if (of_device_is_compatible(child, STMPE_KEYPAD_COMPATIBLE)) > pdata->blocks |= STMPE_BLOCK_KEYPAD; > - } else if (of_node_name_eq(child, "stmpe_touchscreen")) { > + else if (of_device_is_compatible(child, STMPE_TS_COMPATIBLE)) > pdata->blocks |= STMPE_BLOCK_TOUCHSCREEN; > - } else if (of_node_name_eq(child, "stmpe_adc")) { > + else if (of_device_is_compatible(child, STMPE_ADC_COMPATIBLE)) > pdata->blocks |= STMPE_BLOCK_ADC; > - } else if (of_node_name_eq(child, "stmpe_pwm")) { > + else if (of_device_is_compatible(child, STMPE_PWM_COMPATIBLE)) > pdata->blocks |= STMPE_BLOCK_PWM; > - } else if (of_node_name_eq(child, "stmpe_rotator")) { > - pdata->blocks |= STMPE_BLOCK_ROTATOR; > - } This should be a separate patch. > } > } > -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog