linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Panin <pazke@orbita1.ru>
To: Martin Dalecki <dalecki@evision-ventures.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] hpt366.c cosmetic cleanups
Date: Fri, 31 May 2002 16:23:18 +0400	[thread overview]
Message-ID: <20020531122318.GA305@pazke.ipt> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 534 bytes --]

Hi,

attached patch contains some cosmetic cleanups for hpt366.c driver:
	- remove lots of unneeded initializations of local vars;
	- get rid of byte type usage, we have kernelwide u8 type;
	- s/unsigned int/u32/ where needed (args to pci_read_dword());

Patch against 2.5.19, applies (with some offsets) on top IDE 76. 
Compiles and seems working (for me). Please take a look at it.

Best regards.

-- 
Andrey Panin            | Embedded systems software engineer
pazke@orbita1.ru        | PGP key: wwwkeys.eu.pgp.net

[-- Attachment #1.2: patch-hpt366 --]
[-- Type: text/plain, Size: 7947 bytes --]

diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/hpt366.c linux/drivers/ide/hpt366.c
--- linux.vanilla/drivers/ide/hpt366.c	Fri May 31 03:38:52 2002
+++ linux/drivers/ide/hpt366.c	Fri May 31 04:03:00 2002
@@ -598,7 +598,7 @@
 
 static unsigned int hpt_revision(struct pci_dev *dev)
 {
-	unsigned int class_rev;
+	u32 class_rev;
 	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
 	class_rev &= 0xff;
 
@@ -654,7 +654,7 @@
 }
 
 
-static unsigned int pci_bus_clock_list(byte speed, struct chipset_bus_clock_list_entry * chipset_table)
+static unsigned int pci_bus_clock_list(u8 speed, struct chipset_bus_clock_list_entry * chipset_table)
 {
 	for ( ; chipset_table->xfer_speed ; chipset_table++)
 		if (chipset_table->xfer_speed == speed) {
@@ -663,18 +663,17 @@
 	return chipset_table->chipset_settings;
 }
 
-static void hpt366_tune_chipset(struct ata_device *drive, byte speed)
+static void hpt366_tune_chipset(struct ata_device *drive, u8 speed)
 {
 	struct pci_dev *dev	= drive->channel->pci_dev;
-	byte regtime		= (drive->select.b.unit & 0x01) ? 0x44 : 0x40;
-	byte regfast		= (drive->channel->unit) ? 0x55 : 0x51;
+	u8 regtime = (drive->select.b.unit & 0x01) ? 0x44 : 0x40;
+	u8 regfast = (drive->channel->unit) ? 0x55 : 0x51;
 			/*
 			 * since the channel is always 0 it does not matter.
 			 */
 
-	unsigned int reg1	= 0;
-	unsigned int reg2	= 0;
-	byte drive_fast		= 0;
+	u32 reg1, reg2;
+	u8 drive_fast;
 
 	/*
 	 * Disable the "fast interrupt" prediction.
@@ -699,19 +698,18 @@
 	pci_write_config_dword(dev, regtime, reg2);
 }
 
-static void hpt368_tune_chipset(struct ata_device *drive, byte speed)
+static void hpt368_tune_chipset(struct ata_device *drive, u8 speed)
 {
 	hpt366_tune_chipset(drive, speed);
 }
 
-static void hpt370_tune_chipset(struct ata_device *drive, byte speed)
+static void hpt370_tune_chipset(struct ata_device *drive, u8 speed)
 {
-	byte regfast		= (drive->channel->unit) ? 0x55 : 0x51;
-	unsigned int list_conf	= 0;
-	unsigned int drive_conf = 0;
-	unsigned int conf_mask	= (speed >= XFER_MW_DMA_0) ? 0xc0000000 : 0x30070000;
-	byte drive_pci		= 0x40 + (drive->dn * 4);
-	byte new_fast, drive_fast		= 0;
+	u8 regfast = (drive->channel->unit) ? 0x55 : 0x51;
+	u32 list_conf, drive_conf;
+	u32 conf_mask = (speed >= XFER_MW_DMA_0) ? 0xc0000000 : 0x30070000;
+	u8 drive_pci = 0x40 + (drive->dn * 4);
+	u8 new_fast, drive_fast;
 	struct pci_dev *dev	= drive->channel->pci_dev;
 
 	/*
@@ -747,14 +745,13 @@
 	pci_write_config_dword(dev, drive_pci, list_conf);
 }
 
-static void hpt372_tune_chipset(struct ata_device *drive, byte speed)
+static void hpt372_tune_chipset(struct ata_device *drive, u8 speed)
 {
-	byte regfast		= (drive->channel->unit) ? 0x55 : 0x51;
-	unsigned int list_conf	= 0;
-	unsigned int drive_conf	= 0;
-	unsigned int conf_mask	= (speed >= XFER_MW_DMA_0) ? 0xc0000000 : 0x30070000;
-	byte drive_pci		= 0x40 + (drive->dn * 4);
-	byte drive_fast		= 0;
+	u8 regfast = (drive->channel->unit) ? 0x55 : 0x51;
+	u32 list_conf, drive_conf;
+	u32 conf_mask = (speed >= XFER_MW_DMA_0) ? 0xc0000000 : 0x30070000;
+	u8 drive_pci = 0x40 + (drive->dn * 4);
+	u8 drive_fast;
 	struct pci_dev *dev	= drive->channel->pci_dev;
 
 	/*
@@ -775,12 +772,12 @@
 	pci_write_config_dword(dev, drive_pci, list_conf);
 }
 
-static void hpt374_tune_chipset(struct ata_device *drive, byte speed)
+static void hpt374_tune_chipset(struct ata_device *drive, u8 speed)
 {
 	hpt372_tune_chipset(drive, speed);
 }
 
-static int hpt3xx_tune_chipset(struct ata_device *drive, byte speed)
+static int hpt3xx_tune_chipset(struct ata_device *drive, u8 speed)
 {
 	struct pci_dev *dev = drive->channel->pci_dev;
 
@@ -804,9 +801,9 @@
 
 static void config_chipset_for_pio(struct ata_device *drive)
 {
-	unsigned short eide_pio_timing[6] = {960, 480, 240, 180, 120, 90};
+	static unsigned short eide_pio_timing[6] = {960, 480, 240, 180, 120, 90};
 	unsigned short xfer_pio = drive->id->eide_pio_modes;
-	byte	timing, speed, pio;
+	u8 timing, speed, pio;
 
 	pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO) - XFER_PIO_0;
 
@@ -837,12 +834,12 @@
 			speed = (!drive->id->tPIO) ? XFER_PIO_0 : XFER_PIO_SLOW;
 			break;
 	}
-	(void) hpt3xx_tune_chipset(drive, speed);
+	hpt3xx_tune_chipset(drive, speed);
 }
 
-static void hpt3xx_tune_drive(struct ata_device *drive, byte pio)
+static void hpt3xx_tune_drive(struct ata_device *drive, u8 pio)
 {
-	byte speed;
+	u8 speed;
 	switch(pio) {
 		case 4:		speed = XFER_PIO_4;break;
 		case 3:		speed = XFER_PIO_3;break;
@@ -858,7 +855,7 @@
 {
 	struct pci_dev *dev = drive->channel->pci_dev;
 	int map;
-	byte mode;
+	u8 mode;
 
 	if (drive->type != ATA_DISK)
 		return 0;
@@ -924,7 +921,7 @@
 
 	if (drive->quirk_list) {
 		if (hpt_min_rev(dev, 3)) {
-			byte reg5a = 0;
+			u8 reg5a;
 			pci_read_config_byte(dev, 0x5a, &reg5a);
 			if (((reg5a & 0x10) >> 4) != mask)
 				pci_write_config_byte(dev, 0x5a, mask ? (reg5a | 0x10) : (reg5a & ~0x10));
@@ -997,7 +994,7 @@
 
 static void hpt366_udma_irq_lost(struct ata_device *drive)
 {
-	u8 reg50h = 0, reg52h = 0, reg5ah = 0;
+	u8 reg50h, reg52h, reg5ah;
 
 	pci_read_config_byte(drive->channel->pci_dev, 0x50, &reg50h);
 	pci_read_config_byte(drive->channel->pci_dev, 0x52, &reg52h);
@@ -1140,8 +1137,8 @@
 {
 #if 0
 	unsigned long high_16	= pci_resource_start(drive->channel->pci_dev, 4);
-	byte reset		= (drive->channel->unit) ? 0x80 : 0x40;
-	byte reg59h		= 0;
+	u8 reset		= (drive->channel->unit) ? 0x80 : 0x40;
+	u8 reg59h;
 
 	pci_read_config_byte(drive->channel->pci_dev, 0x59, &reg59h);
 	pci_write_config_byte(drive->channel->pci_dev, 0x59, reg59h|reset);
@@ -1154,10 +1151,9 @@
 {
 	struct ata_channel *ch	= drive->channel;
 	struct pci_dev *dev	= ch->pci_dev;
-	byte reset		= (ch->unit) ? 0x80 : 0x40;
-	byte state_reg		= (ch->unit) ? 0x57 : 0x53;
-	byte reg59h		= 0;
-	byte regXXh		= 0;
+	u8 reset = (ch->unit) ? 0x80 : 0x40;
+	u8 state_reg = (ch->unit) ? 0x57 : 0x53;
+	u8 reg59h, regXXh;
 
 	if (!ch)
 		return -EINVAL;
@@ -1366,8 +1362,8 @@
 
 static void __init hpt366_init(struct pci_dev *dev)
 {
-	unsigned int reg1	= 0;
-	u8 drive_fast		= 0;
+	u32 reg1;
+	u8 drive_fast;
 
 	/*
 	 * Disable the "fast interrupt" prediction.
@@ -1394,7 +1390,7 @@
 
 static unsigned int __init hpt366_init_chipset(struct pci_dev *dev)
 {
-	u8 test = 0;
+	u8 test;
 
 	if (dev->resource[PCI_ROM_RESOURCE].start)
 		pci_write_config_byte(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
@@ -1435,8 +1431,8 @@
 
 static unsigned int __init hpt366_ata66_check(struct ata_channel *ch)
 {
-	u8 ata66	= 0;
-	u8 regmask	= (ch->unit) ? 0x01 : 0x02;
+	u8 ata66;
+	u8 regmask = (ch->unit) ? 0x01 : 0x02;
 
 	pci_read_config_byte(ch->pci_dev, 0x5a, &ata66);
 #ifdef DEBUG
@@ -1466,7 +1462,7 @@
 #ifdef CONFIG_BLK_DEV_IDEDMA
 	if (ch->dma_base) {
 		if (hpt_min_rev(dev, 3)) {
-			byte reg5ah = 0;
+			u8 reg5ah;
 			pci_read_config_byte(dev, 0x5a, &reg5ah);
 			if (reg5ah & 0x10)	/* interrupt force enable */
 				pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10);
@@ -1521,14 +1517,12 @@
 
 static void __init hpt366_init_dma(struct ata_channel *ch, unsigned long dmabase)
 {
-	u8 masterdma = 0;
-	u8 slavedma = 0;
-	u8 dma_new = 0;
-	u8 dma_old = inb(dmabase+2);
-	u8 primary	= ch->unit ? 0x4b : 0x43;
-	u8 secondary	= ch->unit ? 0x4f : 0x47;
+	u8 masterdma, slavedma;
+	u8 dma_old = inb(dmabase + 2);
+	u8 dma_new = dma_old;
+	u8 primary = ch->unit ? 0x4b : 0x43;
+	u8 secondary = primary + 4;
 
-	dma_new = dma_old;
 	pci_read_config_byte(ch->pci_dev, primary, &masterdma);
 	pci_read_config_byte(ch->pci_dev, secondary, &slavedma);
 
@@ -1588,5 +1582,5 @@
 		ata_register_chipset(&chipsets[i]);
 	}
 
-    return 0;
+	return 0;
 }

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

                 reply	other threads:[~2002-05-31 12:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020531122318.GA305@pazke.ipt \
    --to=pazke@orbita1.ru \
    --cc=dalecki@evision-ventures.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).