Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5591214pxu; Thu, 22 Oct 2020 06:26:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBUKXltAkaxi2rRZ2b5qjWNPZJrnrz43pr9AFF1THtTrhqmhoy7l7uTF43iIvUOcD6GcO7 X-Received: by 2002:a05:6402:135a:: with SMTP id y26mr2236549edw.114.1603373198109; Thu, 22 Oct 2020 06:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603373198; cv=none; d=google.com; s=arc-20160816; b=EztpjRj5hgW2UwbNy+xtvu8xgkr1YEMQln2eIUo80Fhkgyy2NkH3R1qX6QTPLKGCoV LS1/hSTgvY1dtfG3yvXQkdY0nENztBpu7fV1s63s8JjrEcwHEAAaRJYbcyAkGFLtvIY9 YFjK3MEnvVprPrzCkr6BtxN7BBr0r7Hwv6/dLzYhutZIec14zrDzTG7vEwu9TklT/tZ1 mwPTfQpRXgbyLV+6CK/DA8m9V1WNX8EgYLfaQ3ajjrSU0IjmuqhAt0fAuPZy2u4nXI55 qXFzc2fn6OntBgj3S16trRPwSZ90fF18qVReF6pjHAetdlHNrrUPcd3Gfag5iO17ZuI8 tqUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=f+hQLpxuXEGXOMO7nzpOYJ2CyaDpd2uSHbXE7Go6pYA=; b=ED92+BeEzW1AiGMRF5u61WIghysUCjD1y3DCWaNSUcnGKPqwfYAu4V0YI9Ms//W90w phGIbImzByjBmjZoZfgiTxF2VG2qbVLFjHNUK9ip4/i/7AXrDnHxaObMT+EjqFQRhkTJ HHX9xsqUwEmdFA9lGlFIfHOO2d0uY4RJSoBOOXAnCqLN3Nf1RGHiNoXCZJCqbtdfaFWQ 5XBd2J4huRMUmlMYunWWjeeHK+Y3HSEnHBjSk7o5Sa+4Otbd6i2s825S5zYic5paUwfT RtHBM2xjnbqI3IMbEaJDMO51HNMSQX9YFI7pxfhWY/lMYednPdgot3t349c8SRiB+UKn 9Y3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b="DeS/8oEh"; 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 k25si1008410ejk.10.2020.10.22.06.26.14; Thu, 22 Oct 2020 06:26:38 -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=@ellerman.id.au header.s=201909 header.b="DeS/8oEh"; 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 S2443375AbgJVCxQ (ORCPT + 99 others); Wed, 21 Oct 2020 22:53:16 -0400 Received: from ozlabs.org ([203.11.71.1]:49667 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2442728AbgJVCxQ (ORCPT ); Wed, 21 Oct 2020 22:53:16 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4CGsP14c7Vz9sSn; Thu, 22 Oct 2020 13:53:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1603335192; bh=fW5FipmXYxyEiBCHMu/Sd0mLJUNgkUEv7kKEvoc29V0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=DeS/8oEhEaeq235MxQgaLDc0dL8ank/k+UdrfESwGHS+oQacrPHsm2SnK/uhn8UJ0 SuOqEbOVVsdXOCtnLZsRAzOvMwTx/miCuRrzfqM29KieQ6ERBMklEkPOk1fPpXCvIX pg2UCUi0cpL4cC0PNw2Uz/B/HrQa6QxqIq+6+BSUGucoZNa6wl5iieZrtXAP99+w34 up9Kr9xMjz4IPptPv893Cq3n0BXmLyhXE8WHX3sbImziGehjfTczl87VVjyYH0qEz0 RL26T9lFD1uA77TzLX9k6uEsxkPOjSAlVToeVm34D3ucgM7DK0qB3ugaXLSpV5nBwp h8Vn7kiDKIogw== From: Michael Ellerman To: Laurent Vivier , Greg KH Cc: linux-kernel@vger.kernel.org, Joshua Thompson , linux-serial@vger.kernel.org, Benjamin Herrenschmidt , linux-m68k@lists.linux-m68k.org, Geert Uytterhoeven , Paul Mackerras , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] serial: pmac_zilog: don't init if zilog is not available In-Reply-To: References: <20201020162303.1730562-1-laurent@vivier.eu> <20201020162844.GA865546@kroah.com> <468bbbef-4745-3b16-b6f4-30b46ebcdc33@vivier.eu> <20201020173745.GA882703@kroah.com> <387fd2aa-b181-c41f-0581-0a7e79a44e41@vivier.eu> <20201020183246.GA912431@kroah.com> Date: Thu, 22 Oct 2020 13:52:56 +1100 Message-ID: <87o8kvx987.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Laurent Vivier writes: > Le 20/10/2020 =C3=A0 20:32, Greg KH a =C3=A9crit=C2=A0: >> On Tue, Oct 20, 2020 at 08:19:26PM +0200, Laurent Vivier wrote: >>> Le 20/10/2020 =C3=A0 19:37, Greg KH a =C3=A9crit=C2=A0: >>>> On Tue, Oct 20, 2020 at 06:37:41PM +0200, Laurent Vivier wrote: >>>>> Le 20/10/2020 =C3=A0 18:28, Greg KH a =C3=A9crit=C2=A0: >>>>>> On Tue, Oct 20, 2020 at 06:23:03PM +0200, Laurent Vivier wrote: >>>>>>> We can avoid to probe for the Zilog device (and generate ugly kerne= l warning) >>>>>>> if kernel is built for Mac but not on a Mac. >>>>>>> >>>>>>> Signed-off-by: Laurent Vivier >>>>>>> --- >>>>>>> drivers/tty/serial/pmac_zilog.c | 11 +++++++++++ >>>>>>> 1 file changed, 11 insertions(+) >>>>>>> >>>>>>> diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/p= mac_zilog.c >>>>>>> index 063484b22523..d1d2e55983c3 100644 >>>>>>> --- a/drivers/tty/serial/pmac_zilog.c >>>>>>> +++ b/drivers/tty/serial/pmac_zilog.c >>>>>>> @@ -1867,6 +1867,12 @@ static struct platform_driver pmz_driver =3D= { >>>>>>> static int __init init_pmz(void) >>>>>>> { >>>>>>> int rc, i; >>>>>>> + >>>>>>> +#ifdef CONFIG_MAC >>>>>>> + if (!MACH_IS_MAC) >>>>>>> + return -ENODEV; >>>>>>> +#endif >>>>>> >>>>>> Why is the #ifdef needed? >>>>>> >>>>>> We don't like putting #ifdef in .c files for good reasons. Can you = make >>>>>> the api check for this work with and without that #ifdef needed? >>>>> >>>>> The #ifdef is needed because this file can be compiled for PowerMac a= nd >>>>> m68k Mac. For PowerMac, the MACH_IS_MAC is not defined, so we need the >>>>> #ifdef. >>>>> >>>>> We need the MAC_IS_MAC because the same kernel can be used with sever= al >>>>> m68k machines, so the init_pmz can be called on a m68k machine without >>>>> the zilog device (it's a multi-targets kernel). >>>>> >>>>> You can check it's the good way to do by looking inside: >>>>> >>>>> drivers/video/fbdev/valkyriefb.c +317 >>>>> drivers/macintosh/adb.c +316 >>>>> >>>>> That are two files used by both, mac and pmac. >>>> >>>> Why not fix it to work properly like other arch checks are done >>> I would be happy to do the same. >>> >>>> Put it in a .h file and do the #ifdef there. Why is this "special"? >>> >>> I don't know. >>> >>> Do you mean something like: >>> >>> drivers/tty/serial/pmac_zilog.h >>> ... >>> #ifndef MACH_IS_MAC >>> #define MACH_IS_MAC (0) >>> #endif >>> ... >>> >>> drivers/tty/serial/pmac_zilog.c >>> ... >>> static int __init pmz_console_init(void) >>> { >>> if (!MACH_IS_MAC) >>> return -ENODEV; >>> ... >>=20 >> Yup, that would be a good start, but why is the pmac_zilog.h file >> responsible for this? Shouldn't this be in some arch-specific file >> somewhere? > > For m68k, MACH_IS_MAC is defined in arch/m68k/include/asm/setup.h > > If I want to define it for any other archs I don't know in which file we > can put it. > > But as m68k mac is only sharing drivers with pmac perhaps we can put > this in arch/powerpc/include/asm/setup.h? It doesn't really belong in there. I'd accept a patch to create arch/powerpc/include/asm/macintosh.h, with MACH_IS_MAC defined in there. cheers