From patchwork Sat Jun 4 16:12:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12869633 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 59058C43334 for ; Sat, 4 Jun 2022 16:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234010AbiFDQDi (ORCPT ); Sat, 4 Jun 2022 12:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237979AbiFDQDh (ORCPT ); Sat, 4 Jun 2022 12:03:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1F9286DA for ; Sat, 4 Jun 2022 09:03:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CE515B8069B for ; Sat, 4 Jun 2022 16:03:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 335B6C36AE2; Sat, 4 Jun 2022 16:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654358613; bh=8P5cgBoQ0LFx+OobuC2cThdTEUmGj4AiNCg9VClTIl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/YSEcXWiFM5oOKdqNbxXCyG3DBYxPTvmI8WrpWJblKs6hBZU8nEf/FcEP4OEjD/I H5gr71OtlphzSi4+GJ+lYASqZRozG1GkHzaAAuvF8KWNe5CRZcftvwMe26zm+jAj2k hlhgxYBUZYWJiCin+OzeOd0qOyFUQz2hwgGpyWLU3Gac7G6ZLupxxyI/cN9td+n3fi 820+hcgO0lrZi59Jf8RmvYSyqws4D2DKtv2tR8GS/PT7JFThPgeWCoynhX2BJva0wm yXexD9qL/Rdi4pmiB5BN/uDmZ4atyMFZ0BJHicoQN3VHAW1YVLr6AkwZZl2Ys71WvG CF13ZVwdvy/Qw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Paul Cercueil , Lorenzo Bianconi Cc: Jonathan Cameron Subject: [RESEND PATCH 1/5] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Date: Sat, 4 Jun 2022 17:12:19 +0100 Message-Id: <20220604161223.461847-2-jic23@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220604161223.461847-1-jic23@kernel.org> References: <20220604161223.461847-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Letting the compiler remove these functions when the kernel is built without CONFIG_PM support is simpler and less error prone than the use of #ifdef based config guards. Removing instances of this approach from IIO also stops them being copied into new drivers. Signed-off-by: Jonathan Cameron Link: https://lore.kernel.org/r/20220220181522.541718-5-jic23@kernel.org --- drivers/iio/accel/kxsd9-i2c.c | 2 +- drivers/iio/accel/kxsd9-spi.c | 2 +- drivers/iio/accel/kxsd9.c | 11 ++--------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c index c8dc52f11037..d57f264bd6c8 100644 --- a/drivers/iio/accel/kxsd9-i2c.c +++ b/drivers/iio/accel/kxsd9-i2c.c @@ -55,7 +55,7 @@ static struct i2c_driver kxsd9_i2c_driver = { .driver = { .name = "kxsd9", .of_match_table = kxsd9_of_match, - .pm = &kxsd9_dev_pm_ops, + .pm = pm_ptr(&kxsd9_dev_pm_ops), }, .probe = kxsd9_i2c_probe, .remove = kxsd9_i2c_remove, diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c index b7b5af45429e..07f14a9f22c7 100644 --- a/drivers/iio/accel/kxsd9-spi.c +++ b/drivers/iio/accel/kxsd9-spi.c @@ -52,7 +52,7 @@ MODULE_DEVICE_TABLE(of, kxsd9_of_match); static struct spi_driver kxsd9_spi_driver = { .driver = { .name = "kxsd9", - .pm = &kxsd9_dev_pm_ops, + .pm = pm_ptr(&kxsd9_dev_pm_ops), .of_match_table = kxsd9_of_match, }, .probe = kxsd9_spi_probe, diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 3975860331a6..ba99649fe195 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -492,7 +492,6 @@ void kxsd9_common_remove(struct device *dev) } EXPORT_SYMBOL_NS(kxsd9_common_remove, IIO_KXSD9); -#ifdef CONFIG_PM static int kxsd9_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); @@ -508,15 +507,9 @@ static int kxsd9_runtime_resume(struct device *dev) return kxsd9_power_up(st); } -#endif /* CONFIG_PM */ -const struct dev_pm_ops kxsd9_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(kxsd9_runtime_suspend, - kxsd9_runtime_resume, NULL) -}; -EXPORT_SYMBOL_NS(kxsd9_dev_pm_ops, IIO_KXSD9); +EXPORT_NS_RUNTIME_DEV_PM_OPS(kxsd9_dev_pm_ops, kxsd9_runtime_suspend, + kxsd9_runtime_resume, NULL, IIO_KXSD9); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("Kionix KXSD9 driver"); From patchwork Sat Jun 4 16:12:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12869634 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 92369C433EF for ; Sat, 4 Jun 2022 16:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237979AbiFDQDi (ORCPT ); Sat, 4 Jun 2022 12:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237984AbiFDQDh (ORCPT ); Sat, 4 Jun 2022 12:03:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AE50286DC for ; Sat, 4 Jun 2022 09:03:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E18C760E9E for ; Sat, 4 Jun 2022 16:03:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D1D1C34119; Sat, 4 Jun 2022 16:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654358615; bh=5L5zfHOo9YjQc3aTFmxjI3nBGjZ4EU5LBpij1BpYUs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTMXtBVIQJaT2XwQQdVurQGjtW9P1fPWMCzVz2VTIT16lRPawisTm8CSq3HMS7btM cOMvOBsYN1ozYPQHyTO5k99WqkM+F7Nfcdu6Qxlj+6acn+s0xgXxu7Nspq4JdX/30h rAcCoeS/QadlkEQl/xaqvpls+LNAI1oIEEryaopK3Aoq/16vj9K0eG7xc32r46zUIB RFeNqTtKCGdhjEywTZGT0g4NkA4G5LMG6xbpjnWjSq0Pk5cnCSko10EfCrlRQ0XDSd rzxcl5USRGbSJIcuN7dEwItVxm/OOwJ6VkkTBIYIaVvgDutXG/8R1pV0lm7mg3z9kY 0AWORFLz8SutA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Paul Cercueil , Lorenzo Bianconi Cc: Jonathan Cameron Subject: [RESEND PATCH 2/5] iio: humidity: hts221: Use EXPORT_SIMPLE_DEV_PM_OPS() to allow compiler to remove dead code. Date: Sat, 4 Jun 2022 17:12:20 +0100 Message-Id: <20220604161223.461847-3-jic23@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220604161223.461847-1-jic23@kernel.org> References: <20220604161223.461847-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron If CONFIG_PM_SLEEP is not defined using EXPORT_SIMPLE_DEV_PM_OPS() in conjunction with pm_sleep_ptr() allows the compiler to remove the unused code and data. This removes the need for __maybe_unused markings etc. Signed-off-by: Jonathan Cameron Cc: Lorenzo Bianconi Link: https://lore.kernel.org/r/20220220181522.541718-6-jic23@kernel.org Acked-by: Lorenzo Bianconi --- drivers/iio/humidity/hts221_core.c | 9 +++------ drivers/iio/humidity/hts221_i2c.c | 2 +- drivers/iio/humidity/hts221_spi.c | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c index 6a39615b6961..da9c08432ef2 100644 --- a/drivers/iio/humidity/hts221_core.c +++ b/drivers/iio/humidity/hts221_core.c @@ -670,7 +670,7 @@ int hts221_probe(struct device *dev, int irq, const char *name, } EXPORT_SYMBOL(hts221_probe); -static int __maybe_unused hts221_suspend(struct device *dev) +static int hts221_suspend(struct device *dev) { struct iio_dev *iio_dev = dev_get_drvdata(dev); struct hts221_hw *hw = iio_priv(iio_dev); @@ -680,7 +680,7 @@ static int __maybe_unused hts221_suspend(struct device *dev) FIELD_PREP(HTS221_ENABLE_MASK, false)); } -static int __maybe_unused hts221_resume(struct device *dev) +static int hts221_resume(struct device *dev) { struct iio_dev *iio_dev = dev_get_drvdata(dev); struct hts221_hw *hw = iio_priv(iio_dev); @@ -694,10 +694,7 @@ static int __maybe_unused hts221_resume(struct device *dev) return err; } -const struct dev_pm_ops hts221_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(hts221_suspend, hts221_resume) -}; -EXPORT_SYMBOL(hts221_pm_ops); +EXPORT_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume); MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_DESCRIPTION("STMicroelectronics hts221 sensor driver"); diff --git a/drivers/iio/humidity/hts221_i2c.c b/drivers/iio/humidity/hts221_i2c.c index cab39c4756f8..933b05e4d972 100644 --- a/drivers/iio/humidity/hts221_i2c.c +++ b/drivers/iio/humidity/hts221_i2c.c @@ -62,7 +62,7 @@ MODULE_DEVICE_TABLE(i2c, hts221_i2c_id_table); static struct i2c_driver hts221_driver = { .driver = { .name = "hts221_i2c", - .pm = &hts221_pm_ops, + .pm = pm_sleep_ptr(&hts221_pm_ops), .of_match_table = hts221_i2c_of_match, .acpi_match_table = ACPI_PTR(hts221_acpi_match), }, diff --git a/drivers/iio/humidity/hts221_spi.c b/drivers/iio/humidity/hts221_spi.c index 729e86e433b1..888c5eab944c 100644 --- a/drivers/iio/humidity/hts221_spi.c +++ b/drivers/iio/humidity/hts221_spi.c @@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(spi, hts221_spi_id_table); static struct spi_driver hts221_driver = { .driver = { .name = "hts221_spi", - .pm = &hts221_pm_ops, + .pm = pm_sleep_ptr(&hts221_pm_ops), .of_match_table = hts221_spi_of_match, }, .probe = hts221_spi_probe, From patchwork Sat Jun 4 16:12:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12869635 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 17A9CC433EF for ; Sat, 4 Jun 2022 16:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237992AbiFDQDm (ORCPT ); Sat, 4 Jun 2022 12:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237984AbiFDQDm (ORCPT ); Sat, 4 Jun 2022 12:03:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5066286DB for ; Sat, 4 Jun 2022 09:03:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8E382B8069B for ; Sat, 4 Jun 2022 16:03:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB4E4C36AE3; Sat, 4 Jun 2022 16:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654358617; bh=0SOx3c6aBcif/9j7gTE3UpXYNkrXr8ovQONA+oZ14Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ck0laejdfbYG1k77Y6fVR/9xar9jJLBQWAbFkr3QwtZi3rO2AevLMLTNbA5quKStn zLrGXq1ubg8AWMILPL+PBB5xXPUP6+if3DYrczj1SahVAtHLap00wsWQDw+HGGi6Tj 84jGzd9d96QKm2o5tTDntTRLRp5FThkjaEx3K3z/TO3H23z2FduN0r038T8A/1cGNQ Yh5NVraqSkVWUts8iv0ELAs3e8A5O788OFM3UEzLtJuiDPxW7gCDR5KLL5PLjvp9Ih WpsOLJjS1A5ZssNgJz+9cWAIb95T5tzSjI6gPW80ZhsnQAaCtU0OEn9HZm4ZeABLar GbV/gVOzAgWpQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Paul Cercueil , Lorenzo Bianconi Cc: Jonathan Cameron Subject: [RESEND PATCH 3/5] iio: humidity: hts221: Move symbol exports into IIO_HTS221 namespace Date: Sat, 4 Jun 2022 17:12:21 +0100 Message-Id: <20220604161223.461847-4-jic23@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220604161223.461847-1-jic23@kernel.org> References: <20220604161223.461847-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Avoid unnecessary pollution of the global symbol namespace by moving library functions in to a specific namespace and import that into the drivers that make use of the functions. For more info: https://lwn.net/Articles/760045/ Signed-off-by: Jonathan Cameron Cc: Lorenzo Bianconi Link: https://lore.kernel.org/r/20220220181522.541718-7-jic23@kernel.org Acked-by: Lorenzo Bianconi --- drivers/iio/humidity/hts221_core.c | 5 +++-- drivers/iio/humidity/hts221_i2c.c | 1 + drivers/iio/humidity/hts221_spi.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c index da9c08432ef2..517158307d8c 100644 --- a/drivers/iio/humidity/hts221_core.c +++ b/drivers/iio/humidity/hts221_core.c @@ -668,7 +668,7 @@ int hts221_probe(struct device *dev, int irq, const char *name, return devm_iio_device_register(hw->dev, iio_dev); } -EXPORT_SYMBOL(hts221_probe); +EXPORT_SYMBOL_NS(hts221_probe, IIO_HTS221); static int hts221_suspend(struct device *dev) { @@ -694,7 +694,8 @@ static int hts221_resume(struct device *dev) return err; } -EXPORT_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume); +EXPORT_NS_SIMPLE_DEV_PM_OPS(hts221_pm_ops, hts221_suspend, hts221_resume, + IIO_HTS221); MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_DESCRIPTION("STMicroelectronics hts221 sensor driver"); diff --git a/drivers/iio/humidity/hts221_i2c.c b/drivers/iio/humidity/hts221_i2c.c index 933b05e4d972..afbc611f7712 100644 --- a/drivers/iio/humidity/hts221_i2c.c +++ b/drivers/iio/humidity/hts221_i2c.c @@ -74,3 +74,4 @@ module_i2c_driver(hts221_driver); MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_DESCRIPTION("STMicroelectronics hts221 i2c driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(IIO_HTS221); diff --git a/drivers/iio/humidity/hts221_spi.c b/drivers/iio/humidity/hts221_spi.c index 888c5eab944c..fc4adb68faf6 100644 --- a/drivers/iio/humidity/hts221_spi.c +++ b/drivers/iio/humidity/hts221_spi.c @@ -66,3 +66,4 @@ module_spi_driver(hts221_driver); MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_DESCRIPTION("STMicroelectronics hts221 spi driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(IIO_HTS221); From patchwork Sat Jun 4 16:12:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12869636 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 7CC26C43334 for ; Sat, 4 Jun 2022 16:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237984AbiFDQDn (ORCPT ); Sat, 4 Jun 2022 12:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238002AbiFDQDm (ORCPT ); Sat, 4 Jun 2022 12:03:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1309286DA for ; Sat, 4 Jun 2022 09:03:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C685B8070D for ; Sat, 4 Jun 2022 16:03:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1456C36AE5; Sat, 4 Jun 2022 16:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654358619; bh=0J10Zn3+jeOQvbAvatRYZsyjd3qtmvlN3vkoNStEc74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DRRQ7DwEiuKvJnsSqjJqJcO1slUApqhSa65G/dmqafm7FSXy+9GF3/3JZw4EGu3xZ DysHrG1nU+nTNNd5mnpnJ7Rq0jTpowVEvii/Ff8/YrSGbtC+SSOooC6EwlK0K4nywr 3rRxITWD0AVfpX0egUrbLYtE14cje3gPPmaxqu80srwLA5VT00yCEw8ef6FtDP7xVV 1wyWDxwOMF/HBDrBxG2Y1K4Vh3lQhuXTnWLDsWgorgMfFdP0Ya2qo0QXsPgv7m8n3Y X80bBIuS6CuuWYUWLAX6Fezdnc9kTe+/lSfLf3mEpcVwN3DfIV9iswE4ynyCW/Hhml E2qHlh4NaXS1Q== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Paul Cercueil , Lorenzo Bianconi Cc: Jonathan Cameron Subject: [RESEND PATCH 4/5] iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS() Date: Sat, 4 Jun 2022 17:12:22 +0100 Message-Id: <20220604161223.461847-5-jic23@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220604161223.461847-1-jic23@kernel.org> References: <20220604161223.461847-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron These new functions move the burden of removing unused code when CONFIG_PM_SLEEP is not defined onto the compiler rather than requiring the use of CONFIG_PM guards and similar. Signed-off-by: Jonathan Cameron Link: https://lore.kernel.org/r/20220220181522.541718-8-jic23@kernel.org Acked-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 10 ++++------ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 2 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c | 2 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 910397716833..9e4aa5c1c8d6 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2291,7 +2291,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, } EXPORT_SYMBOL(st_lsm6dsx_probe); -static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) +static int st_lsm6dsx_suspend(struct device *dev) { struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); struct st_lsm6dsx_sensor *sensor; @@ -2330,7 +2330,7 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) return err; } -static int __maybe_unused st_lsm6dsx_resume(struct device *dev) +static int st_lsm6dsx_resume(struct device *dev) { struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); struct st_lsm6dsx_sensor *sensor; @@ -2366,10 +2366,8 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev) return err; } -const struct dev_pm_ops st_lsm6dsx_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume) -}; -EXPORT_SYMBOL(st_lsm6dsx_pm_ops); +EXPORT_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend, + st_lsm6dsx_resume); MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_AUTHOR("Denis Ciocca "); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c index 715fbdc8190e..5bd565b93a8c 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c @@ -134,7 +134,7 @@ MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table); static struct i2c_driver st_lsm6dsx_driver = { .driver = { .name = "st_lsm6dsx_i2c", - .pm = &st_lsm6dsx_pm_ops, + .pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops), .of_match_table = st_lsm6dsx_i2c_of_match, }, .probe = st_lsm6dsx_i2c_probe, diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c index 35556cd04284..4df186499802 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c @@ -44,7 +44,7 @@ static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev) static struct i3c_driver st_lsm6dsx_driver = { .driver = { .name = "st_lsm6dsx_i3c", - .pm = &st_lsm6dsx_pm_ops, + .pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops), }, .probe = st_lsm6dsx_i3c_probe, .id_table = st_lsm6dsx_i3c_ids, diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c index f5767cf76c1d..3a206fd4d92c 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c @@ -134,7 +134,7 @@ MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table); static struct spi_driver st_lsm6dsx_driver = { .driver = { .name = "st_lsm6dsx_spi", - .pm = &st_lsm6dsx_pm_ops, + .pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops), .of_match_table = st_lsm6dsx_spi_of_match, }, .probe = st_lsm6dsx_spi_probe, From patchwork Sat Jun 4 16:12:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12869637 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 E8A5BCCA47E for ; Sat, 4 Jun 2022 16:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237997AbiFDQDo (ORCPT ); Sat, 4 Jun 2022 12:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238001AbiFDQDm (ORCPT ); Sat, 4 Jun 2022 12:03:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A92E286DC for ; Sat, 4 Jun 2022 09:03:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BAD1160EAC for ; Sat, 4 Jun 2022 16:03:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7AD5C36AE3; Sat, 4 Jun 2022 16:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654358621; bh=OP7pdcy9mvPtKqyf66TsRtMflMNN83QaB0NJ+Wj/WGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IL1W3vm3RKLv0gmBTXnM6VgfYu8OGkrJ3M1O6eSnHyge2cjsWF6nQEck+WOikX5yA m6kIrb9N8orq8YVXn9ix67AUAFqYVEVIFwHF/zwH/iJ5AiXgs8Q2qn0g9Q5j3fcf1V kwW2+oKxHEWon2YV3taF6eNhRN9iKLClo8nb0Ag+tikfRUu4V94CPaJ0tqdYK0y79g VaVLrqbTbZawPbTlhxZT1ygwQIfH9hLBzJy41c94dp415X5ySIuP2ngYLRpEV3KV1f VINTPSxxF+sZY+iiysbORnrbioyzNmGzJNPyd+LuLNLjahZmYaKZtN4pKuW1ifavCa 5QRip/c3bX1ZQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Paul Cercueil , Lorenzo Bianconi Cc: Jonathan Cameron Subject: [RESEND PATCH 5/5] iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace Date: Sat, 4 Jun 2022 17:12:23 +0100 Message-Id: <20220604161223.461847-6-jic23@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220604161223.461847-1-jic23@kernel.org> References: <20220604161223.461847-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Avoid unnecessary pollution of the global symbol namespace by moving library functions in to a specific namespace and import that into the drivers that make use of the functions. For more info: https://lwn.net/Articles/760045/ Signed-off-by: Jonathan Cameron Link: https://lore.kernel.org/r/20220220181522.541718-9-jic23@kernel.org Acked-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 +++--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 1 + drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c | 1 + drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 9e4aa5c1c8d6..6b268f1c5fc3 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2289,7 +2289,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, return 0; } -EXPORT_SYMBOL(st_lsm6dsx_probe); +EXPORT_SYMBOL_NS(st_lsm6dsx_probe, IIO_LSM6DSX); static int st_lsm6dsx_suspend(struct device *dev) { @@ -2366,8 +2366,8 @@ static int st_lsm6dsx_resume(struct device *dev) return err; } -EXPORT_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend, - st_lsm6dsx_resume); +EXPORT_NS_SIMPLE_DEV_PM_OPS(st_lsm6dsx_pm_ops, st_lsm6dsx_suspend, + st_lsm6dsx_resume, IIO_LSM6DSX); MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_AUTHOR("Denis Ciocca "); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c index 5bd565b93a8c..2ea34c0d3a8c 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c @@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_AUTHOR("Denis Ciocca "); MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i2c driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(IIO_LSM6DSX); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c index 4df186499802..3b0c8b19c448 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c @@ -54,3 +54,4 @@ module_i3c_driver(st_lsm6dsx_driver); MODULE_AUTHOR("Vitor Soares "); MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i3c driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(IIO_LSM6DSX); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c index 3a206fd4d92c..6a8883f022a8 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c @@ -146,3 +146,4 @@ MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_AUTHOR("Denis Ciocca "); MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx spi driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(IIO_LSM6DSX);