linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Another small set of cleanups for floppy driver
@ 2021-04-16  8:34 Denis Efremov
  2021-04-16  8:34 ` [PATCH 1/5] floppy: cleanups: remove trailing whitespaces Denis Efremov
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Denis Efremov @ 2021-04-16  8:34 UTC (permalink / raw)
  To: linux-block; +Cc: Denis Efremov, linux-kernel

Just a couple of patches to make checkpatch.pl a bit more happy.
All these patches preserve original semantics of the code and only
memset(), memcpy() patches change binary code.

Denis Efremov (5):
  floppy: cleanups: remove trailing whitespaces
  floppy: cleanups: use ST0 as reply_buffer index 0
  floppy: cleanups: use memset() to zero reply_buffer
  floppy: cleanups: use memcpy() to copy reply_buffer
  floppy: cleanups: remove FLOPPY_SILENT_DCL_CLEAR undef

 drivers/block/floppy.c  | 23 +++++++--------------
 include/uapi/linux/fd.h | 46 ++++++++++++++++++++---------------------
 2 files changed, 31 insertions(+), 38 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] floppy: cleanups: remove trailing whitespaces
  2021-04-16  8:34 [PATCH 0/5] Another small set of cleanups for floppy driver Denis Efremov
@ 2021-04-16  8:34 ` Denis Efremov
  2021-04-16  8:34 ` [PATCH 2/5] floppy: cleanups: use ST0 as reply_buffer index 0 Denis Efremov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Denis Efremov @ 2021-04-16  8:34 UTC (permalink / raw)
  To: linux-block; +Cc: Denis Efremov, linux-kernel

Cleanup trailing whitespaces as checkpatch.pl suggests.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 include/uapi/linux/fd.h | 46 ++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/include/uapi/linux/fd.h b/include/uapi/linux/fd.h
index 8b80c63b971c..7022e3413dbc 100644
--- a/include/uapi/linux/fd.h
+++ b/include/uapi/linux/fd.h
@@ -49,11 +49,11 @@ struct floppy_struct {
 #define FDCLRPRM _IO(2, 0x41)
 /* clear user-defined parameters */
 
-#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) 
+#define FDSETPRM _IOW(2, 0x42, struct floppy_struct)
 #define FDSETMEDIAPRM FDSETPRM
 /* set user-defined parameters for current media */
 
-#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) 
+#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)
 #define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
 #define FDDEFMEDIAPRM FDDEFPRM
 #define FDGETMEDIAPRM FDGETPRM
@@ -65,7 +65,7 @@ struct floppy_struct {
 /* issue/don't issue kernel messages on media type change */
 
 
-/* 
+/*
  * Formatting (obsolete)
  */
 #define FD_FILL_BYTE 0xF6 /* format fill byte. */
@@ -126,13 +126,13 @@ typedef char floppy_drive_name[16];
  */
 struct floppy_drive_params {
 	signed char cmos;		/* CMOS type */
-	
-	/* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms 
+
+	/* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms
 	 * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA).
 	 */
 	unsigned long max_dtr;		/* Step rate, usec */
 	unsigned long hlt;     		/* Head load/settle time, msec */
-	unsigned long hut;     		/* Head unload time (remnant of 
+	unsigned long hut;     		/* Head unload time (remnant of
 					 * 8" drives) */
 	unsigned long srt;     		/* Step rate, usec */
 
@@ -145,12 +145,12 @@ struct floppy_drive_params {
 	unsigned char rps;		/* rotations per second */
 	unsigned char tracks;		/* maximum number of tracks */
 	unsigned long timeout;		/* timeout for interrupt requests */
-	
-	unsigned char interleave_sect;	/* if there are more sectors, use 
+
+	unsigned char interleave_sect;	/* if there are more sectors, use
 					 * interleave */
-	
+
 	struct floppy_max_errors max_errors;
-	
+
 	char flags;			/* various flags, including ftd_msg */
 /*
  * Announce successful media type detection and media information loss after
@@ -162,7 +162,7 @@ struct floppy_drive_params {
 #define FD_BROKEN_DCL 0x20
 #define FD_DEBUG 0x02
 #define FD_SILENT_DCL_CLEAR 0x4
-#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware 
+#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware
 				considerations */
 
 	char read_track;		/* use readtrack during probing? */
@@ -176,8 +176,8 @@ struct floppy_drive_params {
 #define FD_AUTODETECT_SIZE 8
 
 	short autodetect[FD_AUTODETECT_SIZE]; /* autodetected formats */
-	
-	int checkfreq; /* how often should the drive be checked for disk 
+
+	int checkfreq; /* how often should the drive be checked for disk
 			* changes */
 	int native_format; /* native format of this drive */
 };
@@ -225,13 +225,13 @@ struct floppy_drive_struct {
  * decremented after each probe.
  */
 	int keep_data;
-	
+
 	/* Prevent "aliased" accesses. */
 	int fd_ref;
 	int fd_device;
-	unsigned long last_checked; /* when was the drive last checked for a disk 
+	unsigned long last_checked; /* when was the drive last checked for a disk
 			   * change? */
-	
+
 	char *dmabuf;
 	int bufblocks;
 };
@@ -255,7 +255,7 @@ enum reset_mode {
 /*
  * FDC state
  */
-struct floppy_fdc_state {	
+struct floppy_fdc_state {
 	int spec1;		/* spec1 value last used */
 	int spec2;		/* spec2 value last used */
 	int dtr;
@@ -302,16 +302,16 @@ struct floppy_write_errors {
 	 * to the user process are not counted.
 	 */
 
-	unsigned int write_errors;  /* number of physical write errors 
+	unsigned int write_errors;  /* number of physical write errors
 				     * encountered */
-	
+
 	/* position of first and last write errors */
 	unsigned long first_error_sector;
 	int           first_error_generation;
 	unsigned long last_error_sector;
 	int           last_error_generation;
-	
-	unsigned int badness; /* highest retry count for a read or write 
+
+	unsigned int badness; /* highest retry count for a read or write
 			       * operation */
 };
 
@@ -335,7 +335,7 @@ struct floppy_raw_cmd {
 #define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */
 #define FD_RAW_INTR 8    /* wait for an interrupt */
 #define FD_RAW_SPIN 0x10 /* spin up the disk for this command */
-#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command 
+#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command
 				    * completion */
 #define FD_RAW_NEED_DISK 0x40  /* this command needs a disk to be present */
 #define FD_RAW_NEED_SEEK 0x80  /* this command uses an implied seek (soft) */
@@ -353,7 +353,7 @@ struct floppy_raw_cmd {
 
 	void __user *data;
 	char *kernel_data; /* location of data buffer in the kernel */
-	struct floppy_raw_cmd *next; /* used for chaining of raw cmd's 
+	struct floppy_raw_cmd *next; /* used for chaining of raw cmd's
 				      * within the kernel */
 	long length; /* in: length of dma transfer. out: remaining bytes */
 	long phys_length; /* physical length, if different from dma length */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] floppy: cleanups: use ST0 as reply_buffer index 0
  2021-04-16  8:34 [PATCH 0/5] Another small set of cleanups for floppy driver Denis Efremov
  2021-04-16  8:34 ` [PATCH 1/5] floppy: cleanups: remove trailing whitespaces Denis Efremov
@ 2021-04-16  8:34 ` Denis Efremov
  2021-04-16  8:34 ` [PATCH 3/5] floppy: cleanups: use memset() to zero reply_buffer Denis Efremov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Denis Efremov @ 2021-04-16  8:34 UTC (permalink / raw)
  To: linux-block; +Cc: Denis Efremov, linux-kernel

Use ST0 as 0 index for reply_buffer array. get_fdc_version() is the only
function that uses index 0 directly instead of the ST0 define.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 drivers/block/floppy.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 960e5791d6f5..df5c32900539 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4232,7 +4232,7 @@ static char __init get_fdc_version(int fdc)
 	r = result(fdc);
 	if (r <= 0x00)
 		return FDC_NONE;	/* No FDC present ??? */
-	if ((r == 1) && (reply_buffer[0] == 0x80)) {
+	if ((r == 1) && (reply_buffer[ST0] == 0x80)) {
 		pr_info("FDC %d is an 8272A\n", fdc);
 		return FDC_8272A;	/* 8272a/765 don't know DUMPREGS */
 	}
@@ -4257,12 +4257,12 @@ static char __init get_fdc_version(int fdc)
 
 	output_byte(fdc, FD_UNLOCK);
 	r = result(fdc);
-	if ((r == 1) && (reply_buffer[0] == 0x80)) {
+	if ((r == 1) && (reply_buffer[ST0] == 0x80)) {
 		pr_info("FDC %d is a pre-1991 82077\n", fdc);
 		return FDC_82077_ORIG;	/* Pre-1991 82077, doesn't know
 					 * LOCK/UNLOCK */
 	}
-	if ((r != 1) || (reply_buffer[0] != 0x00)) {
+	if ((r != 1) || (reply_buffer[ST0] != 0x00)) {
 		pr_info("FDC %d init: UNLOCK: unexpected return of %d bytes.\n",
 			fdc, r);
 		return FDC_UNKNOWN;
@@ -4274,11 +4274,11 @@ static char __init get_fdc_version(int fdc)
 			fdc, r);
 		return FDC_UNKNOWN;
 	}
-	if (reply_buffer[0] == 0x80) {
+	if (reply_buffer[ST0] == 0x80) {
 		pr_info("FDC %d is a post-1991 82077\n", fdc);
 		return FDC_82077;	/* Revised 82077AA passes all the tests */
 	}
-	switch (reply_buffer[0] >> 5) {
+	switch (reply_buffer[ST0] >> 5) {
 	case 0x0:
 		/* Either a 82078-1 or a 82078SL running at 5Volt */
 		pr_info("FDC %d is an 82078.\n", fdc);
@@ -4294,7 +4294,7 @@ static char __init get_fdc_version(int fdc)
 		return FDC_87306;
 	default:
 		pr_info("FDC %d init: 82078 variant with unknown PARTID=%d.\n",
-			fdc, reply_buffer[0] >> 5);
+			fdc, reply_buffer[ST0] >> 5);
 		return FDC_82078_UNKN;
 	}
 }				/* get_fdc_version */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] floppy: cleanups: use memset() to zero reply_buffer
  2021-04-16  8:34 [PATCH 0/5] Another small set of cleanups for floppy driver Denis Efremov
  2021-04-16  8:34 ` [PATCH 1/5] floppy: cleanups: remove trailing whitespaces Denis Efremov
  2021-04-16  8:34 ` [PATCH 2/5] floppy: cleanups: use ST0 as reply_buffer index 0 Denis Efremov
@ 2021-04-16  8:34 ` Denis Efremov
  2021-04-16  8:34 ` [PATCH 4/5] floppy: cleanups: use memcpy() to copy reply_buffer Denis Efremov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Denis Efremov @ 2021-04-16  8:34 UTC (permalink / raw)
  To: linux-block; +Cc: Denis Efremov, linux-kernel

Use memset() to zero reply buffer in raw_cmd_copyin() instead
of a for loop.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 drivers/block/floppy.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index df5c32900539..c58b0b079afc 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3090,7 +3090,6 @@ static int raw_cmd_copyin(int cmd, void __user *param,
 {
 	struct floppy_raw_cmd *ptr;
 	int ret;
-	int i;
 
 	*rcmd = NULL;
 
@@ -3109,8 +3108,7 @@ static int raw_cmd_copyin(int cmd, void __user *param,
 	if (ptr->cmd_count > FD_RAW_CMD_FULLSIZE)
 		return -EINVAL;
 
-	for (i = 0; i < FD_RAW_REPLY_SIZE; i++)
-		ptr->reply[i] = 0;
+	memset(ptr->reply, 0, FD_RAW_REPLY_SIZE);
 	ptr->resultcode = 0;
 
 	if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] floppy: cleanups: use memcpy() to copy reply_buffer
  2021-04-16  8:34 [PATCH 0/5] Another small set of cleanups for floppy driver Denis Efremov
                   ` (2 preceding siblings ...)
  2021-04-16  8:34 ` [PATCH 3/5] floppy: cleanups: use memset() to zero reply_buffer Denis Efremov
@ 2021-04-16  8:34 ` Denis Efremov
  2021-04-16  8:34 ` [PATCH 5/5] floppy: cleanups: remove FLOPPY_SILENT_DCL_CLEAR undef Denis Efremov
  2021-04-16 12:05 ` [PATCH 0/5] Another small set of cleanups for floppy driver Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Denis Efremov @ 2021-04-16  8:34 UTC (permalink / raw)
  To: linux-block; +Cc: Denis Efremov, linux-kernel

Use memcpy() in raw_cmd_done() to copy reply_buffer instead
of a for loop.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 drivers/block/floppy.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index c58b0b079afc..c584657bacab 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -2988,8 +2988,6 @@ static const char *drive_name(int type, int drive)
 /* raw commands */
 static void raw_cmd_done(int flag)
 {
-	int i;
-
 	if (!flag) {
 		raw_cmd->flags |= FD_RAW_FAILURE;
 		raw_cmd->flags |= FD_RAW_HARDFAILURE;
@@ -2997,8 +2995,7 @@ static void raw_cmd_done(int flag)
 		raw_cmd->reply_count = inr;
 		if (raw_cmd->reply_count > FD_RAW_REPLY_SIZE)
 			raw_cmd->reply_count = 0;
-		for (i = 0; i < raw_cmd->reply_count; i++)
-			raw_cmd->reply[i] = reply_buffer[i];
+		memcpy(raw_cmd->reply, reply_buffer, raw_cmd->reply_count);
 
 		if (raw_cmd->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
 			unsigned long flags;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] floppy: cleanups: remove FLOPPY_SILENT_DCL_CLEAR undef
  2021-04-16  8:34 [PATCH 0/5] Another small set of cleanups for floppy driver Denis Efremov
                   ` (3 preceding siblings ...)
  2021-04-16  8:34 ` [PATCH 4/5] floppy: cleanups: use memcpy() to copy reply_buffer Denis Efremov
@ 2021-04-16  8:34 ` Denis Efremov
  2021-04-16 12:05 ` [PATCH 0/5] Another small set of cleanups for floppy driver Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Denis Efremov @ 2021-04-16  8:34 UTC (permalink / raw)
  To: linux-block; +Cc: Denis Efremov, linux-kernel

FLOPPY_SILENT_DCL_CLEAR is not defined anywhere and comes from pre-git
era. Just drop this undef. There is FD_SILENT_DCL_CLEAR which is really
used.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 drivers/block/floppy.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index c584657bacab..678ea45f2388 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -145,8 +145,6 @@
  * Better audit of register_blkdev.
  */
 
-#undef  FLOPPY_SILENT_DCL_CLEAR
-
 #define REALLY_SLOW_IO
 
 #define DEBUGT 2
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] Another small set of cleanups for floppy driver
  2021-04-16  8:34 [PATCH 0/5] Another small set of cleanups for floppy driver Denis Efremov
                   ` (4 preceding siblings ...)
  2021-04-16  8:34 ` [PATCH 5/5] floppy: cleanups: remove FLOPPY_SILENT_DCL_CLEAR undef Denis Efremov
@ 2021-04-16 12:05 ` Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2021-04-16 12:05 UTC (permalink / raw)
  To: Denis Efremov, linux-block; +Cc: linux-kernel

On 4/16/21 2:34 AM, Denis Efremov wrote:
> Just a couple of patches to make checkpatch.pl a bit more happy.
> All these patches preserve original semantics of the code and only
> memset(), memcpy() patches change binary code.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-16 12:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16  8:34 [PATCH 0/5] Another small set of cleanups for floppy driver Denis Efremov
2021-04-16  8:34 ` [PATCH 1/5] floppy: cleanups: remove trailing whitespaces Denis Efremov
2021-04-16  8:34 ` [PATCH 2/5] floppy: cleanups: use ST0 as reply_buffer index 0 Denis Efremov
2021-04-16  8:34 ` [PATCH 3/5] floppy: cleanups: use memset() to zero reply_buffer Denis Efremov
2021-04-16  8:34 ` [PATCH 4/5] floppy: cleanups: use memcpy() to copy reply_buffer Denis Efremov
2021-04-16  8:34 ` [PATCH 5/5] floppy: cleanups: remove FLOPPY_SILENT_DCL_CLEAR undef Denis Efremov
2021-04-16 12:05 ` [PATCH 0/5] Another small set of cleanups for floppy driver Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).