Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp686345ybz; Fri, 1 May 2020 06:48:52 -0700 (PDT) X-Google-Smtp-Source: APiQypL1x3BxSk6W8ZhB/0l7oidXy1SPZsHRMLV6DZQthVMJPrWczom4d+rp8DO72JlxUPAoqe1S X-Received: by 2002:a17:906:68cf:: with SMTP id y15mr3122975ejr.260.1588340932103; Fri, 01 May 2020 06:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588340932; cv=none; d=google.com; s=arc-20160816; b=wzN9ZeN7LS4abS2eHWd4gCTo1sKWT6RhOyIogSptcSfz9bkQDWCnuwvYZJljFcl3uK xvNIupyMcCNH2MOTe8+kMTnejHH45HxeWuj3CVzOqKvjQZiEHAvc1RyHmokPgkk7peWn 6SztFwGt6Z3OPhTo2FOcUaysQQO99VgIs7nsun4CIgrMBGXVwmXfxtXEnnphmAhMJWP6 cvn3Pio/ncTaCcInZrDftziZfzNiAYWhRoKeAB56XXk69Sww9kuAAktHfN2RohgNpidC ISo/6/3QoR0ZGIA6xSz0zc1lL2Q/hZT7hZ3qXyPhJthyt/MUfFt7+4fyIrpkmEj4rMWW PfPg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UjJIbG5PhVX5vmhqPNitT7lQ30lLq2zeuGUdDd0kBno=; b=MK5nSM3toAFNVwTigoxA5G7yhD3zOkJTX84cfv9/Efx747onxwW8cBfhctS2LxoFGn eg+BBaJCYefC7pFl/pWmNff56B4JPLmRse1NMD8/n1a+LbczKq+RWf5t63u0Lb/xvwPq yYaKqnG773TACKGyM6lX8Lcw3oavyGH9CXtBXBcKLCSOVz+Q5nTpzUBXwmow0YnTj/UJ oRajO+i2WHgNeK55wWugiXMJlgZg807Bwn3sFimCBRNbU1s0Pfqn0Z+BhBnlJ2UYH9Ty MXuhrzFuOzRsuYc1++sxRGNCeheqq5Q0eyqjrp3uCG/04ukfF2zKwkq43OlGWwUOYfCJ 3LDg== 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 g14si1809031eje.287.2020.05.01.06.48.29; Fri, 01 May 2020 06:48:52 -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 S1731586AbgEANrM (ORCPT + 99 others); Fri, 1 May 2020 09:47:12 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:38526 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730317AbgEANpK (ORCPT ); Fri, 1 May 2020 09:45:10 -0400 Received: by mail-lf1-f68.google.com with SMTP id l11so3898488lfc.5; Fri, 01 May 2020 06:45:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UjJIbG5PhVX5vmhqPNitT7lQ30lLq2zeuGUdDd0kBno=; b=ii/dZOXMNrZNV8QMGycWL5eYUUGhoDWQyGJfFF+Md4PHlDjqs9IoKTxeBSoxv1OB3D M/rWnP2+RWC/UswRA8h6ETXtWD77Ez3yy3j4GaslGVAaFof3LTG11tSvnIpJdoyjGdeS JoX0rFuw/F8/WOSXqAjolvu7g2cYU5hyW2V2j2N76LQqv+6DwDqnUsTJLqoDP+e3q8Iw FHMMwr/AhAZLQCjj8ZtRs9NfC+Vw5laAUxUngoTUFfO5VrtzGTO9joaryPpJx6Coxqa7 CmyqiywphXgIoqK/CZM9ljSaYGXvjRqQLFpmO8Jc2F7DQX6cntrkjZjkeza48Fy7Uhju 2mMg== X-Gm-Message-State: AGi0PubXipHgTwZZ/C/nmzYIRCK3vPp9qHKgsJVbz3YR3Tom2n4qurVG iyJecKwZ9vTgM4u/vgTrVDtc1W+LdaU= X-Received: by 2002:a19:42c3:: with SMTP id p186mr2590791lfa.194.1588340707226; Fri, 01 May 2020 06:45:07 -0700 (PDT) Received: from localhost.localdomain ([213.87.150.177]) by smtp.googlemail.com with ESMTPSA id b2sm2269194lfi.14.2020.05.01.06.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 06:45:06 -0700 (PDT) From: Denis Efremov To: linux-block@vger.kernel.org Cc: Denis Efremov , Willy Tarreau , Christoph Hellwig , Joe Perches , linux-kernel@vger.kernel.org Subject: [PATCH v3 2/4] floppy: add FD_AUTODETECT_SIZE define for struct floppy_drive_params Date: Fri, 1 May 2020 16:44:14 +0300 Message-Id: <20200501134416.72248-3-efremov@linux.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200501134416.72248-1-efremov@linux.com> References: <20200501134416.72248-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use FD_AUTODETECT_SIZE for autodetect buffer size in struct floppy_drive_params instead of a magic number. Signed-off-by: Denis Efremov --- drivers/block/floppy.c | 9 +++++---- include/uapi/linux/fd.h | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 3ab6e804b5ec..b82b3d38b834 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -2073,7 +2073,8 @@ static int next_valid_format(int drive) probed_format = drive_state[drive].probed_format; while (1) { - if (probed_format >= 8 || !drive_params[drive].autodetect[probed_format]) { + if (probed_format >= FD_AUTODETECT_SIZE || + !drive_params[drive].autodetect[probed_format]) { drive_state[drive].probed_format = 0; return 1; } @@ -3442,13 +3443,13 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo) return 0; } -static bool valid_floppy_drive_params(const short autodetect[8], +static bool valid_floppy_drive_params(const short autodetect[FD_AUTODETECT_SIZE], int native_format) { size_t floppy_type_size = ARRAY_SIZE(floppy_type); size_t i = 0; - for (i = 0; i < 8; ++i) { + for (i = 0; i < FD_AUTODETECT_SIZE; ++i) { if (autodetect[i] < 0 || autodetect[i] >= floppy_type_size) return false; @@ -3673,7 +3674,7 @@ struct compat_floppy_drive_params { struct floppy_max_errors max_errors; char flags; char read_track; - short autodetect[8]; + short autodetect[FD_AUTODETECT_SIZE]; compat_int_t checkfreq; compat_int_t native_format; }; diff --git a/include/uapi/linux/fd.h b/include/uapi/linux/fd.h index 90fb94712c41..3f6b7be4c096 100644 --- a/include/uapi/linux/fd.h +++ b/include/uapi/linux/fd.h @@ -172,7 +172,10 @@ struct floppy_drive_params { * used in succession to try to read the disk. If the FDC cannot lock onto * the disk, the next format is tried. This uses the variable 'probing'. */ - short autodetect[8]; /* autodetected formats */ + +#define FD_AUTODETECT_SIZE 8 + + short autodetect[FD_AUTODETECT_SIZE]; /* autodetected formats */ int checkfreq; /* how often should the drive be checked for disk * changes */ -- 2.25.3