Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp205851rdg; Thu, 12 Oct 2023 03:24:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8nFx1jXGdC34D+Z8PEfy3gpelCOFzy8Eslo5wJTIC28wsW6W7qZMJxAu2NQnjVcjIADSH X-Received: by 2002:a17:902:6f02:b0:1c5:de4c:f079 with SMTP id w2-20020a1709026f0200b001c5de4cf079mr15241656plk.33.1697106245559; Thu, 12 Oct 2023 03:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697106245; cv=none; d=google.com; s=arc-20160816; b=K3Ylm1FGT1ytGtdKTCEmAUGEs0MgXjbw6SiePZ3KH8T/phsMi7vzIUmpKjcGh+Mzet XtJMPcMeZm9N/UM8c3J4FsVBYsF5syr9rYyWQsQAk2E5BljQr4abPkv3nbCWxiHkIUaR +nmtO1+7wngNfiB0dhgMs2P+FtcGuE22AkzNbToEfv3ck84OkPgt6xp4VPbwC8FpGkof 4Xqu7e25Z5k1omOPxH5791y3PDbpnpvZelUMciVppUxahMN+HVoHLe7AvZPG3BfsrN8L 8vm0cuvKpU8eIhLDnmJNUpmRczv5IvQlyhBhKRMg2vNmlfKX9bOKrEB4z6+6JD+B4SWX MbQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=GDkT80A/jtoVkuj9J4SnCoJbf/78QeDTUDuEZoIOcfc=; fh=xUtS4Ye9bvz4mnbfL9bwsYffunq5fde5WqM/qGGhhDQ=; b=n72FJ4LIIrBlpJgFgHpPqCUVTwoqBENP6usBkRwPHqJxhfLQfqcPsxwsjEO73prvFS DY6/Kh8NTs3FUQdpYkjAsDfIV6IWD/8LgRxy2ZdZcCTF1VKG+G+2yrmV5RZSKKJAl7B2 8pyRJvfHDGpiHZ0U7vE7MtfvLzbHaomDF6XG4kXqudd++OU3B8j0gfm9zAzJkC7WRMaE VrJN13j/EEagQUGRN8mjDNHNA/lIH6jq9Sg6oDdWepZYlM3gfv22gGuhB1gwykAj5Qeu ja/0NQzGx/0EFb4hD9fN14yVxkKZGazFSZ2vDAKkp1h+0opmQ8AZETuVWAuAamSnBg27 HdLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=IxEIFffO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d1-20020a170903230100b001bb3316f71dsi2121878plh.481.2023.10.12.03.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 03:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=IxEIFffO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6897280477BA; Thu, 12 Oct 2023 03:24:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377791AbjJLKX6 (ORCPT + 99 others); Thu, 12 Oct 2023 06:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347111AbjJLKXw (ORCPT ); Thu, 12 Oct 2023 06:23:52 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88A0CD3; Thu, 12 Oct 2023 03:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1697106227; bh=dcNGhXp5FPTom7QF06OFWt6twK9Wx0jnbCF/HnZ41vM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IxEIFffOIC37ReXiTicel+yXLwHpChvLvrPq5QvxGftNl0sTXr6LNSyA3qazcweoj kEp0rmPIun58vHqP6kaUkoSA4vTSKCd+WrY6xBl0PdPlPGdQX7lO0RFGa0MW2rF+tl F7d+9YguOHYV/qFTj11zoovw6XbwvJPnG3QgPn1E= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 12 Oct 2023 12:23:38 +0200 Subject: [PATCH 1/4] HID: core: remove #ifdef CONFIG_PM from hid_driver MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231012-hid-pm_ptr-v1-1-0a71531ca93b@weissschuh.net> References: <20231012-hid-pm_ptr-v1-0-0a71531ca93b@weissschuh.net> In-Reply-To: <20231012-hid-pm_ptr-v1-0-0a71531ca93b@weissschuh.net> To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1697106227; l=1175; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=dcNGhXp5FPTom7QF06OFWt6twK9Wx0jnbCF/HnZ41vM=; b=Iad8VW67+qA6YLgatRKUO/dbPz3xzTYuvOSHdHEpMdPKfTICbIfy4mSCjas9tG9y14b1Q5eNN 58M7fGLO+jMAhHHV3SuHZoD3CSvt+G3f25G61eBrc9MgUUFGGNLWWuL X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 03:24:04 -0700 (PDT) Allow HID drivers to pass ->suspend, ->resume and ->reset_resume via pm_ptr(). Through the usage of pm_ptr() the CONFIG_PM-dependent code will always be compiled, protecting against bitrot. The linker will then garbage-collect the unused function avoiding any overhead. The only overhead in the final kernel image and at runtime are a few extra bytes in 'struct hid_driver'. The same approach is chosen by 'struct usb_driver' and other subsystems. Signed-off-by: Thomas Weißschuh --- include/linux/hid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/hid.h b/include/linux/hid.h index 964ca1f15e3f..5a8387a4a712 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -833,11 +833,11 @@ struct hid_driver { void (*feature_mapping)(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage); -#ifdef CONFIG_PM + int (*suspend)(struct hid_device *hdev, pm_message_t message); int (*resume)(struct hid_device *hdev); int (*reset_resume)(struct hid_device *hdev); -#endif + /* private: */ struct device_driver driver; }; -- 2.42.0