From patchwork Thu Jul 14 21:09:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 648598 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 3rr7c85JzVz9s8d for ; Fri, 15 Jul 2016 07:09:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=yADk9vKU; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751262AbcGNVJM (ORCPT ); Thu, 14 Jul 2016 17:09:12 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33970 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbcGNVJK (ORCPT ); Thu, 14 Jul 2016 17:09:10 -0400 Received: by mail-pf0-f196.google.com with SMTP id g202so5345831pfb.1 for ; Thu, 14 Jul 2016 14:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fzqF6a7+c0s9G0lRLGQ+Oy2n3HlraJpKP9nkyq/Uj9U=; b=yADk9vKUWpMNR8WivRpUuyZ47xVZfdRyjzD3ZuDu+CQBVMzkj2egvx3THbBBRDNSez hCkoDL1OLgaVLdJyzofZk2LpCOPwMhCUjhGNyBTCAdXON7j8cu4FHx0Ti9l9Lc4Zcg4y 1483cWs6WP99YOA/6oOSXob3ogb5PWvTCFuclsVKa6ENtgNwj/BKqRiGmn3zDurnTot/ i1eMRA7sApPACrZZr5xrnk4St06dX2ClZk/bVnycuB5nkvilhVg1uXDm8d/lKovSMQGc 90gx7ciscmqG1GFZ20HBI6GZ9Z4FRk/kkJuUxwVHmQgdvoLZ2DpM/0n/ADybb70W65Td m57g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fzqF6a7+c0s9G0lRLGQ+Oy2n3HlraJpKP9nkyq/Uj9U=; b=acCoLSpVOhkIT0sfjZoPOEpvUVUOjscI8jfcBpSnGeCpBfMfJfsNpAbCZ0+95dHpS5 XWa/t5sFwqtDMV/H7BUBvBp7WLkyUH4l0+z/nFgSO8dNzgHud4ZBy36Sy/HnlUMFev2E 7Z/GE10QT/gmIsQnKaaB8XV4sZDE4jturkYCO24U2JyiOQOO7r4xVoWC7d/nD0QMjPVP t7J0DZ8YV6lnyGxnOlgXrfadjb9L2f7cSkl1BZkcAAs4qFPlc0CdLXx6nfvBlL2sMtZE a8fm7PCbrqKwpH1sZ+4WaqtogumH7pIWp7os7ZDPj8Qwsb6AZ0ZbS05cm83435p3wV1u QfqA== X-Gm-Message-State: ALyK8tILfoeNxGrIXtIYnUYoEo4cFQ6GTLAV5kI1o2EaJzaaHZ6aKwGSBg9TYR6wRw2B+Q== X-Received: by 10.98.4.193 with SMTP id 184mr15774549pfe.98.1468530549501; Thu, 14 Jul 2016 14:09:09 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id m5sm6831951paw.40.2016.07.14.14.09.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2016 14:09:09 -0700 (PDT) From: tom.ty89@gmail.com X-Google-Original-From: me To: tj@kernel.org Cc: linux-ide@vger.kernel.org, Tom Yan Subject: [PATCH] ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48} Date: Fri, 15 Jul 2016 05:09:02 +0800 Message-Id: X-Mailer: git-send-email 2.9.0 In-Reply-To: <91a6bb6f4c04eb617a49d9a51f261b661c179de0.1468384890.git.tom.ty89@gmail.com> References: <91a6bb6f4c04eb617a49d9a51f261b661c179de0.1468384890.git.tom.ty89@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Tom Yan Since we set ATA_MAX_SECTORS_LBA48 to 65535 to avoid the corner case in some drives that commands with "count" set to 0000h (which reprsents 65536) does not work as expected, lba_48_ok(), which is used for number-of-blocks checking when libata pack commands, should use the same limit as well. In fact, there is no reason for the two functions not to use the macros anyway. Signed-off-by: Tom Yan diff --git a/include/linux/ata.h b/include/linux/ata.h index 99346be..f87287a 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -46,7 +46,7 @@ enum { ATA_MAX_SECTORS_128 = 128, ATA_MAX_SECTORS = 256, ATA_MAX_SECTORS_1024 = 1024, - ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */ + ATA_MAX_SECTORS_LBA48 = 65535,/* avoid count to be 0000h */ ATA_MAX_SECTORS_TAPE = 65535, ATA_ID_WORDS = 256, @@ -1095,13 +1095,13 @@ static inline bool ata_ok(u8 status) static inline bool lba_28_ok(u64 block, u32 n_block) { /* check the ending block number: must be LESS THAN 0x0fffffff */ - return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256); + return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= ATA_MAX_SECTORS); } static inline bool lba_48_ok(u64 block, u32 n_block) { /* check the ending block number */ - return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); + return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= ATA_MAX_SECTORS_LBA48); } #define sata_pmp_gscr_vendor(gscr) ((gscr)[SATA_PMP_GSCR_PROD_ID] & 0xffff)