public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Linux ACPI <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	David Box <david.e.box@linux.intel.com>
Subject: [PATCH v1 4/8] thermal: intel: intel_pch: Eliminate device operations object
Date: Mon, 30 Jan 2023 20:02:19 +0100	[thread overview]
Message-ID: <2141577.Mh6RI2rZIc@kreacher> (raw)
In-Reply-To: <1751684.VLH7GnMWUR@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The same device operations object is pointed to by all of the board
configurations in the driver, so effectively the same operations
callbacks are used by all of them which only adds overhead (that can
be significant due to retpolines) for no real purpose.

For this reason, drop the device operations object and replace the
respective callback invocations by direct calls to the specific
functions that were previously pointed to by callback pointers.

No intentional change in behavior.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/intel/intel_pch_thermal.c |   33 +++---------------------------
 1 file changed, 4 insertions(+), 29 deletions(-)

Index: linux-pm/drivers/thermal/intel/intel_pch_thermal.c
===================================================================
--- linux-pm.orig/drivers/thermal/intel/intel_pch_thermal.c
+++ linux-pm/drivers/thermal/intel/intel_pch_thermal.c
@@ -82,7 +82,6 @@ static char driver_name[] = "Intel PCH t
 
 struct pch_thermal_device {
 	void __iomem *hw_base;
-	const struct pch_dev_ops *ops;
 	struct pci_dev *pdev;
 	struct thermal_zone_device *tzd;
 	struct thermal_trip trips[PCH_MAX_TRIPS];
@@ -251,25 +250,11 @@ static int pch_resume(struct pch_thermal
 	return 0;
 }
 
-struct pch_dev_ops {
-	int (*hw_init)(struct pch_thermal_device *ptd);
-	int (*get_temp)(struct pch_thermal_device *ptd);
-	int (*suspend)(struct pch_thermal_device *ptd);
-	int (*resume)(struct pch_thermal_device *ptd);
-};
-
-static const struct pch_dev_ops pch_dev_ops = {
-	.hw_init = pch_hw_init,
-	.get_temp = pch_get_temp,
-	.suspend = pch_suspend,
-	.resume = pch_resume,
-};
-
 static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp)
 {
 	struct pch_thermal_device *ptd = tzd->devdata;
 
-	*temp = ptd->ops->get_temp(ptd);
+	*temp = pch_get_temp(ptd);
 	return 0;
 }
 
@@ -295,35 +280,27 @@ enum board_ids {
 
 static const struct board_info {
 	const char *name;
-	const struct pch_dev_ops *ops;
 } board_info[] = {
 	[board_hsw] = {
 		.name = "pch_haswell",
-		.ops = &pch_dev_ops,
 	},
 	[board_wpt] = {
 		.name = "pch_wildcat_point",
-		.ops = &pch_dev_ops,
 	},
 	[board_skl] = {
 		.name = "pch_skylake",
-		.ops = &pch_dev_ops,
 	},
 	[board_cnl] = {
 		.name = "pch_cannonlake",
-		.ops = &pch_dev_ops,
 	},
 	[board_cml] = {
 		.name = "pch_cometlake",
-		.ops = &pch_dev_ops,
 	},
 	[board_lwb] = {
 		.name = "pch_lewisburg",
-		.ops = &pch_dev_ops,
 	},
 	[board_wbg] = {
 		.name = "pch_wellsburg",
-		.ops = &pch_dev_ops,
 	},
 };
 
@@ -340,8 +317,6 @@ static int intel_pch_thermal_probe(struc
 	if (!ptd)
 		return -ENOMEM;
 
-	ptd->ops = bi->ops;
-
 	pci_set_drvdata(pdev, ptd);
 	ptd->pdev = pdev;
 
@@ -364,7 +339,7 @@ static int intel_pch_thermal_probe(struc
 		goto error_release;
 	}
 
-	nr_trips = ptd->ops->hw_init(ptd);
+	nr_trips = pch_hw_init(ptd);
 	if (nr_trips < 0) {
 		err = nr_trips;
 		goto error_cleanup;
@@ -412,14 +387,14 @@ static int intel_pch_thermal_suspend_noi
 {
 	struct pch_thermal_device *ptd = dev_get_drvdata(device);
 
-	return ptd->ops->suspend(ptd);
+	return pch_suspend(ptd);
 }
 
 static int intel_pch_thermal_resume(struct device *device)
 {
 	struct pch_thermal_device *ptd = dev_get_drvdata(device);
 
-	return ptd->ops->resume(ptd);
+	return pch_resume(ptd);
 }
 
 static const struct pci_device_id intel_pch_thermal_id[] = {




  parent reply	other threads:[~2023-01-30 19:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 18:56 [PATCH v1 0/8] thermal: intel: intel_pch: Code simplification and cleanups Rafael J. Wysocki
2023-01-30 18:58 ` [PATCH v1 1/8] thermal: intel: intel_pch: Make pch_wpt_add_acpi_psv_trip() return int Rafael J. Wysocki
2023-01-31 13:16   ` Daniel Lezcano
2023-01-30 18:59 ` [PATCH v1 2/8] thermal: intel: intel_pch: Eliminate redundant return pointers Rafael J. Wysocki
2023-01-31 13:19   ` Daniel Lezcano
2023-01-31 14:54   ` Daniel Lezcano
2023-01-30 19:00 ` [PATCH v1 3/8] thermal: intel: intel_pch: Rename device operations callbacks Rafael J. Wysocki
2023-01-31 14:55   ` Daniel Lezcano
2023-01-30 19:02 ` Rafael J. Wysocki [this message]
2023-01-31 14:57   ` [PATCH v1 4/8] thermal: intel: intel_pch: Eliminate device operations object Daniel Lezcano
2023-01-30 19:03 ` [PATCH v1 5/8] thermal: intel: intel_pch: Fold two functions into their callers Rafael J. Wysocki
2023-01-31 15:58   ` Daniel Lezcano
2023-01-30 19:04 ` [PATCH v1 6/8] thermal: intel: intel_pch: Fold suspend and resume routines " Rafael J. Wysocki
2023-01-31 15:59   ` Daniel Lezcano
2023-01-30 19:04 ` [PATCH v1 7/8] thermal: intel: intel_pch: Rename board ID symbols Rafael J. Wysocki
2023-01-31 11:17   ` Zhang, Rui
2023-01-31 13:08     ` Rafael J. Wysocki
2023-01-31 16:00       ` Daniel Lezcano
2023-01-30 19:07 ` [PATCH v1 8/8] thermal: intel: intel_pch: Refer to thermal zone name directly Rafael J. Wysocki
2023-01-31 16:02   ` Daniel Lezcano
2023-01-31 19:20     ` Rafael J. Wysocki
2023-01-31 23:41       ` Daniel Lezcano
2023-01-30 19:13 ` [PATCH v1 0/8] thermal: intel: intel_pch: Code simplification and cleanups Rafael J. Wysocki
2023-02-01  9:30   ` Zhang, Rui
2023-02-01  9:06 ` Zhang, Rui
2023-02-01  9:08   ` Zhang, Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2141577.Mh6RI2rZIc@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=david.e.box@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox