From patchwork Thu Jan 28 12:30:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 43858 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.180.67]) by ozlabs.org (Postfix) with ESMTP id C63B3B7D09 for ; Thu, 28 Jan 2010 23:31:44 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753169Ab0A1Mbm (ORCPT ); Thu, 28 Jan 2010 07:31:42 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753370Ab0A1Mbm (ORCPT ); Thu, 28 Jan 2010 07:31:42 -0500 Received: from verein.lst.de ([213.95.11.210]:57320 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169Ab0A1Mbm (ORCPT ); Thu, 28 Jan 2010 07:31:42 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o0SCUBWY032036 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Thu, 28 Jan 2010 13:30:11 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o0SCUBoG032035; Thu, 28 Jan 2010 13:30:11 +0100 Date: Thu, 28 Jan 2010 13:30:11 +0100 From: Christoph Hellwig To: jgarzik@pobox.com Cc: linux-ide@vger.kernel.org, stable@kernel.org Subject: [PATCH v2] libata: fix ata_id_logical_per_physical_sectors Message-ID: <20100128123011.GA32001@lst.de> References: <20100128104234.GA25693@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100128104234.GA25693@lst.de> User-Agent: Mutt/1.3.28i X-Spam-Score: 0 () X-Scanned-By: MIMEDefang 2.39 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org The value we get from the low byte of the ATA_ID_SECTOR_SIZE word is not not a plain multiple, but the log of it, so fix the helper to give the correct answer. Without this we'll get an incorrect minimal I/O size in the block limits VPD page for 4k sector drives. Also change the return value of ata_id_logical_per_physical_sectors to u16 for the unlikely case of very large logical sectors. Signed-off-by: Christoph Hellwig --- 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: linux-2.6/include/linux/ata.h =================================================================== --- linux-2.6.orig/include/linux/ata.h 2010-01-28 12:24:02.061016474 +0100 +++ linux-2.6/include/linux/ata.h 2010-01-28 13:26:59.270005271 +0100 @@ -647,9 +647,9 @@ static inline int ata_id_has_large_logic return id[ATA_ID_SECTOR_SIZE] & (1 << 13); } -static inline u8 ata_id_logical_per_physical_sectors(const u16 *id) +static inline u16 ata_id_logical_per_physical_sectors(const u16 *id) { - return id[ATA_ID_SECTOR_SIZE] & 0xf; + return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf); } static inline int ata_id_has_lba48(const u16 *id)