Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp120140ybz; Tue, 21 Apr 2020 05:59:27 -0700 (PDT) X-Google-Smtp-Source: APiQypKHqtyTg8R6LcBFr7ltCYZw0/VuKuivvaxfLng3t4UlRHM3iH4hwYQmcURCTPop4pMnTOAN X-Received: by 2002:a50:d981:: with SMTP id w1mr18326596edj.275.1587473967037; Tue, 21 Apr 2020 05:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587473967; cv=none; d=google.com; s=arc-20160816; b=0M6t3zLcc+tCcBwUMDXD8chAPE4kUqnZVcVVZPQm+09NSz1oM494D+Dl+6DnI5o0d5 zbku9IxG9tO7O4BMWJZyGlXoN4Q7grky5XioypOORk0gqFs7OvJQoRwXYdR9A+N8eVmL XhgZJoO2q+K7+6jCec8mbymkdA4h4U4YJ04XAllb2S8oWohS5IqydKBtXuP8E+puHzQP Otsdxj/2t4qZJ5yYxLqMRVgkNre9HKlI1BkDR/ZZgDysWB4iCMHmNOAGdV3sz/VeJ/af jjLC6e7RyM7KkqUHbjdk2rw7i4u/MsSzZLCEtr065kpM0t9T0WJavF/nozlY76I58gGf Eliw== 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=EfnTedNe2IUpWuf+EJLADm5FOOxOv1WkovWVN+XtvOM=; b=0GgmvAJiTC8XEVDT1ATpbbZEi/NrARkzTD+8SOKb6qShwmbH+PrD3L0XmHn2614SFs te7vq01GBnrtMMSvKGLPLIUyKM8EMHto9vpf26L1+9j8YgOXMSibbFicygNNBFI/CvsJ T68Kpx0ve6GpZmih7oeeGdvlc0pRlUHKMDHlT2lJCxMh8F4VciFHuAlbt6Aw/YGq9jYe hk6g72sfFVWdKJiR9hxxhSFMN/gEy7Jr0oVr2ASC4m1kDMWEgEna3kZobD4mjYY7MRzA daD7MTqzwtqFhYS+OS/KG2elCm7DTXd67uG4XgLcW0hEhsdup8c1t8zw2hspi1mP6rBZ sBZg== 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 r18si1452772ejj.211.2020.04.21.05.59.03; Tue, 21 Apr 2020 05:59:27 -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 S1728786AbgDUM6B (ORCPT + 99 others); Tue, 21 Apr 2020 08:58:01 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39037 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbgDUM6A (ORCPT ); Tue, 21 Apr 2020 08:58:00 -0400 Received: by mail-lj1-f193.google.com with SMTP id u6so13877273ljl.6; Tue, 21 Apr 2020 05:57:58 -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=EfnTedNe2IUpWuf+EJLADm5FOOxOv1WkovWVN+XtvOM=; b=AfnPk8bmCVXfbdt2Y41Zj1HmQQEebqhMn9XTIAZMPBsYEueK3ioFuSxVZiP68r7vKW 4nl1h6fvLbK1R1+W9izqzENkYzbmm5mNw/QaX3OsJPAilG30kOTLbkYfGGRuZJav3M0T sQL2qUwuQgubioHFGLu2ZLz06EfBB3ROItjAlFl0Mgo1wmO52v1f7qM9Q5lZVB63u1wZ dRSw9KknPPGyjOmhCNM1k1M3WnZ5jLBOGtM8SNr/yPdVn82u6ZIT/UELfy/fzo7Xe12/ y8XKFmpwIHNs5ummN4mbsB8L4ZVFvL+mwzdb7knlY9kb/k5hhe3BFAeW5reTh5zINyIq yYDQ== X-Gm-Message-State: AGi0PuaO9K7o+1X8fb7miTGx8KoQzrOSBWHHZtQF/M6kRkwqmONmQWfg Db5F5E0jXixZOH5VuoO4Jav73JfwD0A= X-Received: by 2002:a2e:b00a:: with SMTP id y10mr12371417ljk.158.1587473877635; Tue, 21 Apr 2020 05:57:57 -0700 (PDT) Received: from localhost.localdomain ([213.87.162.215]) by smtp.googlemail.com with ESMTPSA id z7sm1902268ljc.17.2020.04.21.05.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 05:57:57 -0700 (PDT) From: Denis Efremov To: linux-block@vger.kernel.org Cc: Denis Efremov , Willy Tarreau , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] floppy: add FD_AUTODETECT_SIZE define for struct floppy_drive_params Date: Tue, 21 Apr 2020 15:57:20 +0300 Message-Id: <20200421125722.58959-2-efremov@linux.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200421125722.58959-1-efremov@linux.com> References: <20200421125722.58959-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..f5cb0aa8cebc 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