From patchwork Fri Nov 27 18:54:53 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 39638 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id A2B0A1007D1 for ; Sat, 28 Nov 2009 05:59:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752660AbZK0S6a (ORCPT ); Fri, 27 Nov 2009 13:58:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751732AbZK0S6U (ORCPT ); Fri, 27 Nov 2009 13:58:20 -0500 Received: from mail-ew0-f219.google.com ([209.85.219.219]:51786 "EHLO mail-ew0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752664AbZK0S6N (ORCPT ); Fri, 27 Nov 2009 13:58:13 -0500 Received: by mail-ew0-f219.google.com with SMTP id 19so1731389ewy.21 for ; Fri, 27 Nov 2009 10:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:mime-version:content-type:content-transfer-encoding :message-id; bh=nqWZNR9eppCMfIQuG+ZerKAlvj4ZxyP/6Ts+c/uafe4=; b=J5df4M/4PXoF5ZBzXBqnhdNrWjq2iZINmnjHEh6hYvDux7Kzext1urNBzmKEvXLwOG NqwIO61M0D1Up9ko0vOzpp/gH2pOcnjKQgcdZN/2zH9YTEf4Qz5yqsdlnKwAhzto1IJT 22RIv3SnlQ+bN98UtjChQOUtJLjZrUgCVnX+8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:mime-version:content-type :content-transfer-encoding:message-id; b=kRpYBij8MVd4TsKUiOo/ARTjXyQ7qZ7GR5CNSewFPoLbNNL0N6gUM6Qo+zRTp3bSw6 vdjatCgHB3V0cgfVOyR4IiAQnIqkxyXv5KQ5lo65qCteV9/Ikwj9swf03STWmguP7T5u DVvG6yGV1/G4GhBDmxCMRf1mEkW21AZ/rUlLI= Received: by 10.216.85.210 with SMTP id u60mr395537wee.226.1259348298958; Fri, 27 Nov 2009 10:58:18 -0800 (PST) Received: from szaki.localnet (chello089079027028.chello.pl [89.79.27.28]) by mx.google.com with ESMTPS id t12sm4513208gvd.20.2009.11.27.10.58.17 (version=SSLv3 cipher=RC4-MD5); Fri, 27 Nov 2009 10:58:18 -0800 (PST) From: Bartlomiej Zolnierkiewicz To: linux-ide@vger.kernel.org Subject: [PATCH] pata_hpt366: add hpt36x_find_mode() helper Date: Fri, 27 Nov 2009 19:54:53 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.31.5-0.1-desktop; KDE/4.3.1; x86_64; ; ) Cc: linux-kernel@vger.kernel.org, Sergei Shtylyov MIME-Version: 1.0 Message-Id: <200911271954.54019.bzolnier@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Factor out code for finding the register programming information from hpt366_set_mode() to hpt36x_find_mode(). This makes pata_hpt366 driver more similar to pata_{37x,3x2n} ones. Signed-off-by: Bartlomiej Zolnierkiewicz --- Sergei, pata_hpt{37x,3x2n} drivers can also be made to use *set_mode() helper but I don't want to interfere with your pending fixes there. drivers/ata/pata_hpt366.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/ata/pata_hpt366.c =================================================================== --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c @@ -114,6 +114,28 @@ static const struct hpt_clock hpt366_25[ { 0, 0x01208585 } }; +/** + * hpt36x_find_mode - find the hpt36x timing + * @ap: ATA port + * @speed: transfer mode + * + * Return the 32bit register programming information for this channel + * that matches the speed provided. + */ + +static u32 hpt36x_find_mode(struct ata_port *ap, int speed) +{ + struct hpt_clock *clocks = ap->host->private_data; + + while (clocks->xfer_mode) { + if (clocks->xfer_mode == speed) + return clocks->timing; + clocks++; + } + BUG(); + return 0xffffffffU; /* silence compiler warning */ +} + static const char *bad_ata33[] = { "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2", "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2", @@ -238,11 +260,10 @@ static int hpt36x_prereset(struct ata_li static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mode) { - struct hpt_clock *clocks = ap->host->private_data; struct pci_dev *pdev = to_pci_dev(ap->host->dev); u32 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); u32 addr2 = 0x51 + 4 * ap->port_no; - u32 mask, reg; + u32 mask, reg, t; u8 fast; /* Fast interrupt prediction disable, hold off interrupt disable */ @@ -260,13 +281,7 @@ static void hpt366_set_mode(struct ata_p else mask = 0x30070000; - while (clocks->xfer_mode) { - if (clocks->xfer_mode == mode) - break; - clocks++; - } - if (!clocks->xfer_mode) - BUG(); + t = hpt36x_find_mode(ap, mode); /* * Combine new mode bits with old config bits and disable @@ -274,7 +289,7 @@ static void hpt366_set_mode(struct ata_p * problems handling I/O errors later. */ pci_read_config_dword(pdev, addr1, ®); - reg = ((reg & ~mask) | (clocks->timing & mask)) & ~0xc0000000; + reg = ((reg & ~mask) | (t & mask)) & ~0xc0000000; pci_write_config_dword(pdev, addr1, reg); }