From patchwork Wed Nov 30 12:36:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059770 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D436C4332F for ; Wed, 30 Nov 2022 12:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233549AbiK3Mfx (ORCPT ); Wed, 30 Nov 2022 07:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbiK3Mfw (ORCPT ); Wed, 30 Nov 2022 07:35:52 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C67DD286D5; Wed, 30 Nov 2022 04:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669811751; x=1701347751; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Y6YImtjFUGnItblf4QVHZN5K6aqgx8h21CJrsd1H+SE=; b=XEm+d+JBtoD9rSObnK5zcCOs24FkXFzLd87CFkftSQWyyaD+tydv7dNf ypd/28Dwwye5A3QMDMc5l4SUZqEFURbdLhZyv04+lWHtkZrJTZNO9BwIt gEA84+sXG8fDyv1dF74B+j0gk9C9Nxj6WaTebUz0awYABjBmXIT3j+GNg xtmsCSjFC5YqhbQan80VWbRCiHfXmIhnj9xbNETvRPhgA1ezy/WcyBoZX h9kVPIrjtFEZ8EM7yOszy5LuGmJtLyKtMON07b3VwP6xpGFLQG5LtSS+l 6h43fv+X0ZWwz9jLsZ1lfICuVqO8ZHODNabn8SIt1+lXznySoQ4sA2Sna g==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="315412993" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="315412993" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 04:35:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="621868377" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="621868377" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 30 Nov 2022 04:35:48 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E31F010E; Wed, 30 Nov 2022 14:36:14 +0200 (EET) From: Andy Shevchenko To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Jamet , Mika Westerberg , Yehezkel Bernat , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko Subject: [PATCH net-next v3 1/2] net: thunderbolt: Switch from __maybe_unused to pm_sleep_ptr() etc Date: Wed, 30 Nov 2022 14:36:12 +0200 Message-Id: <20221130123613.20829-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less heavier for builds than the use of __maybe_unused attributes. Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg --- v3: sent proper patch v2: added tag (Mika) drivers/net/thunderbolt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c index b20cd370b7f2..c73d419f1456 100644 --- a/drivers/net/thunderbolt.c +++ b/drivers/net/thunderbolt.c @@ -1319,7 +1319,7 @@ static void tbnet_shutdown(struct tb_service *svc) tbnet_tear_down(tb_service_get_drvdata(svc), true); } -static int __maybe_unused tbnet_suspend(struct device *dev) +static int tbnet_suspend(struct device *dev) { struct tb_service *svc = tb_to_service(dev); struct tbnet *net = tb_service_get_drvdata(svc); @@ -1334,7 +1334,7 @@ static int __maybe_unused tbnet_suspend(struct device *dev) return 0; } -static int __maybe_unused tbnet_resume(struct device *dev) +static int tbnet_resume(struct device *dev) { struct tb_service *svc = tb_to_service(dev); struct tbnet *net = tb_service_get_drvdata(svc); @@ -1350,9 +1350,7 @@ static int __maybe_unused tbnet_resume(struct device *dev) return 0; } -static const struct dev_pm_ops tbnet_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(tbnet_suspend, tbnet_resume) -}; +static DEFINE_SIMPLE_DEV_PM_OPS(tbnet_pm_ops, tbnet_suspend, tbnet_resume); static const struct tb_service_id tbnet_ids[] = { { TB_SERVICE("network", 1) }, @@ -1364,7 +1362,7 @@ static struct tb_service_driver tbnet_driver = { .driver = { .owner = THIS_MODULE, .name = "thunderbolt-net", - .pm = &tbnet_pm_ops, + .pm = pm_sleep_ptr(&tbnet_pm_ops), }, .probe = tbnet_probe, .remove = tbnet_remove, From patchwork Wed Nov 30 12:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059771 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E021FC433FE for ; Wed, 30 Nov 2022 12:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234896AbiK3Mf4 (ORCPT ); Wed, 30 Nov 2022 07:35:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbiK3Mfw (ORCPT ); Wed, 30 Nov 2022 07:35:52 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F2A67722B; Wed, 30 Nov 2022 04:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669811752; x=1701347752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RgyhU5bmK96xArXf/6a/u43HPi5BukzWqwYI+tdpOpA=; b=hp9eV7KLqmJnZijuhtn10/C6xUvAXeXj4MdMEGA1Gzr1Tyi1t3ZpuBlG gwx7sTVYG849cm/kSFKG/aWOcI92MtwEJ2sQICvOF3b7Ocd4I/jgM0foj dLCbOlDsxZWtteUgA/0c+bIckvvk+/rmS/I1XC7QKq4QZAaWe7XW47AIm r/HBWCs28Yhx/TgQIsDY138Mm+ytbAVFq5raeJQyI3OYfTyothr7eMm+U s2SP5109Ib2JDsDjr5E8ljyODGqMJiWviXiAOMswiYYXY6hx5tNXviqa9 YdjRbqjmoxj9Ym7ft2hDic3fKeK8UlgI0rkB9P5C8gHvDRDyA5HzJ2gFA Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="315413002" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="315413002" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 04:35:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="621868380" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="621868380" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 30 Nov 2022 04:35:48 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id ECC5D6A; Wed, 30 Nov 2022 14:36:14 +0200 (EET) From: Andy Shevchenko To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Jamet , Mika Westerberg , Yehezkel Bernat , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko Subject: [PATCH net-next v3 2/2] net: thunderbolt: Use bitwise types in the struct thunderbolt_ip_frame_header Date: Wed, 30 Nov 2022 14:36:13 +0200 Message-Id: <20221130123613.20829-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221130123613.20829-1-andriy.shevchenko@linux.intel.com> References: <20221130123613.20829-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The main usage of the struct thunderbolt_ip_frame_header is to handle the packets on the media layer. The header is bound to the protocol in which the byte ordering is crucial. However the data type definition doesn't use that and sparse is unhappy, for example (17 altogether): .../thunderbolt.c:718:23: warning: cast to restricted __le32 .../thunderbolt.c:966:42: warning: incorrect type in assignment (different base types) .../thunderbolt.c:966:42: expected unsigned int [usertype] frame_count .../thunderbolt.c:966:42: got restricted __le32 [usertype] Switch to the bitwise types in the struct thunderbolt_ip_frame_header to reduce this, but not completely solving (9 left), because the same data type is used for Rx header handled locally (in CPU byte order). Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg --- v3: no changes v2: changed only types without splitting the data type (Mika) drivers/net/thunderbolt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c index c73d419f1456..4ed7f5b547e3 100644 --- a/drivers/net/thunderbolt.c +++ b/drivers/net/thunderbolt.c @@ -58,10 +58,10 @@ * supported then @frame_id is filled, otherwise it stays %0. */ struct thunderbolt_ip_frame_header { - u32 frame_size; - u16 frame_index; - u16 frame_id; - u32 frame_count; + __le32 frame_size; + __le16 frame_index; + __le16 frame_id; + __le32 frame_count; }; enum thunderbolt_ip_frame_pdf {