From patchwork Mon Jan 7 14:41:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 154882 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3553934ljp; Mon, 7 Jan 2019 06:41:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN7K2toj0tv24PxxJp8nz+bNh43V1N049XSpZ4mbXfITdXgreUtwSuJiGLasUEz0U7FVTzeo X-Received: by 2002:a63:c24c:: with SMTP id l12mr11247846pgg.146.1546872077726; Mon, 07 Jan 2019 06:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546872077; cv=none; d=google.com; s=arc-20160816; b=KjgYI4f/PFKp/0u/2DUeDGq0j0xyjGov6p2thzOCgQ1tpyVq2NNDh+NZHLSsZtqDp8 bstHin4nPuIwMqCe+OhUCJ6ZREno/NP+UB3r6KpeW0x+F8zxK0gsP2XkGWcaVGN8ZviF PkVeijsLoHLzlgMdFdD2Ae1NwkpLPEReoo0PO0niI6ryg27H3DzVt07lBuA6gkrI2Rxy ZDp8p3ts8Wt6jMsXnYEK3elZb/Ne1DGcHGXSEcYt5i8dcwhRySiuNXqD2K6c1q9dYMK+ zRKr+I7XpYVLtZkCOiwnkh0lcso2Z0Busv8SqVLTN4kFeoQBlI1kiuatTGesvQ21uJ3h q94Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=BCcJl3fWDBPOhQ91VCYrO/yPpU5QGR60PIF7nLOXulQ=; b=V/LxEct2m7rVnCbWi0pAN+YLBHiPf/o8WkM9QlCH1t/vui46BRFkXqOv5U0Wq2kxED e9LR0EZu+x/B+Ar/3VffsXilLA59VZU/RhO14x9afawpWxTzNGl8VQGDq0cbW/+uTRpS OVtllrd4MfK0xQBbqNS/V9NTRsje4X67u79Gfj5qjt86v8Lb/6HJWR7IBrzd7YbOLlGz lPZY3Zn/TDs1Q5dDoxQEoaXZ23w4AlBN6tDx7O8YsBbEenTtUB665/olNnjzZEqdVk1B 6x0AIH7FhdugGcsclLfUFZFPHTBy9s0O8VdXCyNZW+CN7dQg0o75BBI6Vk3rOcctmGx9 HuxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u28si27836887pgn.436.2019.01.07.06.41.17; Mon, 07 Jan 2019 06:41:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729066AbfAGOlQ (ORCPT + 31 others); Mon, 7 Jan 2019 09:41:16 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:35164 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728418AbfAGOlP (ORCPT ); Mon, 7 Jan 2019 09:41:15 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4C790C515E02D1F4D80; Mon, 7 Jan 2019 22:41:09 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Mon, 7 Jan 2019 22:41:02 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH] scsi: sd: Make protection lookup tables static Date: Mon, 7 Jan 2019 22:41:51 +0800 Message-ID: <1546872111-5627-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the protection lookup tables in sd_prot_flag_mask() and sd_prot_op() are declared non-static. As such, they will be rebuilt for each respective function call. Optimise by making them static. This saves ~100B object code for sd.c: Before: text data bss dec hex filename 25403 1024 16 26443 674b drivers/scsi/sd.o After: text data bss dec hex filename 25299 1024 16 26339 66e3 drivers/scsi/sd.o Signed-off-by: John Garry -- 1.9.1 diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 1d63f3a..89e6d42 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -195,15 +195,15 @@ static inline sector_t sectors_to_logical(struct scsi_device *sdev, sector_t sec static inline unsigned int sd_prot_op(bool write, bool dix, bool dif) { /* Lookup table: bit 2 (write), bit 1 (dix), bit 0 (dif) */ - const unsigned int ops[] = { /* wrt dix dif */ - SCSI_PROT_NORMAL, /* 0 0 0 */ - SCSI_PROT_READ_STRIP, /* 0 0 1 */ - SCSI_PROT_READ_INSERT, /* 0 1 0 */ - SCSI_PROT_READ_PASS, /* 0 1 1 */ - SCSI_PROT_NORMAL, /* 1 0 0 */ - SCSI_PROT_WRITE_INSERT, /* 1 0 1 */ - SCSI_PROT_WRITE_STRIP, /* 1 1 0 */ - SCSI_PROT_WRITE_PASS, /* 1 1 1 */ + static const unsigned int ops[] = { /* wrt dix dif */ + SCSI_PROT_NORMAL, /* 0 0 0 */ + SCSI_PROT_READ_STRIP, /* 0 0 1 */ + SCSI_PROT_READ_INSERT, /* 0 1 0 */ + SCSI_PROT_READ_PASS, /* 0 1 1 */ + SCSI_PROT_NORMAL, /* 1 0 0 */ + SCSI_PROT_WRITE_INSERT, /* 1 0 1 */ + SCSI_PROT_WRITE_STRIP, /* 1 1 0 */ + SCSI_PROT_WRITE_PASS, /* 1 1 1 */ }; return ops[write << 2 | dix << 1 | dif]; @@ -215,7 +215,7 @@ static inline unsigned int sd_prot_op(bool write, bool dix, bool dif) */ static inline unsigned int sd_prot_flag_mask(unsigned int prot_op) { - const unsigned int flag_mask[] = { + static const unsigned int flag_mask[] = { [SCSI_PROT_NORMAL] = 0, [SCSI_PROT_READ_STRIP] = SCSI_PROT_TRANSFER_PI |