Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp432107pxb; Wed, 3 Nov 2021 06:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3UHHIfKHF8LJKVfaNYwSaGdXs6At7BTZUPkFCsjCbTY4W5SEcvDJX1EddNbFPUJtoAku8 X-Received: by 2002:a17:907:d0b:: with SMTP id gn11mr27744346ejc.355.1635946809669; Wed, 03 Nov 2021 06:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635946809; cv=none; d=google.com; s=arc-20160816; b=FjXw2eG+C7stN0Qg3ZZ3nRY2x+xfdI0yxGohVpYRcyJnycWfmAr3YtkutZ/bT3+W/T jfrIfZrUa1LTKMa6CD0+CWiBeITX9pw/ZqY57/TK4vukb7vW2vTgaTeL+gKjI/j1MxxE mV08263+qtd3IXsaM8uKLy09XumneKmtniPu/TOdtbjaM3NCNO4mJQ8IkfkSqd+RBs1/ P7bz8DoHqcWuorbfcss8en/PYXJQoJSTOoA2zcI+pzQXGhZy4l1J+exqutY/XSOF9imT xPCSIZaWCCS074UScD3BgJHpREnVt6IOhNstCkhxl9WLlMvGL3IYfrCF1pMCjwu5Lgsp Ot1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=tvoaaXMd99Aly5rEwx0+nDfU+NKtixpNXJWzrFtUn1w=; b=GLUJ9u27S1/9O3fWXppa7YEbfYD7UGFU5W3eg2N492T+iiTKBKMjERjaJrRqQzUZQW UbgJvNupurRSyJiM2iyXRpF2301x17GedlMJV58DSpc/R60UDVGvyYVD6WBAyVYjNQEv N/F3SLpVi6bk955Rop40xYpIKle106Vir6xyFUGLWRF/r+Fb12wrtsfgg4kqEtQDDxIM 9REyfZtY1iprMZeew8e95tMg/y6sxzbGvZjy1iLjpkmwwn5URN+MAONRO3oV9MxJFFVr 34dHTpOqYFRe7aetz2D4j8AoKzjlr4hi4wFpqS14o6l41PkOr3FVYd7N2SEzxczRFI3B YB3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@goldelico.com header.s=strato-dkim-0002 header.b=AcC9vrg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bk26si3367991ejb.557.2021.11.03.06.39.45; Wed, 03 Nov 2021 06:40:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@goldelico.com header.s=strato-dkim-0002 header.b=AcC9vrg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231643AbhKCNjZ (ORCPT + 99 others); Wed, 3 Nov 2021 09:39:25 -0400 Received: from mo4-p03-ob.smtp.rzone.de ([85.215.255.103]:33236 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbhKCNjW (ORCPT ); Wed, 3 Nov 2021 09:39:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1635946588; s=strato-dkim-0002; d=goldelico.com; h=To:References:Message-Id:Cc:Date:In-Reply-To:From:Subject:Cc:Date: From:Subject:Sender; bh=tvoaaXMd99Aly5rEwx0+nDfU+NKtixpNXJWzrFtUn1w=; b=AcC9vrg3ysgfi8RqVBHIIFDtJQiZVZOeo/Dp7kPPD0xFHDjLU3RHeDBcPE3xe/xpvi APUhPqn794VyphisxHMiWKHXj9L33c4mVnWPbUwAmCc1t8S+rzyNL614omjxT1P6SxeC vS4Dg1LUTakBilxg6lwyWp+mZLRgad2bvYJImZzbC+ROxqsbZX8WcGwn6qwbYVWahJ+5 pDM4gsBNE2sTXXn2TFknutt06DFlHmahSCbJ23cq+4fvcjQ9FcefB8UDrHUl88xQ1Uzb OdoXD9UGR4ois2vuWQMvLSSY0bIWX3/XVGfYrLYuuTW8gWdn6sMnHRx7yUlzMuy0CUNF /YXw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMgPgp8VKxflSZ1P34KBj7wpz8NIGH/jrwDOoFRs=" X-RZG-CLASS-ID: mo00 Received: from imac.fritz.box by smtp.strato.de (RZmta 47.34.1 DYNA|AUTH) with ESMTPSA id 902c63xA3DaR0Qf (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Wed, 3 Nov 2021 14:36:27 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: [RFC v3 2/6] mmc: core: allow to match the device tree to apply quirks From: "H. Nikolaus Schaller" In-Reply-To: <12030734.Zn5U6lzIJN@pc-42> Date: Wed, 3 Nov 2021 14:36:21 +0100 Cc: Ulf Hansson , Avri Altman , Shawn Lin , Linus Walleij , Tony Lindgren , Bean Huo , notasas@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, kernel@pyra-handheld.com Content-Transfer-Encoding: quoted-printable Message-Id: <01F92CD5-89B8-4BF1-9E90-1A37BD49B68A@goldelico.com> References: <12030734.Zn5U6lzIJN@pc-42> To: =?utf-8?B?SsOpcsO0bWUgUG91aWxsZXI=?= X-Mailer: Apple Mail (2.3445.104.21) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi jerome, > Am 03.11.2021 um 14:24 schrieb J=C3=A9r=C3=B4me Pouiller = : >=20 > Hi Nikolaus, >=20 > On Wednesday 3 November 2021 14:00:10 CET H. Nikolaus Schaller wrote: >> From: J=C3=A9r=C3=B4me Pouiller >>=20 >> MMC subsystem provides a way to apply quirks when a device match some >> properties (VID, PID, etc...) Unfortunately, some SDIO devices does = not >> comply with the SDIO specification and does not provide reliable = VID/PID >> (eg. Silabs WF200). >>=20 >> So, the drivers for these devices rely on device tree to identify the >> device. >>=20 >> This patch allows the MMC to also rely on the device tree to apply a >> quirk. >>=20 >> Signed-off-by: J=C3=A9r=C3=B4me Pouiller >> --- >> drivers/mmc/core/card.h | 3 +++ >> drivers/mmc/core/quirks.h | 18 ++++++++++++++++++ >> 2 files changed, 21 insertions(+) >>=20 >> diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h >> index 7bd392d55cfa5..2f73f8567e14f 100644 >> --- a/drivers/mmc/core/card.h >> +++ b/drivers/mmc/core/card.h >> @@ -59,6 +59,9 @@ struct mmc_fixup { >> /* for MMC cards */ >> unsigned int ext_csd_rev; >>=20 >> + /* Match against functions declared in device tree */ >> + const char *const *of_compatible; >> + >> void (*vendor_fixup)(struct mmc_card *card, int data); >> int data; >> }; >> diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h >> index c7ef2d14b359f..a8b82b34dcfd2 100644 >> --- a/drivers/mmc/core/quirks.h >> +++ b/drivers/mmc/core/quirks.h >> @@ -10,6 +10,7 @@ >> * >> */ >>=20 >> +#include >> #include >>=20 >> #include "card.h" >> @@ -145,6 +146,20 @@ static const struct mmc_fixup __maybe_unused = sdio_fixup_methods[] =3D { >> END_FIXUP >> }; >>=20 >> +static inline bool mmc_fixup_of_compatible_match(struct mmc_card = *card, >> + const char *const = *compat_list) >> +{ >> + struct device_node *of_node; >> + int i; >> + >> + for (i =3D 0; i < 7; i++) { >> + of_node =3D mmc_of_find_child_device(card->host, i); >> + if (of_node && of_device_compatible_match(of_node, = compat_list)) >> + return true; >> + } >> + return false; >> +} >> + >> static inline void mmc_fixup_device(struct mmc_card *card, >> const struct mmc_fixup *table) >> { >> @@ -173,6 +188,9 @@ static inline void mmc_fixup_device(struct = mmc_card *card, >> continue; >> if (rev < f->rev_start || rev > f->rev_end) >> continue; >> + if (f->of_compatible && >> + !mmc_fixup_of_compatible_match(card, = f->of_compatible)) >> + continue; >>=20 >> dev_dbg(&card->dev, "calling %ps\n", f->vendor_fixup); >> f->vendor_fixup(card, f->data); >> -- >> 2.33.0 >>=20 >>=20 >=20 > Thanks to take care of this. Do you know if the comments for Ulf[1] > are still relevant? >=20 > [1]: = https://lore.kernel.org/lkml/CAPDyKFpr0kpRXoUACNNSwe8pL1S9wJPjnX+GFGS1PNez= KCDYzQ@mail.gmail.com/ Ah yes. I think so. Especially the comment about doing the loop over the child nodes... I'll make a note for v4. BR and thanks, Nikolaus