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 2F6F1C433EF for ; Fri, 4 Mar 2022 14:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239747AbiCDO07 (ORCPT ); Fri, 4 Mar 2022 09:26:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiCDO04 (ORCPT ); Fri, 4 Mar 2022 09:26:56 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 729AB1BAF22 for ; Fri, 4 Mar 2022 06:26:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0FEE5617E5 for ; Fri, 4 Mar 2022 14:26:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 697B9C340E9; Fri, 4 Mar 2022 14:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646403963; bh=QiEeOJ7rebdrAU94OlMmketbBtb1BBpaT/qA8z0cp70=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NQ7Sl32GvWnrWfx1jY7zhgaaLWVCN5KO6B9l4JUur+2lmXeOKZ6TKRuuec1dfvpqH oVf9gGBf7/NiYTTYCQSZkFQyBGHAXjPxXtmVp8ZjivVJXgL+CSYSbjxNVfYqU/WBb5 HnqR0bisl3D7RiILHoiUIhOrOU56PHjNZy0Tff2vkVp8ncIAr4/wiEfka+firRH+Qd kV7hxsb5jXIDwHyz+cDdOFZu/WIxrGp3hY9zSVLS1JDdpe4+pb9jzrXN7D8HzeAZ1q 7bixBVc/mw/HuIl4Q53LXyni/61ihT/u1xwPtimdd7PTaYw7lmLoR1dZEciAoJX8oX z38Ol88Cc2SGA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nQ8sb-00CEuP-1o; Fri, 04 Mar 2022 14:26:01 +0000 Date: Fri, 04 Mar 2022 14:26:00 +0000 Message-ID: <87o82l23rb.wl-maz@kernel.org> From: Marc Zyngier To: Christophe Leroy Cc: "cgel.zte@gmail.com" , "mpe@ellerman.id.au" , Zeal Robot , "linux-kernel@vger.kernel.org" , Minghao Chi , "jgg@ziepe.ca" , "paulus@samba.org" , "tglx@linutronix.de" , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [PATCH] powerpc/sysdev: Use of_device_get_match_data() In-Reply-To: <6481b730-e338-294d-3602-bb899654ed2b@csgroup.eu> References: <20220304011830.2061591-1-chi.minghao@zte.com.cn> <6481b730-e338-294d-3602-bb899654ed2b@csgroup.eu> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: christophe.leroy@csgroup.eu, cgel.zte@gmail.com, mpe@ellerman.id.au, zealci@zte.com.cn, linux-kernel@vger.kernel.org, chi.minghao@zte.com.cn, jgg@ziepe.ca, paulus@samba.org, tglx@linutronix.de, linuxppc-dev@lists.ozlabs.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 04 Mar 2022 13:10:19 +0000, Christophe Leroy wrote: >=20 >=20 >=20 > Le 04/03/2022 =C3=A0 02:18, cgel.zte@gmail.com a =C3=A9crit=C2=A0: > > From: Minghao Chi (CGEL ZTE) > >=20 > > Use of_device_get_match_data() to simplify the code. > >=20 > > Reported-by: Zeal Robot > > Signed-off-by: Minghao Chi (CGEL ZTE) > > --- > > arch/powerpc/sysdev/fsl_msi.c | 6 +----- > > 1 file changed, 1 insertion(+), 5 deletions(-) > >=20 > > diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_ms= i.c > > index b3475ae9f236..9d135bbb30b7 100644 > > --- a/arch/powerpc/sysdev/fsl_msi.c > > +++ b/arch/powerpc/sysdev/fsl_msi.c > > @@ -387,7 +387,6 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi,= struct platform_device *dev, > > static const struct of_device_id fsl_of_msi_ids[]; > > static int fsl_of_msi_probe(struct platform_device *dev) > > { > > - const struct of_device_id *match; > > struct fsl_msi *msi; > > struct resource res, msiir; > > int err, i, j, irq_index, count; > > @@ -397,10 +396,7 @@ static int fsl_of_msi_probe(struct platform_device= *dev) > > u32 offset; > > struct pci_controller *phb; > > =20 > > - match =3D of_match_device(fsl_of_msi_ids, &dev->dev); > > - if (!match) > > - return -EINVAL; > > - features =3D match->data; > > + features =3D of_device_get_match_data(&dev->dev); >=20 > What happens when features is NULL ? I did jump at that one too, but as it turns out, it cannot happen, by construction. All the fsl_of_msi_ids[] entries have a non-NULL .data pointer, and you only enter probe if you match a fsl_of_msi_ids[] entry with the DT. So the current check for a NULL match is not something that can happen short of some other bug somewhere. M. --=20 Without deviation from the norm, progress is not possible.