Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13336979ybl; Sun, 29 Dec 2019 09:35:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzUegBV7YEFs/ZHCh+u1IegMJjfNnyRNzcNuf0T3AVNgmw5TqtnvZJVYPNZl+StWDQoeGSK X-Received: by 2002:a05:6830:9a:: with SMTP id a26mr59394535oto.131.1577640911373; Sun, 29 Dec 2019 09:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640911; cv=none; d=google.com; s=arc-20160816; b=x9vDyyxWRSgSJ3LMjhB0rR4KqF7ZuJyvGtJh1pfnNBcg5xINd3PBwleheSurKM7yY3 D42u3+olA/htTLX5xu/YbahH3NI3jIZ1KOuIeuCtAc8uo6pSbabW8rbtYB+zp+P3Ft5j w6Q0jOOPVpA0XnmiVmCIeqAdzJjjVF9C2XGfUtdzX+6D4FNNN9CO+jXrkyKQAySHIZH9 nPynkk87q6VDBAvtXXI8LtGJOHjaYMtahv2nQEUJcXPszhVNb9XDKp1R8Cr983ugwaW+ 8Q+5fG6iDA7ai2mKf00Orhn2uj/vqF0dAgPk2AyhUKTzWBr0HZw7GQr44b2Vzg7xhsOO eD+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qLnDXibhWJVQhjLMwKanXS21F/b5O0Rmpq0aSkCq1fk=; b=fi4Ax2tEYc94XrFVIR0pIk++Tu+KWDtDePvds+KQOkcHilzZy/eyiy4Ra+lEuSzrt2 hvES082nZr6P6fbxLceNdRYXgLa9NvAJAzdRtJVSfuLQgqbXAKCoFOZwRHAkK05Gikb7 QqqcBbm/KNCciIngEFAte5YZgyhFEabEl+wxRHaXAjlaBT1ijmSm3mrNhyzNkZ6x9LAn i655L/IXoaJy6WpiTq/Z4aBU6PeswW6JibVXLREud9McWQ1YypcGI/oiAXgzwlB/Z7Ot Noe+O0vAnr71Blz2CgZrvQpz7ytLElys8Dl28kGjplyv/0p3xnaT9lDdklsjhyhNpoAS nvYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ADZNhivx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11si4011377oic.185.2019.12.29.09.35.00; Sun, 29 Dec 2019 09:35:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ADZNhivx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729543AbfL2Rdy (ORCPT + 99 others); Sun, 29 Dec 2019 12:33:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:36124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729535AbfL2Rdu (ORCPT ); Sun, 29 Dec 2019 12:33:50 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7DD7207FF; Sun, 29 Dec 2019 17:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640830; bh=u1vbAAODFFibUTO2yMqM38STXoTtYukUrreTORXp/oo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ADZNhivx1NEo+i57OpjfSlRBMCk4oX+bW/Om6L2iLK/DWXN0o2a/ofEy4rOTz8sIN FtL3/cTXrfomjPpfLuusJKDNMzqOWh9wso5DOrrbogpfWhhUelYGaY1wRPwANPfMik 5SSqYIVXgTNMaWlkbFzaYHejFHd6+tM5Xpjpp5hE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudip Mukherjee , Sasha Levin Subject: [PATCH 4.19 156/219] parport: load lowlevel driver if ports not found Date: Sun, 29 Dec 2019 18:19:18 +0100 Message-Id: <20191229162532.031849147@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sudip Mukherjee [ Upstream commit 231ec2f24dad18d021b361045bbd618ba62a274e ] Usually all the distro will load the parport low level driver as part of their initialization. But we can get into a situation where all the parallel port drivers are built as module and we unload all the modules at a later time. Then if we just do "modprobe parport" it will only load the parport module and will not load the low level driver which will actually register the ports. So, check the bus if there is any parport registered, if not, load the low level driver. We can get into the above situation with all distro but only Suse has setup the alias for "parport_lowlevel" and so it only works in Suse. Users of Debian based distro will need to load the lowlevel module manually. Signed-off-by: Sudip Mukherjee Link: https://lore.kernel.org/r/20191016144540.18810-3-sudipm.mukherjee@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/parport/share.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/parport/share.c b/drivers/parport/share.c index 7b4ee33c1935..15c81cffd2de 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c @@ -230,6 +230,18 @@ static int port_check(struct device *dev, void *dev_drv) return 0; } +/* + * Iterates through all the devices connected to the bus and return 1 + * if the device is a parallel port. + */ + +static int port_detect(struct device *dev, void *dev_drv) +{ + if (is_parport(dev)) + return 1; + return 0; +} + /** * parport_register_driver - register a parallel port device driver * @drv: structure describing the driver @@ -282,6 +294,15 @@ int __parport_register_driver(struct parport_driver *drv, struct module *owner, if (ret) return ret; + /* + * check if bus has any parallel port registered, if + * none is found then load the lowlevel driver. + */ + ret = bus_for_each_dev(&parport_bus_type, NULL, NULL, + port_detect); + if (!ret) + get_lowlevel_driver(); + mutex_lock(®istration_lock); if (drv->match_port) bus_for_each_dev(&parport_bus_type, NULL, drv, -- 2.20.1