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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B87F0C43603 for ; Tue, 10 Dec 2019 22:36:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B4EE208C3 for ; Tue, 10 Dec 2019 22:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576017361; bh=38FFUr4wJcSHZUo18xjwL//0/s+aUyFXP8m0Ec/39v0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OapoZKrcONvMXiL7fZlkLvULFEzprW2rt6vkj7xEW2Y7x8TSsnxDNWZdHFXKATEnC VY3QpcqraHOwRAMOvqgkTT6n6vQrPNVKb56xd9xPN5u4JRLPq4pc99DJx3LRdFZkBF +d2qPjdCJ6Xhy8ZcbxfTKCuuQOnmI0ZC43Bh7h7s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730504AbfLJWgB (ORCPT ); Tue, 10 Dec 2019 17:36:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:55788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730312AbfLJWeZ (ORCPT ); Tue, 10 Dec 2019 17:34:25 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 58C6120836; Tue, 10 Dec 2019 22:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576017264; bh=38FFUr4wJcSHZUo18xjwL//0/s+aUyFXP8m0Ec/39v0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AK5QDvCxSNyhcwrB6ujF6dB2CM19kDLrHGqqljbekTvZqwnffOmDpPY0H9cTPqJPY FPY8hmsUuRkm0U5CjpUy0ci5Rj7jHKNNB4/CNfwdraEoP9v6cFw5BwGsJhMHjXL23J 2CzrxOSrOmvTyhDC2lxClBpbt5Tu8VMMdOjVTJ/s= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sudip Mukherjee , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.4 58/71] parport: load lowlevel driver if ports not found Date: Tue, 10 Dec 2019 17:33:03 -0500 Message-Id: <20191210223316.14988-58-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191210223316.14988-1-sashal@kernel.org> References: <20191210223316.14988-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 f26af0214ab3e..3be1f4a041d49 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c @@ -228,6 +228,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 @@ -280,6 +292,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