From patchwork Tue Sep 27 14:28:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 610659 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 0DB81C6FA92 for ; Tue, 27 Sep 2022 14:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbiI0O2Z (ORCPT ); Tue, 27 Sep 2022 10:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231974AbiI0O2O (ORCPT ); Tue, 27 Sep 2022 10:28:14 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DDEA1857BF; Tue, 27 Sep 2022 07:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664288893; x=1695824893; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cGiBw8L0ywgUyx1iTQQodYnhEJ/yQh4jXSXjDl9NZPU=; b=KnnM+75F+3zK44k+OT8tZVlBxacbRF9my+XVgO/I7BNcYLgsdsRU7KUI dusHHpWIS0FDnBjf4vGBatCZ/VYI3gN7gchpsAQgezWwV6jU4+RRFscBr NR1bekf4jYeYo+dluvUK2fv918gak7Abqdldpafr1PVbp9vOvEALhpBmR 75ddTT032xP0HgTxjSFZwhcI03BBwZnMZvbPjCNDSCDrcVB6+Kyc//h0B G7aMRZgV+kWT/5dxDuDiJpFDqVE1Ky4bCagRBgMfaMvoMYkAF1rvVOI6/ Etmbv+gs1A52dimUFwsZesGTrdDaGYBi0ciA7st44MAoNZZsDEYETuOiC A==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="302808028" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="302808028" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 07:28:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="684008507" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="684008507" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 27 Sep 2022 07:28:08 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DFA38F7; Tue, 27 Sep 2022 17:28:26 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Prashant Malani , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Date: Tue, 27 Sep 2022 17:28:17 +0300 Message-Id: <20220927142822.4095-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: linux-acpi@vger.kernel.org It's not fully correct to take a const parameter pointer to a struct and return a non-const pointer to a member of that struct. Instead, introduce a const version of the dev_fwnode() API which takes and returns const pointers and use it where it's applicable. Suggested-by: Sakari Ailus Fixes: aade55c86033 ("device property: Add const qualifier to device_get_match_data() parameter") Signed-off-by: Andy Shevchenko --- drivers/base/property.c | 11 +++++++++-- include/linux/property.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 4d6278a84868..699f1b115e0a 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -17,13 +17,20 @@ #include #include -struct fwnode_handle *dev_fwnode(const struct device *dev) +struct fwnode_handle *dev_fwnode(struct device *dev) { return IS_ENABLED(CONFIG_OF) && dev->of_node ? of_fwnode_handle(dev->of_node) : dev->fwnode; } EXPORT_SYMBOL_GPL(dev_fwnode); +const struct fwnode_handle *dev_fwnode_const(const struct device *dev) +{ + return IS_ENABLED(CONFIG_OF) && dev->of_node ? + of_fwnode_handle(dev->of_node) : dev->fwnode; +} +EXPORT_SYMBOL_GPL(dev_fwnode_const); + /** * device_property_present - check if a property of a device is present * @dev: Device whose property is being checked @@ -1202,7 +1209,7 @@ EXPORT_SYMBOL(fwnode_graph_parse_endpoint); const void *device_get_match_data(const struct device *dev) { - return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); + return fwnode_call_ptr_op(dev_fwnode_const(dev), device_get_match_data, dev); } EXPORT_SYMBOL_GPL(device_get_match_data); diff --git a/include/linux/property.h b/include/linux/property.h index 117cc200c656..ae5d7f8eccf4 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -32,7 +32,8 @@ enum dev_dma_attr { DEV_DMA_COHERENT, }; -struct fwnode_handle *dev_fwnode(const struct device *dev); +struct fwnode_handle *dev_fwnode(struct device *dev); +const struct fwnode_handle *dev_fwnode_const(const struct device *dev); bool device_property_present(struct device *dev, const char *propname); int device_property_read_u8_array(struct device *dev, const char *propname, From patchwork Tue Sep 27 14:28:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 609629 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 D2208C6FA8E for ; Tue, 27 Sep 2022 14:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232137AbiI0O23 (ORCPT ); Tue, 27 Sep 2022 10:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbiI0O2O (ORCPT ); Tue, 27 Sep 2022 10:28:14 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1360F3FA3; Tue, 27 Sep 2022 07:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664288893; x=1695824893; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6GnvNvsRVzevPy91Tli/IN1ZpRHSoqDRvpUzQPBiTDI=; b=M7LirVhCLf6HT/NGjBpu6I0czX4rsZvwAO48481fGNgfHt3C44mL+Hoc V9TkrkPKpJWAdCkCNzIkjsRrlfB9MXv/upCEAKAAhmT8ns7VkUfU3wvIK rt4JBQ+aYHRiasozL6xcOa6OFYExGCyNsMvEOCYQjNV0GiJBl6eHoPj3W nczV/nPSn34pk8g9gfXWP94nzUkDXefNtfKVXoMsJvsiXnpGcuiUQhRxb Y/x3CHOj31wtLe3I+2M8KuqJaEtT/0k0+PBn0DVwBz5/RcuwsBQCH8WN6 Nuy3KOh0LzE+kAZfSJvPN3z78jwOtGPRSP4pcJCOZwoGGEh0qgQwDNzmC g==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="365370925" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="365370925" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 07:28:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="616845983" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="616845983" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 27 Sep 2022 07:28:08 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E8EC87C; Tue, 27 Sep 2022 17:28:26 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Prashant Malani , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v1 2/5] device property: Constify fwnode connection match APIs Date: Tue, 27 Sep 2022 17:28:18 +0300 Message-Id: <20220927142822.4095-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> References: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The fwnode and device parameters are not altered in the fwnode connection match APIs, constify them. Signed-off-by: Andy Shevchenko --- drivers/base/property.c | 8 ++++---- drivers/usb/roles/class.c | 2 +- drivers/usb/typec/retimer.c | 2 +- include/linux/property.h | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 699f1b115e0a..1a1616c9b599 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1213,7 +1213,7 @@ const void *device_get_match_data(const struct device *dev) } EXPORT_SYMBOL_GPL(device_get_match_data); -static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, +static unsigned int fwnode_graph_devcon_matches(const struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match, void **matches, @@ -1247,7 +1247,7 @@ static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, return count; } -static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode, +static unsigned int fwnode_devcon_matches(const struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match, void **matches, @@ -1289,7 +1289,7 @@ static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode, * device node. @match will be used to convert the connection description to * data the caller is expecting to be returned. */ -void *fwnode_connection_find_match(struct fwnode_handle *fwnode, +void *fwnode_connection_find_match(const struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match) { @@ -1326,7 +1326,7 @@ EXPORT_SYMBOL_GPL(fwnode_connection_find_match); * * Return: Number of matches resolved, or negative errno. */ -int fwnode_connection_find_matches(struct fwnode_handle *fwnode, +int fwnode_connection_find_matches(const struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match, void **matches, unsigned int matches_len) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index dfaed7eee94f..a3575a5a18ce 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -87,7 +87,7 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw) } EXPORT_SYMBOL_GPL(usb_role_switch_get_role); -static void *usb_role_switch_match(struct fwnode_handle *fwnode, const char *id, +static void *usb_role_switch_match(const struct fwnode_handle *fwnode, const char *id, void *data) { struct device *dev; diff --git a/drivers/usb/typec/retimer.c b/drivers/usb/typec/retimer.c index 2003731f1bee..8edfdc709a28 100644 --- a/drivers/usb/typec/retimer.c +++ b/drivers/usb/typec/retimer.c @@ -34,7 +34,7 @@ static int retimer_fwnode_match(struct device *dev, const void *fwnode) return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-retimer"); } -static void *typec_retimer_match(struct fwnode_handle *fwnode, const char *id, void *data) +static void *typec_retimer_match(const struct fwnode_handle *fwnode, const char *id, void *data) { struct device *dev; diff --git a/include/linux/property.h b/include/linux/property.h index ae5d7f8eccf4..6f9d6604edc3 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -438,21 +438,21 @@ unsigned int fwnode_graph_get_endpoint_count(struct fwnode_handle *fwnode, int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); -typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id, +typedef void *(*devcon_match_fn_t)(const struct fwnode_handle *fwnode, const char *id, void *data); -void *fwnode_connection_find_match(struct fwnode_handle *fwnode, +void *fwnode_connection_find_match(const struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match); -static inline void *device_connection_find_match(struct device *dev, +static inline void *device_connection_find_match(const struct device *dev, const char *con_id, void *data, devcon_match_fn_t match) { - return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match); + return fwnode_connection_find_match(dev_fwnode_const(dev), con_id, data, match); } -int fwnode_connection_find_matches(struct fwnode_handle *fwnode, +int fwnode_connection_find_matches(const struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match, void **matches, unsigned int matches_len); From patchwork Tue Sep 27 14:28:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 609631 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 6CF0CC54EE9 for ; Tue, 27 Sep 2022 14:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232045AbiI0O2X (ORCPT ); Tue, 27 Sep 2022 10:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232311AbiI0O2N (ORCPT ); Tue, 27 Sep 2022 10:28:13 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86A6518699F; Tue, 27 Sep 2022 07:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664288891; x=1695824891; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OpCYS+dBiHi5I1/btU2nR0TfLX5a+7mXaU5C2OHUqa4=; b=iB7MXCvg2KgzUsjiB5jlwjVeEL40xvByut4d3e2R1tQ4C7uIkyrnuFpB C5lwHd/ue7SYvz2pzaOvGyerq7cLdUsgip5pnltilHDmJPLR229/CrEdZ LJfU1hRafyUNAIwK3+RIpu0RAncYM8AnbxFUirDTxM6e5+NtUoGgonVRi HDs8cmsayRLL3SfA+u7ZjtSLEpSAaTF0GxpKwXmzEO9UCkMNO8fbIOQGi sBzIwXrnGB5nx5G/IqCtoegK02OnjfmRdQJ6ZSSJfF0ir1zBk1fKhUvfL AYsuzkZAylQJnY+YgFHR4RN4XHszl1p4lLJk9yGsHV9OA3YxSq1jCgXJD Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="365370927" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="365370927" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 07:28:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="616845985" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="616845985" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 27 Sep 2022 07:28:08 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 00B41235; Tue, 27 Sep 2022 17:28:26 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Prashant Malani , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v1 3/5] device property: Constify parameter in fwnode_graph_is_endpoint() Date: Tue, 27 Sep 2022 17:28:19 +0300 Message-Id: <20220927142822.4095-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> References: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Constify parameter in fwnode_graph_is_endpoint() since it doesn't alter anything related to it. Signed-off-by: Andy Shevchenko --- include/linux/property.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/property.h b/include/linux/property.h index 6f9d6604edc3..fe440211e529 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -406,7 +406,7 @@ struct fwnode_handle *fwnode_graph_get_remote_port( struct fwnode_handle *fwnode_graph_get_remote_endpoint( const struct fwnode_handle *fwnode); -static inline bool fwnode_graph_is_endpoint(struct fwnode_handle *fwnode) +static inline bool fwnode_graph_is_endpoint(const struct fwnode_handle *fwnode) { return fwnode_property_present(fwnode, "remote-endpoint"); } From patchwork Tue Sep 27 14:28:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 609630 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 D231EC6FA8E for ; Tue, 27 Sep 2022 14:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232072AbiI0O2Y (ORCPT ); Tue, 27 Sep 2022 10:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbiI0O2N (ORCPT ); Tue, 27 Sep 2022 10:28:13 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16DA7186990; Tue, 27 Sep 2022 07:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664288892; x=1695824892; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cc1aFjYUO4SDChMPwPNv5Bv/vhNv4tExWF8sOyp8IOc=; b=AvtXbPzYTPnufJQiza+ZRHIPXhXeWSgPSD+kvl3K+YPqvweu7aF+Wco8 3KX5tQpUPfbkZhew7Kl9nEAyrnUM1DDiH/llettZtkTYHkGA9OXcyXiBn gthYOECzUS0yiIQmeC4/7JYL8oJdvTTwXzYchh+hwj0D/5dhpwRKre9zk SxXypEAqgQRY7o7CS9+gcKKgfDJsjoL3jfWFxi3uzFwOs9m7G0SWfMBCc xaOIZcZeIYjpkXjpvZ7RI+TgGtAf3D3tdsG4ECcG3RfrpUY4MeMCa8+YD 2phU6KEOr90Mt6GZMyX+Xcj56td6+9LlW+9bJaMYGfDj3vkNV72TXvQ6j w==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="302808026" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="302808026" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 07:28:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="684008506" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="684008506" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 27 Sep 2022 07:28:08 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 08235265; Tue, 27 Sep 2022 17:28:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Prashant Malani , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v1 4/5] device property: Constify device child node APIs Date: Tue, 27 Sep 2022 17:28:20 +0300 Message-Id: <20220927142822.4095-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> References: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The device parameter is not altered in the device child node APIs, constify them. Signed-off-by: Andy Shevchenko --- drivers/base/property.c | 10 +++++----- include/linux/property.h | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 1a1616c9b599..04eb5e0ab407 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -763,10 +763,10 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node); * @dev: Device to find the next child node for. * @child: Handle to one of the device's child nodes or a null handle. */ -struct fwnode_handle *device_get_next_child_node(struct device *dev, +struct fwnode_handle *device_get_next_child_node(const struct device *dev, struct fwnode_handle *child) { - const struct fwnode_handle *fwnode = dev_fwnode(dev); + const struct fwnode_handle *fwnode = dev_fwnode_const(dev); struct fwnode_handle *next; if (IS_ERR_OR_NULL(fwnode)) @@ -800,10 +800,10 @@ EXPORT_SYMBOL_GPL(fwnode_get_named_child_node); * @dev: Device to find the named child node for. * @childname: String to match child node name against. */ -struct fwnode_handle *device_get_named_child_node(struct device *dev, +struct fwnode_handle *device_get_named_child_node(const struct device *dev, const char *childname) { - return fwnode_get_named_child_node(dev_fwnode(dev), childname); + return fwnode_get_named_child_node(dev_fwnode_const(dev), childname); } EXPORT_SYMBOL_GPL(device_get_named_child_node); @@ -859,7 +859,7 @@ EXPORT_SYMBOL_GPL(fwnode_device_is_available); * device_get_child_node_count - return the number of child nodes for device * @dev: Device to cound the child nodes for */ -unsigned int device_get_child_node_count(struct device *dev) +unsigned int device_get_child_node_count(const struct device *dev) { struct fwnode_handle *child; unsigned int count = 0; diff --git a/include/linux/property.h b/include/linux/property.h index fe440211e529..31dd6cbea9b0 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -110,16 +110,16 @@ struct fwnode_handle *fwnode_get_next_available_child_node( for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\ child = fwnode_get_next_available_child_node(fwnode, child)) -struct fwnode_handle *device_get_next_child_node( - struct device *dev, struct fwnode_handle *child); +struct fwnode_handle *device_get_next_child_node(const struct device *dev, + struct fwnode_handle *child); #define device_for_each_child_node(dev, child) \ for (child = device_get_next_child_node(dev, NULL); child; \ child = device_get_next_child_node(dev, child)) -struct fwnode_handle *fwnode_get_named_child_node( - const struct fwnode_handle *fwnode, const char *childname); -struct fwnode_handle *device_get_named_child_node(struct device *dev, +struct fwnode_handle *fwnode_get_named_child_node(const struct fwnode_handle *fwnode, + const char *childname); +struct fwnode_handle *device_get_named_child_node(const struct device *dev, const char *childname); struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); @@ -128,7 +128,7 @@ void fwnode_handle_put(struct fwnode_handle *fwnode); int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name); -unsigned int device_get_child_node_count(struct device *dev); +unsigned int device_get_child_node_count(const struct device *dev); static inline bool device_property_read_bool(struct device *dev, const char *propname) From patchwork Tue Sep 27 14:28:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 610658 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 B2D6EC6FA82 for ; Tue, 27 Sep 2022 14:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232181AbiI0O20 (ORCPT ); Tue, 27 Sep 2022 10:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232342AbiI0O2O (ORCPT ); Tue, 27 Sep 2022 10:28:14 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C121EF0AF; Tue, 27 Sep 2022 07:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664288893; x=1695824893; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Ldno0VG4b7OFqx4NzeiuH/7QWhkds3QSmsBZXHBdbQ=; b=jq9hNAvqdGATEeVZxFo5W7XGKbbbJN6oUBFWQgCYrv5705qBl/SmSBrG El98UFG4lKQE7ckMgKLg3VG0XRT4CuqHfLoOVDCHowAks4118JQV4bG9v GJDfQw41tk/S2eyww2Se5r55w6ZbXmXxbJYL37hJv5tktpXs/jS0CEtOt j2euaRVYutMsWzX399qxxvbqiop+dfepWZYIkPKhZt92GqXGpQSn1sZaV N6pZhvdkq+b3801Z6jgOMwmGMBAoyLbvZ/2QnDikdGZujDugSWvmQI+ZX z3KvmtmK5ZceN8Ju3eR8Xys4mB0hHXRI+Nqqe6Ava8XlvO81FVkXcsyMI w==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="365370926" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="365370926" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 07:28:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="616845984" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="616845984" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 27 Sep 2022 07:28:08 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 149F9268; Tue, 27 Sep 2022 17:28:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Prashant Malani , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v1 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr() Date: Tue, 27 Sep 2022 17:28:21 +0300 Message-Id: <20220927142822.4095-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> References: <20220927142822.4095-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Constify parameter in device_dma_supported() and device_get_dma_attr() since they don't alter anything related to it. Signed-off-by: Andy Shevchenko --- drivers/base/property.c | 10 +++++----- include/linux/property.h | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 04eb5e0ab407..5b0417f7e561 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -871,18 +871,18 @@ unsigned int device_get_child_node_count(const struct device *dev) } EXPORT_SYMBOL_GPL(device_get_child_node_count); -bool device_dma_supported(struct device *dev) +bool device_dma_supported(const struct device *dev) { - return fwnode_call_bool_op(dev_fwnode(dev), device_dma_supported); + return fwnode_call_bool_op(dev_fwnode_const(dev), device_dma_supported); } EXPORT_SYMBOL_GPL(device_dma_supported); -enum dev_dma_attr device_get_dma_attr(struct device *dev) +enum dev_dma_attr device_get_dma_attr(const struct device *dev) { - if (!fwnode_has_op(dev_fwnode(dev), device_get_dma_attr)) + if (!fwnode_has_op(dev_fwnode_const(dev), device_get_dma_attr)) return DEV_DMA_NOT_SUPPORTED; - return fwnode_call_int_op(dev_fwnode(dev), device_get_dma_attr); + return fwnode_call_int_op(dev_fwnode_const(dev), device_get_dma_attr); } EXPORT_SYMBOL_GPL(device_get_dma_attr); diff --git a/include/linux/property.h b/include/linux/property.h index 31dd6cbea9b0..a9498757155d 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -384,9 +384,8 @@ property_entries_dup(const struct property_entry *properties); void property_entries_free(const struct property_entry *properties); -bool device_dma_supported(struct device *dev); - -enum dev_dma_attr device_get_dma_attr(struct device *dev); +bool device_dma_supported(const struct device *dev); +enum dev_dma_attr device_get_dma_attr(const struct device *dev); const void *device_get_match_data(const struct device *dev);