Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5040345pxu; Wed, 21 Oct 2020 11:36:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza2umcjt/vDsYyh8Z3lmfIdvE8TT1yu4S9AZ2YhVQtwTWbVVsRgwhvapTWhkkg62PveAWc X-Received: by 2002:aa7:d28c:: with SMTP id w12mr4421751edq.248.1603305389057; Wed, 21 Oct 2020 11:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603305389; cv=none; d=google.com; s=arc-20160816; b=CHBkF3Z1W7+bWW2sGP3MRnLRQ02WqUtY89Xm4BZCgJzYWDCPCWTM0n8/l44PgvETHn F+oqMk495l2FAGcoHP6gjY+rnGtAxox3l0fFvPObAfmNY30ABVdW8LtunSoW8SZft0bI Mq1saNHlIm/ZmHjCMl5EdNEQjOUdH6W6TMFe8fzU140h6/3PL1j1sLY3/o4dKY0MT0zy b2WgUAu4OUd1zOvqsEoLEYpj2g5dxK7ahL3cvoXHRIL+1gd89tQngpyhPhMPH0wOnxv+ ATFPd/0AcVUE3/wcKsVtuH8FjfDe8Bb5mDAoBDQvCe177PFCtw2uq4m+1c2pbJ6KbMDn Og+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date; bh=y1tD7kBk3I9NYYxXrnkBagIAOdbk0CASF4rXkWMFx8I=; b=yQu816wa3/Slm52U+tgp3K9SC5LwMcmg9uUFetv5RRUk/IzEdQwyLXYt9IBEjLaDjR pdMOtXG6zeXFCiBAqFGnnLSdWJv9z2Zbirx0hSn+PjsOP/Um2b4ZgRFVY+nT4wFO6wdb 2BVHUkTgQyUcafx1zvtzR+BIptleef+ukX6wP4Riah707cMxJcky6h50fyjPCfKN4cY9 T+ZOq8PNw1kKTctaFQhV2iyAk/1rRfx3WmQdScoG1j+viiN6FDlAVvFCplfyMOemhMe2 ISaQbCnUiRiFTZBAodRtCFEML6nSAXCxQ0mBGZ9qmx8xUAQlWkFhK6fv/sGCrEjUsMSv DqfA== ARC-Authentication-Results: i=1; mx.google.com; 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 e12si1913148ejd.673.2020.10.21.11.36.07; Wed, 21 Oct 2020 11:36:29 -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; 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 S2410670AbgJTXni (ORCPT + 99 others); Tue, 20 Oct 2020 19:43:38 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:38388 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410623AbgJTXni (ORCPT ); Tue, 20 Oct 2020 19:43:38 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 3A69323B22; Tue, 20 Oct 2020 19:43:34 -0400 (EDT) Date: Wed, 21 Oct 2020 10:43:37 +1100 (AEDT) From: Finn Thain To: Brad Boyer cc: Laurent Vivier , Greg KH , 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, Michael Ellerman Subject: Re: [PATCH] serial: pmac_zilog: don't init if zilog is not available In-Reply-To: <20201020224446.GA15066@allandria.com> Message-ID: 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> <20201020224446.GA15066@allandria.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Oct 2020, Brad Boyer wrote: > > Wouldn't it be better to rearrange this code to only run if the devices > are present? This is a macio driver on pmac and a platform driver on > mac, so shouldn't it be possible to only run this code when the > appropriate entries are present in the right data structures? > > I didn't look at a lot of the other serial drivers, but some other mac > drivers have recently been updated to no longer have MACH_IS_MAC checks > due to being converted to platform drivers. > Actually, it's not simply a platform driver or macio driver. I think the console is supposed to be registered before the normal bus matching takes place. Hence this comment in pmac_zilog.c, /* * First, we need to do a direct OF-based probe pass. We * do that because we want serial console up before the * macio stuffs calls us back, and since that makes it * easier to pass the proper number of channels to * uart_register_driver() */ Laurent, can we avoid the irq == 0 warning splat like this? diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 96e7aa479961..7db600cd8cc7 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c @@ -1701,8 +1701,10 @@ static int __init pmz_init_port(struct uart_pmac_port *uap) int irq; r_ports = platform_get_resource(uap->pdev, IORESOURCE_MEM, 0); + if (!r_ports) + return -ENODEV; irq = platform_get_irq(uap->pdev, 0); - if (!r_ports || irq <= 0) + if (irq <= 0) return -ENODEV; uap->port.mapbase = r_ports->start;