From patchwork Tue Aug 23 04:45:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 9295367 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE060608A7 for ; Tue, 23 Aug 2016 10:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE9EF28A14 for ; Tue, 23 Aug 2016 10:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1D3F28A48; Tue, 23 Aug 2016 10:20:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C78628A5B for ; Tue, 23 Aug 2016 10:20:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755749AbcHWKUu (ORCPT ); Tue, 23 Aug 2016 06:20:50 -0400 Received: from mail-by2nam03on0134.outbound.protection.outlook.com ([104.47.42.134]:55712 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932594AbcHWKUr (ORCPT ); Tue, 23 Aug 2016 06:20:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NBttdgr2aDqC6ep0vIJ5A5r4TDRV1BZbzZBoU63l+1g=; b=HHtXcG76gsrrdxaz02twFGjJW6MPGw60TgbjelK14/8R9pdDrRGvZYKoaWQFCwsOzUUDzH7ReO/r9fHzYwisdPF0NCzZ+USBlqjy6fNj+Dl8k8m0h6OOCf12ZMO0NkgHsjqA5QyVX+LlzjbS6lOPJNzZS6G8qceL46fQoquE+V0= Received: from MWHPR03MB2669.namprd03.prod.outlook.com (10.168.207.15) by MWHPR03MB2544.namprd03.prod.outlook.com (10.169.201.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Tue, 23 Aug 2016 04:45:51 +0000 Received: from MWHPR03MB2669.namprd03.prod.outlook.com ([10.168.207.15]) by MWHPR03MB2669.namprd03.prod.outlook.com ([10.168.207.15]) with mapi id 15.01.0587.009; Tue, 23 Aug 2016 04:45:51 +0000 From: Dexuan Cui To: Bjorn Helgaas , "linux-pci@vger.kernel.org" , "gregkh@linuxfoundation.org" , KY Srinivasan , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , "vkuznets@redhat.com" , Haiyang Zhang , Hadden Hoppert , "helgaas@kernel.org" , "Stephen Hemminger" Subject: [PATCH 1/5] PCI: hv: use zero-length array in struct pci_packet Thread-Topic: [PATCH 1/5] PCI: hv: use zero-length array in struct pci_packet Thread-Index: AdH8+SICGTD16HWORp6YlPOqCIwCjg== Date: Tue, 23 Aug 2016 04:45:51 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [112.65.1.155] x-ms-office365-filtering-correlation-id: cf9fd398-250d-401b-73f9-08d3cb105c2c x-microsoft-exchange-diagnostics: 1; MWHPR03MB2544; 6:TGGla/D0GMbimo/IRUBXQJL/tfWboOt651mYuvGWgqRSTmGhS7JNiMkWpNCS4e51ALKehxOWfHsmb9QmwS4KrezZNuN9aEMCmKJNrLZ0492vAjs2sVTTpE1eUVZnBVqBzGQvGBVYJ0c7klb4/F5gYo5IbH16NoKp6MMGIBxoZ8g3sCF3ih4U362KlzPKggcWHqBMBfxyJ2GYlAxVJcF7Obr5tqMINXWD+NYaFH5UajOC+9k7ne8pYSMGWPiMOBuPO41MOGG+iW97Mf7AnSkc9z0P85hsuavatI05inr6WgftXReIlyxmhfib9GWzXxKJ+Xh7wD8qcuF6YClUDOrEaw==; 5:xWsBnM7EhFW/I678FbB8NyBTjBBE5vLZ7irwx9r7M6l652tO0fIyp5lQjcigNrMg08rl090IbEUzPLkUATw0w0USTSaf+xNpkq7NHfXIUVnmEEmJJVqU9vWXCwipcLxruil5mIaOk9vU4OimNyvOLg==; 24:h/oG99jvP9BWkFXohEXmJK2mfzje9Y4xO03ZpLp+fQ01fu/1Ffaw8CrCpF0IidqJZGzTIzdneO5xxXf3gyqHMvXCCZ8P8ZcAmVR4yT1cJow=; 7:HGCAYdQR2lbCc/0l6i3mDOpGBloqvt97iOudP1Ma61hCmKP+ujQ2ZRwWl6kqs67NYvbB0A+rsbTKshS9oAdstuTT27JehZqqEvSnucETtfSV6cqnlreO2ai9j+UpDtkPfWGKHR6gU5jgIezJu1NNVX8HXPkFwLarmDC+TWt0oVLONLnqepmfP2RcJEQ9lsGng/GXD1Fzx9dl2aPyOupI2SWtWEUh3gKWLV6DCyWcDylOlsPt6yc29xABFAthEQEy x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:MWHPR03MB2544; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(61426038)(61427038); SRVR:MWHPR03MB2544; BCL:0; PCL:0; RULEID:; SRVR:MWHPR03MB2544; x-forefront-prvs: 004395A01C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(199003)(189002)(4001450100002)(106356001)(10090500001)(2561002)(11100500001)(92566002)(305945005)(7696003)(7736002)(5660300001)(7846002)(8936002)(81166006)(81156014)(2900100001)(77096005)(8676002)(2501003)(8990500004)(7416002)(10290500002)(5005710100001)(5002640100001)(10400500002)(74316002)(9686002)(122556002)(97736004)(5001770100001)(189998001)(19580405001)(107886002)(2906002)(2201001)(575784001)(76576001)(54356999)(99286002)(50986999)(86362001)(3846002)(102836003)(19580395003)(105586002)(6116002)(33656002)(586003)(1511001)(3280700002)(66066001)(101416001)(3660700001)(68736007)(86612001)(2421001)(87936001)(229853001)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR03MB2544; H:MWHPR03MB2669.namprd03.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Aug 2016 04:45:51.4203 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2544 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP And, rename struct pci_message's field "message_type" to "type. This makes the code more readable. No functionality change. Cc: Jake Oshins Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Vitaly Kuznetsov Signed-off-by: Dexuan Cui --- drivers/pci/host/pci-hyperv.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 7e9b2de..78758e9 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -200,11 +200,11 @@ struct tran_int_desc { */ struct pci_message { - u32 message_type; + u32 type; } __packed; struct pci_child_message { - u32 message_type; + struct pci_message message_type; union win_slot_encoding wslot; } __packed; @@ -222,7 +222,8 @@ struct pci_packet { void (*completion_func)(void *context, struct pci_response *resp, int resp_packet_size); void *compl_ctxt; - struct pci_message message; + + struct pci_message message[0]; }; /* @@ -314,7 +315,7 @@ struct pci_dev_incoming { } __packed; struct pci_eject_response { - u32 message_type; + struct pci_message message_type; union win_slot_encoding wslot; u32 status; } __packed; @@ -694,13 +695,12 @@ static void hv_int_desc_free(struct hv_pci_dev *hpdev, struct pci_delete_interrupt *int_pkt; struct { struct pci_packet pkt; - u8 buffer[sizeof(struct pci_delete_interrupt) - - sizeof(struct pci_message)]; + u8 buffer[sizeof(struct pci_delete_interrupt)]; } ctxt; memset(&ctxt, 0, sizeof(ctxt)); int_pkt = (struct pci_delete_interrupt *)&ctxt.pkt.message; - int_pkt->message_type.message_type = + int_pkt->message_type.type = PCI_DELETE_INTERRUPT_MESSAGE; int_pkt->wslot.slot = hpdev->desc.win_slot.slot; int_pkt->int_desc = *int_desc; @@ -845,8 +845,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) struct cpumask *affinity; struct { struct pci_packet pkt; - u8 buffer[sizeof(struct pci_create_interrupt) - - sizeof(struct pci_message)]; + u8 buffer[sizeof(struct pci_create_interrupt)]; } ctxt; int cpu; int ret; @@ -874,7 +873,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) ctxt.pkt.completion_func = hv_pci_compose_compl; ctxt.pkt.compl_ctxt = ∁ int_pkt = (struct pci_create_interrupt *)&ctxt.pkt.message; - int_pkt->message_type.message_type = PCI_CREATE_INTERRUPT_MESSAGE; + int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE; int_pkt->wslot.slot = hpdev->desc.win_slot.slot; int_pkt->int_desc.vector = cfg->vector; int_pkt->int_desc.vector_count = 1; @@ -1287,7 +1286,7 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, pkt.init_packet.compl_ctxt = &comp_pkt; pkt.init_packet.completion_func = q_resource_requirements; res_req = (struct pci_child_message *)&pkt.init_packet.message; - res_req->message_type = PCI_QUERY_RESOURCE_REQUIREMENTS; + res_req->message_type.type = PCI_QUERY_RESOURCE_REQUIREMENTS; res_req->wslot.slot = desc->win_slot.slot; ret = vmbus_sendpacket(hbus->hdev->channel, res_req, @@ -1556,8 +1555,7 @@ static void hv_eject_device_work(struct work_struct *work) int wslot; struct { struct pci_packet pkt; - u8 buffer[sizeof(struct pci_eject_response) - - sizeof(struct pci_message)]; + u8 buffer[sizeof(struct pci_eject_response)]; } ctxt; hpdev = container_of(work, struct hv_pci_dev, wrk); @@ -1583,7 +1581,7 @@ static void hv_eject_device_work(struct work_struct *work) memset(&ctxt, 0, sizeof(ctxt)); ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; - ejct_pkt->message_type = PCI_EJECTION_COMPLETE; + ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE; ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; vmbus_sendpacket(hpdev->hbus->hdev->channel, ejct_pkt, sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt, @@ -1685,7 +1683,7 @@ static void hv_pci_onchannelcallback(void *context) case VM_PKT_DATA_INBAND: new_message = (struct pci_incoming_message *)buffer; - switch (new_message->message_type.message_type) { + switch (new_message->message_type.type) { case PCI_BUS_RELATIONS: bus_rel = (struct pci_bus_relations *)buffer; @@ -1716,7 +1714,7 @@ static void hv_pci_onchannelcallback(void *context) default: dev_warn(&hbus->hdev->device, "Unimplemented protocol message %x\n", - new_message->message_type.message_type); + new_message->message_type.type); break; } break; @@ -1768,7 +1766,7 @@ static int hv_pci_protocol_negotiation(struct hv_device *hdev) pkt->completion_func = hv_pci_generic_compl; pkt->compl_ctxt = &comp_pkt; version_req = (struct pci_version_request *)&pkt->message; - version_req->message_type.message_type = PCI_QUERY_PROTOCOL_VERSION; + version_req->message_type.type = PCI_QUERY_PROTOCOL_VERSION; version_req->protocol_version = PCI_PROTOCOL_VERSION_CURRENT; ret = vmbus_sendpacket(hdev->channel, version_req, @@ -1969,7 +1967,7 @@ static int hv_pci_enter_d0(struct hv_device *hdev) pkt->completion_func = hv_pci_generic_compl; pkt->compl_ctxt = &comp_pkt; d0_entry = (struct pci_bus_d0_entry *)&pkt->message; - d0_entry->message_type.message_type = PCI_BUS_D0ENTRY; + d0_entry->message_type.type = PCI_BUS_D0ENTRY; d0_entry->mmio_base = hbus->mem_config->start; ret = vmbus_sendpacket(hdev->channel, d0_entry, sizeof(*d0_entry), @@ -2015,7 +2013,7 @@ static int hv_pci_query_relations(struct hv_device *hdev) return -ENOTEMPTY; memset(&message, 0, sizeof(message)); - message.message_type = PCI_QUERY_BUS_RELATIONS; + message.type = PCI_QUERY_BUS_RELATIONS; ret = vmbus_sendpacket(hdev->channel, &message, sizeof(message), 0, VM_PKT_DATA_INBAND, 0); @@ -2068,8 +2066,8 @@ static int hv_send_resources_allocated(struct hv_device *hdev) init_completion(&comp_pkt.host_event); pkt->completion_func = hv_pci_generic_compl; pkt->compl_ctxt = &comp_pkt; - pkt->message.message_type = PCI_RESOURCES_ASSIGNED; res_assigned = (struct pci_resources_assigned *)&pkt->message; + res_assigned->message_type.type = PCI_RESOURCES_ASSIGNED; res_assigned->wslot.slot = hpdev->desc.win_slot.slot; put_pcichild(hpdev, hv_pcidev_ref_by_slot); @@ -2119,7 +2117,7 @@ static int hv_send_resources_released(struct hv_device *hdev) continue; memset(&pkt, 0, sizeof(pkt)); - pkt.message_type = PCI_RESOURCES_RELEASED; + pkt.message_type.type = PCI_RESOURCES_RELEASED; pkt.wslot.slot = hpdev->desc.win_slot.slot; put_pcichild(hpdev, hv_pcidev_ref_by_slot); @@ -2286,7 +2284,7 @@ static int hv_pci_remove(struct hv_device *hdev) init_completion(&comp_pkt.host_event); pkt.teardown_packet.completion_func = hv_pci_generic_compl; pkt.teardown_packet.compl_ctxt = &comp_pkt; - pkt.teardown_packet.message.message_type = PCI_BUS_D0EXIT; + pkt.teardown_packet.message[0].type = PCI_BUS_D0EXIT; ret = vmbus_sendpacket(hdev->channel, &pkt.teardown_packet.message, sizeof(struct pci_message),