Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11817787pjo; Thu, 2 Jan 2020 14:48:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwsDv0o1cH8rAYTn8VeYBioWUHkOMZZAQTBxRjoLNRJrhEQ161A4i+riZ+oiiU9L7XOA2to X-Received: by 2002:aca:d0c:: with SMTP id 12mr3308590oin.26.1578005338093; Thu, 02 Jan 2020 14:48:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005338; cv=none; d=google.com; s=arc-20160816; b=dl4ghHKDBOeGUNnML9U9KegQYXXrObCUMLHm4/yNMZRt3JVYCp7X4Et2gc2HE6GhMn be5/xIh14qm3ARYqSHDFQSoHRxtQGAVcv/bb1Tsosj0x5ffCcubpyq9/uR/Mht0FvqYK 5Jh5WvSRm1sZ53rtqVJQAk5TQCFroTYkjXUG3QrMF4D+1dcDV6D+LBrwj5EonzG/yR2c JHktNlW21Y0bRsTjYbKZqNH6AoMkdsN0mdkSl2KY0uzPKvFO37S4vWkXHtA5okNgrfZR h6IZi4MkD+KmgA8unnLtFRsSOnrS5nPj8yWjXt4XnMF/+qj8cgxnV6Jo0A5ZN2qfxjJg QlTg== 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=2Q9tY29aeSLpBfQY9eBwIlEaoKAnKIo74tQWntrx8SE=; b=vbDH+j6t/d3WkBeLYwGhuA+D1dG3n+Qmj2zaZHIbrVm69s8jpRG17XnBo79KHvskOK 98AcoskNZ8p7nD6T21WEE5zLwXBsg5kyPcNCCuLwdVrKYng+hQqLnPKwdn8g0mA03QcY aD2yuyN5RUNTwHHwPuvblDv9vmJ1roAPu6pK7gJevbF2bqfIFxKBp1OJr5NJ8O7Gznma 2xsb2Tc6uI7ivpDHFmhZA8U2f/RGzlwT124smXhWuPtMYYQKoWOpl2PGBNxGwHw9uCxZ dGzbvBKDTuw66jcVszqzoAzVQSNvLwuiZ/yeJzKGEcVXdRJCVr+vBJmTL4jQFsubWkjK JNhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dGifCh1k; 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 j9si18749912oii.195.2020.01.02.14.48.46; Thu, 02 Jan 2020 14:48:58 -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=dGifCh1k; 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 S1730114AbgABW37 (ORCPT + 99 others); Thu, 2 Jan 2020 17:29:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:32968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730099AbgABW3y (ORCPT ); Thu, 2 Jan 2020 17:29:54 -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 01611222C3; Thu, 2 Jan 2020 22:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004193; bh=pbsHysMIPxVrUeCLFnSD6U3RGD3lw3QM9UT97777bnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dGifCh1kN/9znIeCH5fTWOfaWzerm+FI0mgy8pK8WyXvIwUgKUb30Jug/fwLccGl+ Jf1MdG0xLy5HIZXuyqM7t/5+j8p22U5Q9dHdhrJkd4gI0AtKlBXn1wwR6uaCG6aaOY 4vL0HctJl4917b8GNDMgU1B8Nyzv8y4rdpyVcMtc= 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.9 069/171] parport: load lowlevel driver if ports not found Date: Thu, 2 Jan 2020 23:06:40 +0100 Message-Id: <20200102220556.468561134@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.960200039@linuxfoundation.org> References: <20200102220546.960200039@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 daa2eb3050df..a7ceed7182ac 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