From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev,
Stephan Gerhold <stephan.gerhold@kernkonzept.com>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1 14/86] cpufreq: qcom-nvmem: Simplify driver data allocation
Date: Wed, 7 Aug 2024 16:59:53 +0200 [thread overview]
Message-ID: <20240807150039.709751835@linuxfoundation.org> (raw)
In-Reply-To: <20240807150039.247123516@linuxfoundation.org>
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephan Gerhold <stephan.gerhold@kernkonzept.com>
[ Upstream commit 2a5d46c3ad6b0e62d2b04356ad999d504fb564e0 ]
Simplify the allocation and cleanup of driver data by using devm
together with a flexible array. Prepare for adding additional per-CPU
data by defining a struct qcom_cpufreq_drv_cpu instead of storing the
opp_tokens directly.
Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Stable-dep-of: d01c84b97f19 ("cpufreq: qcom-nvmem: fix memory leaks in probe error paths")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/cpufreq/qcom-cpufreq-nvmem.c | 49 ++++++++++------------------
1 file changed, 18 insertions(+), 31 deletions(-)
diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
index 91634b84baa87..983991c0afd5c 100644
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -53,10 +53,14 @@ struct qcom_cpufreq_match_data {
const char **genpd_names;
};
+struct qcom_cpufreq_drv_cpu {
+ int opp_token;
+};
+
struct qcom_cpufreq_drv {
- int *opp_tokens;
u32 versions;
const struct qcom_cpufreq_match_data *data;
+ struct qcom_cpufreq_drv_cpu cpus[];
};
static struct platform_device *cpufreq_dt_pdev, *cpufreq_pdev;
@@ -284,42 +288,32 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
return -ENOENT;
}
- drv = kzalloc(sizeof(*drv), GFP_KERNEL);
+ drv = devm_kzalloc(&pdev->dev, struct_size(drv, cpus, num_possible_cpus()),
+ GFP_KERNEL);
if (!drv)
return -ENOMEM;
match = pdev->dev.platform_data;
drv->data = match->data;
- if (!drv->data) {
- ret = -ENODEV;
- goto free_drv;
- }
+ if (!drv->data)
+ return -ENODEV;
if (drv->data->get_version) {
speedbin_nvmem = of_nvmem_cell_get(np, NULL);
- if (IS_ERR(speedbin_nvmem)) {
- ret = dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem),
- "Could not get nvmem cell\n");
- goto free_drv;
- }
+ if (IS_ERR(speedbin_nvmem))
+ return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem),
+ "Could not get nvmem cell\n");
ret = drv->data->get_version(cpu_dev,
speedbin_nvmem, &pvs_name, drv);
if (ret) {
nvmem_cell_put(speedbin_nvmem);
- goto free_drv;
+ return ret;
}
nvmem_cell_put(speedbin_nvmem);
}
of_node_put(np);
- drv->opp_tokens = kcalloc(num_possible_cpus(), sizeof(*drv->opp_tokens),
- GFP_KERNEL);
- if (!drv->opp_tokens) {
- ret = -ENOMEM;
- goto free_drv;
- }
-
for_each_possible_cpu(cpu) {
struct dev_pm_opp_config config = {
.supported_hw = NULL,
@@ -345,9 +339,9 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
}
if (config.supported_hw || config.genpd_names) {
- drv->opp_tokens[cpu] = dev_pm_opp_set_config(cpu_dev, &config);
- if (drv->opp_tokens[cpu] < 0) {
- ret = drv->opp_tokens[cpu];
+ drv->cpus[cpu].opp_token = dev_pm_opp_set_config(cpu_dev, &config);
+ if (drv->cpus[cpu].opp_token < 0) {
+ ret = drv->cpus[cpu].opp_token;
dev_err(cpu_dev, "Failed to set OPP config\n");
goto free_opp;
}
@@ -366,11 +360,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
free_opp:
for_each_possible_cpu(cpu)
- dev_pm_opp_clear_config(drv->opp_tokens[cpu]);
- kfree(drv->opp_tokens);
-free_drv:
- kfree(drv);
-
+ dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
return ret;
}
@@ -382,10 +372,7 @@ static void qcom_cpufreq_remove(struct platform_device *pdev)
platform_device_unregister(cpufreq_dt_pdev);
for_each_possible_cpu(cpu)
- dev_pm_opp_clear_config(drv->opp_tokens[cpu]);
-
- kfree(drv->opp_tokens);
- kfree(drv);
+ dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
}
static struct platform_driver qcom_cpufreq_driver = {
--
2.43.0
next prev parent reply other threads:[~2024-08-07 15:12 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 14:59 [PATCH 6.1 00/86] 6.1.104-rc1 review Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 01/86] arm64: dts: qcom: msm8998: switch USB QMP PHY to new style of bindings Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 02/86] arm64: dts: qcom: msm8998: Disable SS instance in Parkmode for USB Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 03/86] arm64: dts: qcom: ipq8074: " Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 04/86] sysctl: allow change system v ipc sysctls inside ipc namespace Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 05/86] sysctl: allow to change limits for posix messages queues Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 06/86] sysctl: treewide: drop unused argument ctl_table_root::set_ownership(table) Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 07/86] sysctl: always initialize i_uid/i_gid Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 08/86] ext4: make ext4_es_insert_extent() return void Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 09/86] ext4: refactor ext4_da_map_blocks() Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 10/86] ext4: convert to exclusive lock while inserting delalloc extents Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 11/86] ext4: factor out a common helper to query extent map Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 12/86] ext4: check the extent status again before inserting delalloc block Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 13/86] cpufreq: qcom-nvmem: Convert to platform remove callback returning void Greg Kroah-Hartman
2024-08-07 14:59 ` Greg Kroah-Hartman [this message]
2024-08-07 14:59 ` [PATCH 6.1 15/86] cpufreq: qcom-nvmem: fix memory leaks in probe error paths Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 16/86] leds: trigger: Remove unused function led_trigger_rename_static() Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 17/86] leds: trigger: Store brightness set by led_trigger_event() Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 18/86] leds: trigger: Call synchronize_rcu() before calling trig->activate() Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 19/86] leds: triggers: Flush pending brightness before activating trigger Greg Kroah-Hartman
2024-08-07 14:59 ` [PATCH 6.1 20/86] mm: restrict the pcp batch scale factor to avoid too long latency Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 21/86] mm: page_alloc: control latency caused by zone PCP draining Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 22/86] mm/page_alloc: fix pcp->count race between drain_pages_zone() vs __rmqueue_pcplist() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 23/86] f2fs: fix to avoid use SSR allocate when do defragment Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 24/86] f2fs: assign CURSEG_ALL_DATA_ATGC if blkaddr is valid Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 25/86] irqdomain: Use return value of strreplace() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 26/86] irqdomain: Fixed unbalanced fwnode get and put Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 27/86] drm/udl: Rename struct udl_drm_connector to struct udl_connector Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 28/86] drm/udl: Test pixel limit in mode-configs mode-valid function Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 29/86] drm/udl: Use USB timeout constant when reading EDID Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 30/86] drm/udl: Various improvements to the connector Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 31/86] drm/udl: Move connector to modesetting code Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 32/86] drm/udl: Remove DRM_CONNECTOR_POLL_HPD Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 33/86] drm/i915/dp: Dont switch the LTTPR mode on an active link Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 34/86] MIPS: Loongson64: DTS: Add RTC support to Loongson-2K1000 Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 35/86] MIPS: Loongson64: DTS: Fix PCIe port nodes for ls7a Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 36/86] MIPS: dts: loongson: Fix liointc IRQ polarity Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 37/86] MIPS: dts: loongson: Fix ls2k1000-rtc interrupt Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 38/86] HID: amd_sfh: Remove duplicate cleanup Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 39/86] HID: amd_sfh: Split sensor and HID initialization Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 40/86] HID: amd_sfh: Move sensor discovery before HID device initialization Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 41/86] drm/nouveau: prime: fix refcount underflow Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 42/86] drm/vmwgfx: Fix overlay when using Screen Targets Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 43/86] drm/vmwgfx: Trigger a modeset when the screen moves Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 44/86] sched: act_ct: take care of padding in struct zones_ht_key Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 45/86] ALSA: hda: conexant: Reduce CONFIG_PM dependencies Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 46/86] ALSA: hda: conexant: Fix headset auto detect fail in the polling mode Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 47/86] Bluetooth: hci_sync: Fix suspending with wrong filter policy Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 48/86] net: axienet: start napi before enabling Rx/Tx Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 49/86] rtnetlink: Dont ignore IFLA_TARGET_NETNSID when ifname is specified in rtnl_dellink() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 50/86] ice: respect netif readiness in AF_XDP ZC related ndos Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 51/86] ice: dont busy wait for Rx queue disable in ice_qp_dis() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 52/86] ice: replace synchronize_rcu with synchronize_net Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 53/86] ice: add missing WRITE_ONCE when clearing ice_rx_ring::xdp_prog Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 54/86] net/iucv: fix use after free in iucv_sock_close() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 55/86] drm/i915/hdcp: Fix HDCP2_STREAM_STATUS macro Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 56/86] net: mvpp2: Dont re-use loop iterator Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 57/86] ALSA: hda: Conditionally use snooping for AMD HDMI Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 58/86] netfilter: iptables: Fix null-ptr-deref in iptable_nat_table_init() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 59/86] netfilter: iptables: Fix potential null-ptr-deref in ip6table_nat_table_init() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 60/86] net/mlx5: Lag, dont use the hardcoded value of the first port Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 61/86] net/mlx5: Fix missing lock on sync reset reload Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 62/86] net/mlx5e: Add a check for the return value from mlx5_port_set_eth_ptys Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 63/86] ipv6: fix ndisc_is_useropt() handling for PIO Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 64/86] riscv/mm: Add handling for VM_FAULT_SIGSEGV in mm_fault_error() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 65/86] arm64: jump_label: Ensure patched jump_labels are visible to all CPUs Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 66/86] rust: SHADOW_CALL_STACK is incompatible with Rust Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 67/86] platform/chrome: cros_ec_proto: Lock device when updating MKBP version Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 68/86] HID: wacom: Modify pen IDs Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 69/86] btrfs: zoned: fix zone_unusable accounting on making block group read-write again Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 70/86] protect the fetch of ->fd[fd] in do_dup2() from mispredictions Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 71/86] mptcp: sched: check both directions for backup Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 72/86] ALSA: usb-audio: Correct surround channels in UAC1 channel map Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 73/86] ALSA: hda/realtek: Add quirk for Acer Aspire E5-574G Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 74/86] Revert "ALSA: firewire-lib: obsolete workqueue for period update" Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 75/86] Revert "ALSA: firewire-lib: operate for period elapse event in process context" Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 76/86] drm/vmwgfx: Fix a deadlock in dma buf fence polling Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 77/86] drm/i915: Fix possible int overflow in skl_ddi_calculate_wrpll() Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 78/86] net: usb: sr9700: fix uninitialized variable use in sr_mdio_read Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 79/86] r8169: dont increment tx_dropped in case of NETDEV_TX_BUSY Greg Kroah-Hartman
2024-08-07 15:00 ` [PATCH 6.1 80/86] mptcp: fix user-space PM announced address accounting Greg Kroah-Hartman
2024-08-07 15:01 ` [PATCH 6.1 81/86] mptcp: distinguish rcv vs sent backup flag in requests Greg Kroah-Hartman
2024-08-07 15:01 ` [PATCH 6.1 82/86] mptcp: fix NL PM announced address accounting Greg Kroah-Hartman
2024-08-07 15:01 ` [PATCH 6.1 83/86] mptcp: fix bad RCVPRUNED mib accounting Greg Kroah-Hartman
2024-08-07 15:01 ` [PATCH 6.1 84/86] mptcp: pm: only set request_bkup flag when sending MP_PRIO Greg Kroah-Hartman
2024-08-07 15:01 ` [PATCH 6.1 85/86] mptcp: fix duplicate data handling Greg Kroah-Hartman
2024-08-07 15:01 ` [PATCH 6.1 86/86] selftests: mptcp: always close inputs FD if opened Greg Kroah-Hartman
2024-08-07 17:32 ` [PATCH 6.1 00/86] 6.1.104-rc1 review Pavel Machek
2024-08-07 17:42 ` Mark Brown
2024-08-07 18:22 ` Anders Roxell
2024-08-07 20:35 ` Salvatore Bonaccorso
2024-08-11 10:09 ` Greg Kroah-Hartman
2024-08-11 15:03 ` Salvatore Bonaccorso
2024-08-11 15:40 ` Greg Kroah-Hartman
2024-08-12 17:49 ` Salvatore Bonaccorso
2024-08-13 6:08 ` Greg Kroah-Hartman
2024-08-07 21:10 ` Florian Fainelli
2024-08-07 21:39 ` Shuah Khan
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=20240807150039.709751835@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=konrad.dybcio@linaro.org \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stephan.gerhold@kernkonzept.com \
--cc=viresh.kumar@linaro.org \
/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