Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0571c7a4 authored by Borislav Petkov's avatar Borislav Petkov Committed by Bartlomiej Zolnierkiewicz
Browse files

ide-floppy: fix most of the remaining checkpatch.pl issues



such as
ERROR: switch and case should be at the same indent
ERROR: need spaces around that '=' (ctx:VxV)
ERROR: trailing statements should be on next line
WARNING: no space between function name and open parenthesis '('
WARNING: printk() should include KERN_ facility level
ERROR: That open brace { should be on the previous line
ERROR: use tabs not spaces
ERROR: do not use assignment in if condition
WARNING: braces {} are not necessary for single statement blocks
ERROR: need space after that ',' (ctx:VxV)
WARNING: line over 80 characters
ERROR: do not use assignment in if condition
...
and so on.

Signed-off-by: default avatarBorislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 6e5fa7b8
Loading
Loading
Loading
Loading
+160 −195
Original line number Diff line number Diff line
@@ -4,9 +4,7 @@
 * Copyright (C) 1996-1999  Gadi Oxman <gadio@netvision.net.il>
 * Copyright (C) 2000-2002  Paul Bristow <paul@paulbristow.net>
 * Copyright (C) 2005       Bartlomiej Zolnierkiewicz
 */

/*
 *
 * The driver currently doesn't have any fancy features, just the bare
 * minimum read/write support.
 *
@@ -61,47 +59,46 @@
#endif


/*
 *	Some drives require a longer irq timeout.
 */
/* Some drives require a longer irq timeout. */
#define IDEFLOPPY_WAIT_CMD		(5 * WAIT_CMD)

/*
 *	After each failed packet command we issue a request sense command
 *	and retry the packet command IDEFLOPPY_MAX_PC_RETRIES times.
 * After each failed packet command we issue a request sense command and retry
 * the packet command IDEFLOPPY_MAX_PC_RETRIES times.
 */
#define IDEFLOPPY_MAX_PC_RETRIES	3

/*
 *	With each packet command, we allocate a buffer of
 *	IDEFLOPPY_PC_BUFFER_SIZE bytes.
 * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE
 * bytes.
 */
#define IDEFLOPPY_PC_BUFFER_SIZE	256

/*
 *	In various places in the driver, we need to allocate storage
 *	for packet commands and requests, which will remain valid while
 *	we leave the driver to wait for an interrupt or a timeout event.
 * In various places in the driver, we need to allocate storage for packet
 * commands and requests, which will remain valid while	we leave the driver to
 * wait for an interrupt or a timeout event.
 */
#define IDEFLOPPY_PC_STACK		(10 + IDEFLOPPY_MAX_PC_RETRIES)

/*
 *	Our view of a packet command.
 */
typedef struct idefloppy_packet_command_s {
	u8 c[12];				/* Actual packet bytes */
	int retries;				/* On each retry, we increment retries */
	int retries;				/* On each retry, we increment
						   retries */
	int error;				/* Error code */
	int request_transfer;			/* Bytes to transfer */
	int actually_transferred;		/* Bytes actually transferred */
	int buffer_size;			/* Size of our data buffer */
	int b_count;				/* Missing/Available data on the current buffer */
	int b_count;				/* Missing/Available data on
						   the current buffer */
	struct request *rq;			/* The corresponding request */
	u8 *buffer;				/* Data buffer */
	u8 *current_position;			/* Pointer into the above buffer */
	void (*callback) (ide_drive_t *);	/* Called when this packet command is completed */
	u8 *current_position;			/* Pointer into above buffer */
	void (*callback) (ide_drive_t *);	/* Called when this packet
						   command is completed */
	u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE];	/* Temporary buffer */
	unsigned long flags;			/* Status/Action bit flags: long for set_bit */
	unsigned long flags;			/* Status/Action bit flags: long
						   for set_bit */
} idefloppy_pc_t;

/* Packet command flag bits. */
@@ -125,9 +122,9 @@ enum {
#define CAPACITY_NO_CARTRIDGE	0x03

/*
 *	Most of our global data which we need to save even as we leave the
 *	driver due to an interrupt or a timer event is stored in a variable
 *	of type idefloppy_floppy_t, defined below.
 * Most of our global data which we need to save even as we leave the driver
 * due to an interrupt or a timer event is stored in a variable of type
 * idefloppy_floppy_t, defined below.
 */
typedef struct ide_floppy_obj {
	ide_drive_t	*drive;
@@ -148,17 +145,13 @@ typedef struct ide_floppy_obj {
	/* We implement a circular array */
	int rq_stack_index;

	/*
	 *	Last error information
	 */
	/* Last error information */
	u8 sense_key, asc, ascq;
	/* delay this long before sending packet command */
	u8 ticks;
	int progress_indication;

	/*
	 *	Device information
	 */
	/* Device information */
	/* Current format */
	int blocks, block_size, bs_factor;
	/* Last format capacity descriptor */
@@ -189,32 +182,24 @@ enum {
	IDEFLOPPY_FLAG_ZIP_DRIVE		= (1 << 4),
};

/*
 *	Defines for the mode sense command
 */
/* Defines for the MODE SENSE command */
#define MODE_SENSE_CURRENT		0x00
#define MODE_SENSE_CHANGEABLE		0x01
#define MODE_SENSE_DEFAULT		0x02
#define MODE_SENSE_SAVED		0x03

/*
 *	IOCTLs used in low-level formatting.
 */

/* IOCTLs used in low-level formatting. */
#define	IDEFLOPPY_IOCTL_FORMAT_SUPPORTED	0x4600
#define	IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY	0x4601
#define	IDEFLOPPY_IOCTL_FORMAT_START		0x4602
#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS	0x4603

/*
 *	Error codes which are returned in rq->errors to the higher part
 *	of the driver.
 */
/* Error code returned in rq->errors to the higher part of the driver. */
#define	IDEFLOPPY_ERROR_GENERAL		101

/*
 *	The following is used to format the general configuration word of
 *	the ATAPI IDENTIFY DEVICE command.
 * The following is used to format the general configuration word of the
 * ATAPI IDENTIFY DEVICE command.
 */
struct idefloppy_id_gcw {
#if defined(__LITTLE_ENDIAN_BITFIELD)
@@ -291,10 +276,8 @@ static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount)


/*
 *	idefloppy_do_end_request is used to finish servicing a request.
 *
 *	For read/write requests, we will call ide_end_request to pass to the
 *	next buffer.
 * Used to finish servicing a request. For read/write requests, we will call
 * ide_end_request to pass to the next buffer.
 */
static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs)
{
@@ -376,11 +359,12 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc)
}

/*
 *	idefloppy_queue_pc_head generates a new packet command request in front
 *	of the request queue, before the current request, so that it will be
 *	processed immediately, on the next pass through the driver.
 * Generate a new packet command request in front of the request queue, before
 * the current request so that it will be processed immediately, on the next
 * pass through the driver.
 */
static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struct request *rq)
static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc,
		struct request *rq)
{
	struct ide_floppy_obj *floppy = drive->driver_data;

@@ -445,9 +429,7 @@ static void idefloppy_request_sense_callback(ide_drive_t *drive)
	}
}

/*
 *	General packet command callback function.
 */
/* General packet command callback function. */
static void idefloppy_pc_callback(ide_drive_t *drive)
{
	idefloppy_floppy_t *floppy = drive->driver_data;
@@ -457,9 +439,6 @@ static void idefloppy_pc_callback (ide_drive_t *drive)
	idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0);
}

/*
 *	idefloppy_init_pc initializes a packet command.
 */
static void idefloppy_init_pc(idefloppy_pc_t *pc)
{
	memset(pc->c, 0, 12);
@@ -481,9 +460,8 @@ static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc)
}

/*
 *	idefloppy_retry_pc is called when an error was detected during the
 *	last packet command. We queue a request sense packet command in
 *	the head of the request list.
 * Called when an error was detected during the last packet command. We queue a
 * request sense packet command in the head of the request list.
 */
static void idefloppy_retry_pc(ide_drive_t *drive)
{
@@ -528,7 +506,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
	/* Clear the interrupt */
	stat = drive->hwif->INB(IDE_STATUS_REG);

	if ((stat & DRQ_STAT) == 0) {		/* No more interrupts */
	/* No more interrupts */
	if ((stat & DRQ_STAT) == 0) {
		debug_log("Packet command completed, %d bytes transferred\n",
				pc->actually_transferred);
		pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
@@ -655,16 +634,14 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive)


/*
 * What we have here is a classic case of a top half / bottom half
 * interrupt service routine. In interrupt mode, the device sends
 * an interrupt to signal it's ready to receive a packet. However,
 * we need to delay about 2-3 ticks before issuing the packet or we
 * gets in trouble.
 * What we have here is a classic case of a top half / bottom half interrupt
 * service routine. In interrupt mode, the device sends an interrupt to signal
 * that it is ready to receive a packet. However, we need to delay about 2-3
 * ticks before issuing the packet or we gets in trouble.
 *
 * So, follow carefully. transfer_pc1 is called as an interrupt (or
 * directly). In either case, when the device says it's ready for a 
 * packet, we schedule the packet transfer to occur about 2-3 ticks
 * later in transfer_pc2.
 * So, follow carefully. transfer_pc1 is called as an interrupt (or directly).
 * In either case, when the device says it's ready for a packet, we schedule
 * the packet transfer to occur about 2-3 ticks later in transfer_pc2.
 */
static int idefloppy_transfer_pc2(ide_drive_t *drive)
{
@@ -702,10 +679,8 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive)
	 * used until after the packet is moved in about 50 msec.
	 */

	ide_set_handler(drive, 
	  &idefloppy_pc_intr, 		/* service routine for packet command */
	  floppy->ticks,		/* wait this long before "failing" */
	  &idefloppy_transfer_pc2);	/* fail == transfer_pc2 */
	ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks,
			&idefloppy_transfer_pc2);
	return ide_started;
}

@@ -725,10 +700,8 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy,

}

/*
 *	Issue a packet command
 */
static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc)
static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
		idefloppy_pc_t *pc)
{
	idefloppy_floppy_t *floppy = drive->driver_data;
	ide_hwif_t *hwif = drive->hwif;
@@ -773,7 +746,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
	ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK |
			   IDE_TFLAG_OUT_DEVICE, bcount, dma);

	if (dma) {	/* Begin DMA, if necessary */
	if (dma) {
		/* Begin DMA, if necessary */
		pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
		hwif->dma_start(drive);
	}
@@ -848,10 +822,9 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l,
	pc->flags |= PC_FLAG_WRITING;
}

/*
 *	A mode sense command is used to "sense" floppy parameters.
 */
static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t *pc, u8 page_code, u8 type)
/* A mode sense command is used to "sense" floppy parameters. */
static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code,
		u8 type)
{
	u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */

@@ -914,8 +887,8 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
	pc->flags |= PC_FLAG_DMA_RECOMMENDED;
}

static void
idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq)
static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
		idefloppy_pc_t *pc, struct request *rq)
{
	idefloppy_init_pc(pc);
	pc->callback = &idefloppy_rw_callback;
@@ -934,10 +907,8 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req
	pc->request_transfer = pc->buffer_size = rq->data_len;
}

/*
 *	idefloppy_do_request is our request handling function.	
 */
static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request *rq, sector_t block_s)
static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
		struct request *rq, sector_t block_s)
{
	idefloppy_floppy_t *floppy = drive->driver_data;
	idefloppy_pc_t *pc;
@@ -962,7 +933,7 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
	if (blk_fs_request(rq)) {
		if (((long)rq->sector % floppy->bs_factor) ||
		    (rq->nr_sectors % floppy->bs_factor)) {
			printk("%s: unsupported r/w request size\n",
			printk(KERN_ERR "%s: unsupported r/w request size\n",
					drive->name);
			idefloppy_do_end_request(drive, 0, 0);
			return ide_stopped;
@@ -986,8 +957,8 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
}

/*
 *	idefloppy_queue_pc_tail adds a special packet command request to the
 *	tail of the request queue, and waits for it to be serviced.
 * Add a special packet command request to the tail of the request queue,
 * and wait for it to be serviced.
 */
static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc)
{
@@ -1247,13 +1218,13 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
}

/*
** Get ATAPI_FORMAT_UNIT progress indication.
**
** Userland gives a pointer to an int.  The int is set to a progress
** indicator 0-65536, with 65536=100%.
**
** If the drive does not support format progress indication, we just check
** the dsc bit, and return either 0 or 65536.
 * Get ATAPI_FORMAT_UNIT progress indication.
 *
 * Userland gives a pointer to an int.  The int is set to a progress
 * indicator 0-65536, with 65536=100%.
 *
 * If the drive does not support format progress indication, we just check
 * the dsc bit, and return either 0 or 65536.
 */

static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
@@ -1264,17 +1235,15 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)

	if (floppy->srfp) {
		idefloppy_create_request_sense_cmd(&pc);
		if (idefloppy_queue_pc_tail(drive, &pc)) {
		if (idefloppy_queue_pc_tail(drive, &pc))
			return (-EIO);
		}

		if (floppy->sense_key == 2 &&
		    floppy->asc == 4 &&
		    floppy->ascq == 4) {
		    floppy->ascq == 4)
			progress_indication = floppy->progress_indication;
		}
		/* Else assume format_unit has finished, and we're
		** at 0x10000 */

		/* Else assume format_unit has finished, and we're at 0x10000 */
	} else {
		unsigned long flags;
		u8 stat;
@@ -1291,9 +1260,6 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
	return (0);
}

/*
 *	Return the current floppy capacity.
 */
static sector_t idefloppy_capacity(ide_drive_t *drive)
{
	idefloppy_floppy_t *floppy = drive->driver_data;
@@ -1344,21 +1310,19 @@ static void idefloppy_add_settings(ide_drive_t *drive)
{
	idefloppy_floppy_t *floppy = drive->driver_data;

/*
 *			drive	setting name	read/write	data type	min	max	mul_factor	div_factor	data pointer		set function
 */
	ide_add_setting(drive,	"bios_cyl",	SETTING_RW,	TYPE_INT,	0,	1023,		1,		1,	&drive->bios_cyl,	NULL);
	ide_add_setting(drive,	"bios_head",	SETTING_RW,	TYPE_BYTE,	0,	255,		1,		1,	&drive->bios_head,	NULL);
	ide_add_setting(drive,	"bios_sect",	SETTING_RW,	TYPE_BYTE,	0,	63,		1,		1,	&drive->bios_sect,	NULL);
	ide_add_setting(drive,	"ticks",	SETTING_RW,	TYPE_BYTE,	0,	255,		1,		1,	&floppy->ticks,		NULL);
	ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1,
			&drive->bios_cyl, NULL);
	ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1,
			&drive->bios_head, NULL);
	ide_add_setting(drive, "bios_sect", SETTING_RW,	TYPE_BYTE, 0,  63, 1, 1,
			&drive->bios_sect, NULL);
	ide_add_setting(drive, "ticks",	   SETTING_RW, TYPE_BYTE, 0, 255, 1, 1,
			&floppy->ticks,	 NULL);
}
#else
static inline void idefloppy_add_settings(ide_drive_t *drive) { ; }
#endif

/*
 *	Driver initialization.
 */
static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
{
	struct idefloppy_id_gcw gcw;
@@ -1368,16 +1332,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
	if (gcw.drq_type == 1)
		floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT;
	/*
	 *	We used to check revisions here. At this point however
	 *	I'm giving up. Just assume they are all broken, its easier.
	 * We used to check revisions here. At this point however I'm giving up.
	 * Just assume they are all broken, its easier.
	 *
	 *	The actual reason for the workarounds was likely
	 *	a driver bug after all rather than a firmware bug,
	 *	and the workaround below used to hide it. It should
	 *	be fixed as of version 1.9, but to be on the safe side
	 * The actual reason for the workarounds was likely a driver bug after
	 * all rather than a firmware bug, and the workaround below used to hide
	 * it. It should be fixed as of version 1.9, but to be on the safe side
	 * we'll leave the limitation below for the 2.2.x tree.
	 */

	if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) {
		floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE;
		/* This value will be visible in the /proc/ide/hdx/settings */
@@ -1386,16 +1348,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
	}

	/*
	*      Guess what?  The IOMEGA Clik! drive also needs the
	*      above fix.  It makes nasty clicking noises without
	*      it, so please don't remove this.
	 * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes
	 * nasty clicking noises without it, so please don't remove this.
	 */
	if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) {
		blk_queue_max_sectors(drive->queue, 64);
		floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE;
	}


	(void) ide_floppy_get_capacity(drive);
	idefloppy_add_settings(drive);
}
@@ -1425,8 +1385,8 @@ static void idefloppy_cleanup_obj(struct kref *kref)
}

#ifdef CONFIG_IDE_PROC_FS
static int proc_idefloppy_read_capacity
	(char *page, char **start, off_t off, int count, int *eof, void *data)
static int proc_idefloppy_read_capacity(char *page, char **start, off_t off,
		int count, int *eof, void *data)
{
	ide_drive_t*drive = (ide_drive_t *)data;
	int len;
@@ -1474,7 +1434,8 @@ static int idefloppy_open(struct inode *inode, struct file *filp)

	debug_log("Reached %s\n", __func__);

	if (!(floppy = ide_floppy_get(disk)))
	floppy = ide_floppy_get(disk);
	if (!floppy)
		return -ENXIO;

	drive = floppy->drive;
@@ -1494,9 +1455,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
		if (ide_floppy_get_capacity(drive)
		   && (filp->f_flags & O_NDELAY) == 0
		    /*
		    ** Allow O_NDELAY to open a drive without a disk, or with
		    ** an unreadable disk, so that we can get the format
		    ** capacity of the drive or begin the format - Sam
		     * Allow O_NDELAY to open a drive without a disk, or with an
		     * unreadable disk, so that we can get the format capacity
		     * of the drive or begin the format - Sam
		     */
		    ) {
			ret = -EIO;
@@ -1727,15 +1688,19 @@ static int ide_floppy_probe(ide_drive_t *drive)
	if (drive->media != ide_floppy)
		goto failed;
	if (!idefloppy_identify_device(drive, drive->id)) {
		printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name);
		printk(KERN_ERR "ide-floppy: %s: not supported by this version"
				" of ide-floppy\n", drive->name);
		goto failed;
	}
	if (drive->scsi) {
		printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
		printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi"
				" emulation.\n", drive->name);
		goto failed;
	}
	if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
		printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
	floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL);
	if (!floppy) {
		printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy"
				" structure\n", drive->name);
		goto failed;
	}

@@ -1773,8 +1738,6 @@ static int ide_floppy_probe(ide_drive_t *drive)
	return -ENODEV;
}

MODULE_DESCRIPTION("ATAPI FLOPPY Driver");

static void __exit idefloppy_exit(void)
{
	driver_unregister(&idefloppy_driver.gen_driver);
@@ -1790,3 +1753,5 @@ MODULE_ALIAS("ide:*m-floppy*");
module_init(idefloppy_init);
module_exit(idefloppy_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ATAPI FLOPPY Driver");