From patchwork Sun Jun 4 12:42:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 770895 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 3wgczq0ZzPz9s3w for ; Sun, 4 Jun 2017 22:42:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="IC7N9MHK"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbdFDMmo (ORCPT ); Sun, 4 Jun 2017 08:42:44 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:53547 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbdFDMmm (ORCPT ); Sun, 4 Jun 2017 08:42:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lt3tFlRdymXldaTSOeICSE5Yp21StJWn3IVyE7xdhWw=; b=IC7N9MHKlmosM2Ry0ffZklvih zpHEauQGXor9jer1Zf//ewR2W9jZPtZOXU1PIBytmxM6mw2Y08Dezq8onpzakN/knLo03AjV6XmVJ NBBwcY7tyZ80pixJFtqmDWycw0T5SyPBgBJCr2aExYPi9UMW653XO4tKO1qQ7MW1/5hepBcEzjFUq h2QRClLHg4AMsvVhGvMi1Mx98Hp/7yoSl6207Eq5f4/yoVYomZ14aDM4dP/Vc4AesvEbgho4irT+W kTAPA6605KqGsOD6D44oMPhTsm/me4hpfbp6foM6XaGe4752oc92wnsusRbCR00iG4x9VcFNOJXeM koZco/F2w==; Received: from p4ff2ee7d.dip0.t-ipconnect.de ([79.242.238.125] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dHUrg-00089L-Ep; Sun, 04 Jun 2017 12:42:40 +0000 From: Christoph Hellwig To: Tejun Heo Cc: Scott Bauer , Jonathan Derrick , Rafael Antognolli , Robert Elliott , linux-ide@vger.kernel.org, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH 4/6] libata: factor out a ata_identify_page_supported helper Date: Sun, 4 Jun 2017 14:42:23 +0200 Message-Id: <20170604124225.27032-5-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604124225.27032-1-hch@lst.de> References: <20170604124225.27032-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- drivers/ata/libata-core.c | 59 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 445e7050637b..f57131115594 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2120,6 +2120,37 @@ static bool ata_log_supported(struct ata_device *dev, u8 log) return get_unaligned_le16(&ap->sector_buf[log * 2]) ? true : false; } +static bool ata_identify_page_supported(struct ata_device *dev, u8 page) +{ + struct ata_port *ap = dev->link->ap; + unsigned int err, i; + + if (!ata_log_supported(dev, ATA_LOG_IDENTIFY_DEVICE)) { + ata_dev_warn(dev, "ATA Identify Device Log not supported\n"); + return false; + } + + /* + * Read IDENTIFY DEVICE data log, page 0, to figure out if the page is + * supported. + */ + err = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, 0, ap->sector_buf, + 1); + if (err) { + ata_dev_info(dev, + "failed to get Device Identify Log Emask 0x%x\n", + err); + return false; + } + + for (i = 0; i < ap->sector_buf[8]; i++) { + if (ap->sector_buf[9 + i] == page) + return true; + } + + return false; +} + static int ata_do_link_spd_horkage(struct ata_device *dev) { struct ata_link *plink = ata_dev_phys_link(dev); @@ -2325,8 +2356,6 @@ static void ata_dev_config_zac(struct ata_device *dev) struct ata_port *ap = dev->link->ap; unsigned int err_mask; u8 *identify_buf = ap->sector_buf; - int i, found = 0; - u16 log_pages; dev->zac_zones_optimal_open = U32_MAX; dev->zac_zones_optimal_nonseq = U32_MAX; @@ -2346,31 +2375,7 @@ static void ata_dev_config_zac(struct ata_device *dev) if (!(dev->flags & ATA_DFLAG_ZAC)) return; - if (!ata_log_supported(dev, ATA_LOG_IDENTIFY_DEVICE)) { - ata_dev_warn(dev, "ATA Identify Device Log not supported\n"); - return; - } - - /* - * Read IDENTIFY DEVICE data log, page 0, to figure out - * if page 9 is supported. - */ - err_mask = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, 0, - identify_buf, 1); - if (err_mask) { - ata_dev_info(dev, - "failed to get Device Identify Log Emask 0x%x\n", - err_mask); - return; - } - log_pages = identify_buf[8]; - for (i = 0; i < log_pages; i++) { - if (identify_buf[9 + i] == ATA_LOG_ZONED_INFORMATION) { - found++; - break; - } - } - if (!found) { + if (!ata_identify_page_supported(dev, ATA_LOG_ZONED_INFORMATION)) { ata_dev_warn(dev, "ATA Zoned Information Log not supported\n"); return;