Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1871350ybz; Sun, 26 Apr 2020 06:10:06 -0700 (PDT) X-Google-Smtp-Source: APiQypIcGzTeXhgkNt+iXriF8h3R1Q+nMIpFGLdtpAjUH5UUtZQkOgZ7w7S05loLGwVLOk+drzqt X-Received: by 2002:a17:906:f1c3:: with SMTP id gx3mr15533512ejb.25.1587906606272; Sun, 26 Apr 2020 06:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587906606; cv=none; d=google.com; s=arc-20160816; b=aQ15LUSKJHQfwFU6hQxMeQ3QFIWV3NVCOdQVSnQLGFd35rnIKRcaobmQ/XPkGtpkLK hhGN83CCh+Nazg/SVTV71ienlLvKu59VgUUFCeX2oO/68Fgp0PqogFC9xhMKasxv+v4J 8tJUJijNF1VKY3KGGqO41BWEkKDH+5ACmuNucHsBxGvcPQa3kQqdszjS7Nh0AqLNgYWI JGyCxcBfBthsvIeqCXnsKKI3s3og1DlDyB/w0R79xb3NOlpaBbRi1SXdcx+qbVwCKmsy gwg366naLsbYw+kSvZ7whVWPe+yEDzMZjBSnrCobGMU21zBC+5R2yTLsr+YCp9/w7Scq YR1Q== 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=HT2BCSWgzxUdrlLCBm0qqAESIN+EGNUthAVxzQxAcj8=; b=wIg1voL+OKtn0nCTp47LX2Birx6jBhk6S93pYPKi8QSrSNrOGn5GagtwqwUTUGHg7U LmGTq8VJh1+xPVVUq7za7wAKi7f05gcMeN7Xe4XLAkuqJDlOcR4h9uFe0kYQcF/vkEhD EZehK3CP/ArUnk2HvWWG770hr4vwi8/F3loJSewXNUYHaW05iegRzgeaZ8gFsRr80oAU cnhyfE6Xqlc+bbYDkWkMBhD/M9B9IBwwxsnJ73LYPYJbek1ZTMXm54ZUX9TTn4nsi7/O tUMEOPKZtaYpOsj6lMrcJJtbYOv/UnO3xOYL/iY5qOhbJSGEER/2K5tnIVKv2yVmOBf5 Ww2g== 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 v22si6916995ejw.454.2020.04.26.06.09.43; Sun, 26 Apr 2020 06:10:06 -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 S1726191AbgDZNIT (ORCPT + 99 others); Sun, 26 Apr 2020 09:08:19 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:39313 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgDZNIS (ORCPT ); Sun, 26 Apr 2020 09:08:18 -0400 Received: by mail-lf1-f66.google.com with SMTP id m2so11493196lfo.6; Sun, 26 Apr 2020 06:08:16 -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=HT2BCSWgzxUdrlLCBm0qqAESIN+EGNUthAVxzQxAcj8=; b=Js4PY6eA7BqbPLWqtiWL5cninSkIY/HZhSwEJNH3rYGAZaAboOgalP9GAhjA+6epNI vYbRPQD4Yt5K8IKYMzQ2t7GI3ua8NFKDkvyf2TOzOdu68FjsOqTUyZ7C4cNpanBZPkcD Alzjg7sSDACC8gSxSXhm2cJ7FXZFS8E0hJIZ17IOWSmqEohXxKNfconwMJ0daiOgWrTB xmiqRgovOT++cI1n/QjxmLATy+S4n5MHG3eOJQwlKfZ1LNc6PEclkQCSaT9jJjou+/kX FZd7uizqe9iWI/c5MDhNTXNe564ihV6Cj69a0VNjKaI57+9H+nNMl8TiIwdfJfZKKF9E fhUg== X-Gm-Message-State: AGi0PubHftkHMv/LuY2+KsYdtuXeOzHq6Xz+/XuPe/dVc9NqJ2ib8JxN 5vQtzxUg+sp1N6ZgGl9y5bEeZuinSFg= X-Received: by 2002:ac2:551e:: with SMTP id j30mr12701110lfk.179.1587906495848; Sun, 26 Apr 2020 06:08:15 -0700 (PDT) Received: from localhost.localdomain ([213.87.147.211]) by smtp.googlemail.com with ESMTPSA id l8sm7983371ljo.5.2020.04.26.06.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 06:08:15 -0700 (PDT) From: Denis Efremov To: linux-block@vger.kernel.org Cc: Denis Efremov , Willy Tarreau , Christoph Hellwig , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] floppy: add FD_AUTODETECT_SIZE define for struct floppy_drive_params Date: Sun, 26 Apr 2020 16:07:26 +0300 Message-Id: <20200426130728.63399-2-efremov@linux.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200426130728.63399-1-efremov@linux.com> References: <20200426130728.63399-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 2817170dd403..ac2023c757e3 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -2076,7 +2076,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; } @@ -3445,13 +3446,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; @@ -3676,7 +3677,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