Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755883AbdCGSnr (ORCPT ); Tue, 7 Mar 2017 13:43:47 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34616 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754333AbdCGSnn (ORCPT ); Tue, 7 Mar 2017 13:43:43 -0500 From: Cheah Kok Cheong To: abbotti@mev.co.uk, hsweeten@visionengravers.com, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org, Cheah Kok Cheong Subject: [PATCH v2 2/2] Staging: comedi: comedi_fops: Fix "out of minor numbers for board device files" Date: Wed, 8 Mar 2017 02:13:59 +0800 Message-Id: <39526ad9c3b52a23acfe4cbe39472847f19ba456.1488908538.git.thrust73@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2141 Lines: 55 If comedi module is loaded with the following max allowed parameter [comedi_num_legacy_minors=48], subsequent loading of an auto-configured device will fail at auto-configuration. If there's no fall back in place then module loading will fail. In this case, a default to auto-configure comedi_test module failed to auto-configure with the following messages. It loaded but fell back to unconfigured mode. comedi_test comedi_testd: ran out of minor numbers for board device files comedi_test comedi_testd: driver 'comedi_test' could not create device. comedi_test: unable to auto-configure device This is due to changes in commit 38b9722a4414 ("staging: comedi: avoid releasing legacy minors automatically") which will not allocate a minor number when comedi_num_legacy_minors equals COMEDI_NUM_BOARD_MINORS. COMEDI_NUM_BOARD_MINORS is defined to be 0x30 which is 48. This goes for a simple fix which limit comedi_num_legacy_minors to 47 instead of tinkering with comedi_alloc_board_minor() and comedi_release_hardware_device(). Fix: commit 38b9722a4414 ("staging: comedi: avoid releasing legacy minors automatically") Signed-off-by: Cheah Kok Cheong --- V2: -Amend commit log to specify that comedi_test module failed to auto-configure and fell back to unconfigured mode. For other devices with no fall back, module loading will fail. drivers/staging/comedi/comedi_fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 354d264..339854f 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2857,9 +2857,9 @@ static int __init comedi_init(void) pr_info("version " COMEDI_RELEASE " - http://www.comedi.org\n"); - if (comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) { + if (comedi_num_legacy_minors >= COMEDI_NUM_BOARD_MINORS) { pr_err("invalid value for module parameter \"comedi_num_legacy_minors\". Valid values are 0 through %i.\n", - COMEDI_NUM_BOARD_MINORS); + COMEDI_NUM_BOARD_MINORS - 1); return -EINVAL; } -- 2.7.4