Prompt:
Given the following original C code:
entry->timestamp = jiffies;
		entry->event = event;

		dbr_data->dbr_debug_idx++;
		if (dbr_data->dbr_debug_idx ==
		    dbr_data->num_ring_debug_entries)
			dbr_data->dbr_debug_idx = 0;
	}

	spin_unlock_bh(&dbr_data->lock);
}

static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)
{
	spin_lock_bh(&ar->data_lock);
	ath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);
	ath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);
	ar->fw_stats.num_vdev_recvd = 0;
	ar->fw_stats.num_bcn_recvd = 0;
	spin_unlock_bh(&ar->data_lock);

Instruction:
wifi: ath11k: move some firmware stats related functions outside of debugfs

Return the diff that fixes it:

Response:
@@ -93,58 +93,14 @@ void ath11k_debugfs_add_dbring_entry(struct ath11k *ar,
 	spin_unlock_bh(&dbr_data->lock);
 }

-static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)
-{
-	spin_lock_bh(&ar->data_lock);
-	ath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);
-	ath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);
-	ar->fw_stats.num_vdev_recvd = 0;
-	ar->fw_stats.num_bcn_recvd = 0;
-	spin_unlock_bh(&ar->data_lock);
-}
-
 void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats)
 {
 	struct ath11k_base *ab = ar->ab;
-	struct ath11k_pdev *pdev;
 	bool is_end = true;
-	size_t total_vdevs_started = 0;
-	int i;
-
-	/* WMI_REQUEST_PDEV_STAT request has been already processed */
-
-	if (stats->stats_id == WMI_REQUEST_RSSI_PER_CHAIN_STAT) {
-		complete(&ar->fw_stats_done);
-		return;
-	}
-
-	if (stats->stats_id == WMI_REQUEST_VDEV_STAT) {
-		if (list_empty(&stats->vdevs)) {
-			ath11k_warn(ab, "empty vdev stats");
-			return;
-		}
-		/* FW sends all the active VDEV stats irrespective of PDEV,
-		 * hence limit until the count of all VDEVs started
-		 */
-		for (i = 0; i < ab->num_radios; i++) {
-			pdev = rcu_dereference(ab->pdevs_active[i]);
-			if (pdev && pdev->ar)
-				total_vdevs_started += ar->num_started_vdevs;
-		}
-
-		if (total_vdevs_started)
-			is_end = ((++ar->fw_stats.num_vdev_recvd) ==
-				  total_vdevs_started);
-
-		list_splice_tail_init(&stats->vdevs,
-				      &ar->fw_stats.vdevs);
-
-		if (is_end)
-			complete(&ar->fw_stats_done);
-
-		return;
-	}

+	/* WMI_REQUEST_PDEV_STAT, WMI_REQUEST_RSSI_PER_CHAIN_STAT and
+	 * WMI_REQUEST_VDEV_STAT requests have been already processed.
+	 */
 	if (stats->stats_id == WMI_REQUEST_BCN_STAT) {
 		if (list_empty(&stats->bcn)) {
 			ath11k_warn(ab, "empty bcn stats");
@@ -165,76 +121,6 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *
 	}
 }

-static int ath11k_debugfs_fw_stats_request(struct ath11k *ar,
-					   struct stats_request_params *req_param)
-{
-	struct ath11k_base *ab = ar->ab;
-	unsigned long time_left;
-	int ret;
-
-	lockdep_assert_held(&ar->conf_mutex);
-
-	ath11k_debugfs_fw_stats_reset(ar);
-
-	reinit_completion(&ar->fw_stats_complete);
-	reinit_completion(&ar->fw_stats_done);
-
-	ret = ath11k_wmi_send_stats_request_cmd(ar, req_param);
-
-	if (ret) {
-		ath11k_warn(ab, "could not request fw stats (%d)\n",
-			    ret);
-		return ret;
-	}
-
-	time_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ);
-	if (!time_left)
-		return -ETIMEDOUT;
-
-	/* FW stats can get split when exceeding the stats data buffer limit.
-	 * In that case, since there is no end marking for the back-to-back
-	 * received 'update stats' event, we keep a 3 seconds timeout in case,
-	 * fw_stats_done is not marked yet
-	 */
-	time_left = wait_for_completion_timeout(&ar->fw_stats_done, 3 * HZ);
-	if (!time_left)
-		return -ETIMEDOUT;
-
-	return 0;
-}
-
-int ath11k_debugfs_get_fw_stats(struct ath11k *ar, u32 pdev_id,
-				u32 vdev_id, u32 stats_id)
-{
-	struct ath11k_base *ab = ar->ab;
-	struct stats_request_params req_param;
-	int ret;
-
-	mutex_lock(&ar->conf_mutex);
-
-	if (ar->state != ATH11K_STATE_ON) {
-		ret = -ENETDOWN;
-		goto err_unlock;
-	}
-
-	req_param.pdev_id = pdev_id;
-	req_param.vdev_id = vdev_id;
-	req_param.stats_id = stats_id;
-
-	ret = ath11k_debugfs_fw_stats_request(ar, &req_param);
-	if (ret)
-		ath11k_warn(ab, "failed to request fw stats: %d\n", ret);
-
-	ath11k_dbg(ab, ATH11K_DBG_WMI,
-		   "debug get fw stat pdev id %d vdev id %d stats id 0x%x\n",
-		   pdev_id, vdev_id, stats_id);
-
-err_unlock:
-	mutex_unlock(&ar->conf_mutex);
-
-	return ret;
-}
-
 static int ath11k_open_pdev_stats(struct inode *inode, struct file *file)
 {
 	struct ath11k *ar = inode->i_private;
@@ -260,7 +146,7 @@ static int ath11k_open_pdev_stats(struct inode *inode, struct file *file)
 	req_param.vdev_id = 0;
 	req_param.stats_id = WMI_REQUEST_PDEV_STAT;

-	ret = ath11k_debugfs_fw_stats_request(ar, &req_param);
+	ret = ath11k_mac_fw_stats_request(ar, &req_param);
 	if (ret) {
 		ath11k_warn(ab, "failed to request fw pdev stats: %d\n", ret);
 		goto err_free;
@@ -331,7 +217,7 @@ static int ath11k_open_vdev_stats(struct inode *inode, struct file *file)
 	req_param.vdev_id = 0;
 	req_param.stats_id = WMI_REQUEST_VDEV_STAT;

-	ret = ath11k_debugfs_fw_stats_request(ar, &req_param);
+	ret = ath11k_mac_fw_stats_request(ar, &req_param);
 	if (ret) {
 		ath11k_warn(ar->ab, "failed to request fw vdev stats: %d\n", ret);
 		goto err_free;
@@ -407,7 +293,7 @@ static int ath11k_open_bcn_stats(struct inode *inode, struct file *file)
 			continue;

 		req_param.vdev_id = arvif->vdev_id;
-		ret = ath11k_debugfs_fw_stats_request(ar, &req_param);
+		ret = ath11k_mac_fw_stats_request(ar, &req_param);
 		if (ret) {
 			ath11k_warn(ar->ab, "failed to request fw bcn stats: %d\n", ret);
 			goto err_free;


Prompt:
Given the following original C code:
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
/*
 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#ifndef _ATH11K_DEBUGFS_H_
#define _ATH11K_DEBUGFS_H_

#include "hal_tx.h"

Instruction:
wifi: ath11k: move some firmware stats related functions outside of debugfs

Return the diff that fixes it:

Response:
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
 /*
  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2022, 2025 Qualcomm Innovation Center, Inc. All rights reserved.
  */

 #ifndef _ATH11K_DEBUGFS_H_
@@ -273,8 +273,6 @@ void ath11k_debugfs_unregister(struct ath11k *ar);
 void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats);

 void ath11k_debugfs_fw_stats_init(struct ath11k *ar);
-int ath11k_debugfs_get_fw_stats(struct ath11k *ar, u32 pdev_id,
-				u32 vdev_id, u32 stats_id);

 static inline bool ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k *ar)
 {
@@ -381,12 +379,6 @@ static inline int ath11k_debugfs_rx_filter(struct ath11k *ar)
 	return 0;
 }

-static inline int ath11k_debugfs_get_fw_stats(struct ath11k *ar,
-					      u32 pdev_id, u32 vdev_id, u32 stats_id)
-{
-	return 0;
-}
-
 static inline void
 ath11k_debugfs_add_dbring_entry(struct ath11k *ar,
 				enum wmi_direct_buffer_module id,


Prompt:
Given the following original C code:
if (rssi != ATH11K_DEFAULT_NOISE_FLOOR &&
		    rssi != ATH11K_INVALID_RSSI_FULL &&
		    rssi != ATH11K_INVALID_RSSI_EMPTY &&
		    rssi != 0) {
			sinfo->chain_signal[i] = rssi;
			sinfo->chains |= BIT(i);
			sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
		}
	}
}

static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
					 struct ieee80211_vif *vif,
					 struct ieee80211_sta *sta,
					 struct station_info *sinfo)
{
	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
	struct ath11k *ar = arsta->arvif->ar;
	s8 signal;

Instruction:
wifi: ath11k: move some firmware stats related functions outside of debugfs

Return the diff that fixes it:

Response:
@@ -8997,6 +8997,86 @@ static void ath11k_mac_put_chain_rssi(struct station_info *sinfo,
 	}
 }

+static void ath11k_mac_fw_stats_reset(struct ath11k *ar)
+{
+	spin_lock_bh(&ar->data_lock);
+	ath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);
+	ath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);
+	ar->fw_stats.num_vdev_recvd = 0;
+	ar->fw_stats.num_bcn_recvd = 0;
+	spin_unlock_bh(&ar->data_lock);
+}
+
+int ath11k_mac_fw_stats_request(struct ath11k *ar,
+				struct stats_request_params *req_param)
+{
+	struct ath11k_base *ab = ar->ab;
+	unsigned long time_left;
+	int ret;
+
+	lockdep_assert_held(&ar->conf_mutex);
+
+	ath11k_mac_fw_stats_reset(ar);
+
+	reinit_completion(&ar->fw_stats_complete);
+	reinit_completion(&ar->fw_stats_done);
+
+	ret = ath11k_wmi_send_stats_request_cmd(ar, req_param);
+
+	if (ret) {
+		ath11k_warn(ab, "could not request fw stats (%d)\n",
+			    ret);
+		return ret;
+	}
+
+	time_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ);
+	if (!time_left)
+		return -ETIMEDOUT;
+
+	/* FW stats can get split when exceeding the stats data buffer limit.
+	 * In that case, since there is no end marking for the back-to-back
+	 * received 'update stats' event, we keep a 3 seconds timeout in case,
+	 * fw_stats_done is not marked yet
+	 */
+	time_left = wait_for_completion_timeout(&ar->fw_stats_done, 3 * HZ);
+	if (!time_left)
+		return -ETIMEDOUT;
+
+	return 0;
+}
+
+static int ath11k_mac_get_fw_stats(struct ath11k *ar, u32 pdev_id,
+				   u32 vdev_id, u32 stats_id)
+{
+	struct ath11k_base *ab = ar->ab;
+	struct stats_request_params req_param;
+	int ret;
+
+	mutex_lock(&ar->conf_mutex);
+
+	if (ar->state != ATH11K_STATE_ON) {
+		ret = -ENETDOWN;
+		goto err_unlock;
+	}
+
+	req_param.pdev_id = pdev_id;
+	req_param.vdev_id = vdev_id;
+	req_param.stats_id = stats_id;
+
+	ret = ath11k_mac_fw_stats_request(ar, &req_param);
+	if (ret)
+		ath11k_warn(ab, "failed to request fw stats: %d\n", ret);
+
+	ath11k_dbg(ab, ATH11K_DBG_WMI,
+		   "debug get fw stat pdev id %d vdev id %d stats id 0x%x\n",
+		   pdev_id, vdev_id, stats_id);
+
+err_unlock:
+	mutex_unlock(&ar->conf_mutex);
+
+	return ret;
+}
+
 static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
 					 struct ieee80211_vif *vif,
 					 struct ieee80211_sta *sta,
@@ -9034,8 +9114,8 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
 	if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL)) &&
 	    arsta->arvif->vdev_type == WMI_VDEV_TYPE_STA &&
 	    ar->ab->hw_params.supports_rssi_stats &&
-	    !ath11k_debugfs_get_fw_stats(ar, ar->pdev->pdev_id, 0,
-					 WMI_REQUEST_RSSI_PER_CHAIN_STAT)) {
+	    !ath11k_mac_get_fw_stats(ar, ar->pdev->pdev_id, 0,
+				     WMI_REQUEST_RSSI_PER_CHAIN_STAT)) {
 		ath11k_mac_put_chain_rssi(sinfo, arsta, "fw stats", true);
 	}

@@ -9043,8 +9123,8 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
 	if (!signal &&
 	    arsta->arvif->vdev_type == WMI_VDEV_TYPE_STA &&
 	    ar->ab->hw_params.supports_rssi_stats &&
-	    !(ath11k_debugfs_get_fw_stats(ar, ar->pdev->pdev_id, 0,
-					WMI_REQUEST_VDEV_STAT)))
+	    !(ath11k_mac_get_fw_stats(ar, ar->pdev->pdev_id, 0,
+				      WMI_REQUEST_VDEV_STAT)))
 		signal = arsta->rssi_beacon;

 	ath11k_dbg(ar->ab, ATH11K_DBG_MAC,


Prompt:
Given the following original C code:
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
/*
 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#ifndef ATH11K_MAC_H
#define ATH11K_MAC_H

#include <net/mac80211.h>
#include <net/cfg80211.h>

Instruction:
wifi: ath11k: move some firmware stats related functions outside of debugfs

Return the diff that fixes it:

Response:
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
 /*
  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023, 2025 Qualcomm Innovation Center, Inc. All rights reserved.
  */

 #ifndef ATH11K_MAC_H
@@ -179,4 +179,6 @@ int ath11k_mac_vif_set_keepalive(struct ath11k_vif *arvif,
 void ath11k_mac_fill_reg_tpc_info(struct ath11k *ar,
 				  struct ieee80211_vif *vif,
 				  struct ieee80211_chanctx_conf *ctx);
+int ath11k_mac_fw_stats_request(struct ath11k *ar,
+				struct stats_request_params *req_param);
 #endif


Prompt:
Given the following original C code:
peer_assoc_conf.vdev_id);
		rcu_read_unlock();
		return;
	}

	complete(&ar->peer_assoc_done);
	rcu_read_unlock();
}

static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *skb)
{
	struct ath11k_fw_stats stats = {};
	struct ath11k *ar;
	int ret;

	INIT_LIST_HEAD(&stats.pdevs);
	INIT_LIST_HEAD(&stats.vdevs);
	INIT_LIST_HEAD(&stats.bcn);

	ret = ath11k_wmi_pull_fw_stats(ab, skb, &stats);

Instruction:
wifi: ath11k: move some firmware stats related functions outside of debugfs

Return the diff that fixes it:

Response:
@@ -8158,6 +8158,11 @@ static void ath11k_peer_assoc_conf_event(struct ath11k_base *ab, struct sk_buff
 static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *skb)
 {
 	struct ath11k_fw_stats stats = {};
+	size_t total_vdevs_started = 0;
+	struct ath11k_pdev *pdev;
+	bool is_end = true;
+	int i;
+
 	struct ath11k *ar;
 	int ret;

@@ -8184,7 +8189,8 @@ static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *sk

 	spin_lock_bh(&ar->data_lock);

-	/* WMI_REQUEST_PDEV_STAT can be requested via .get_txpower mac ops or via
+	/* WMI_REQUEST_PDEV_STAT, WMI_REQUEST_VDEV_STAT and
+	 * WMI_REQUEST_RSSI_PER_CHAIN_STAT can be requested via mac ops or via
 	 * debugfs fw stats. Therefore, processing it separately.
 	 */
 	if (stats.stats_id == WMI_REQUEST_PDEV_STAT) {
@@ -8193,9 +8199,40 @@ static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *sk
 		goto complete;
 	}

-	/* WMI_REQUEST_VDEV_STAT, WMI_REQUEST_BCN_STAT and WMI_REQUEST_RSSI_PER_CHAIN_STAT
-	 * are currently requested only via debugfs fw stats. Hence, processing these
-	 * in debugfs context
+	if (stats.stats_id == WMI_REQUEST_RSSI_PER_CHAIN_STAT) {
+		complete(&ar->fw_stats_done);
+		goto complete;
+	}
+
+	if (stats.stats_id == WMI_REQUEST_VDEV_STAT) {
+		if (list_empty(&stats.vdevs)) {
+			ath11k_warn(ab, "empty vdev stats");
+			goto complete;
+		}
+		/* FW sends all the active VDEV stats irrespective of PDEV,
+		 * hence limit until the count of all VDEVs started
+		 */
+		for (i = 0; i < ab->num_radios; i++) {
+			pdev = rcu_dereference(ab->pdevs_active[i]);
+			if (pdev && pdev->ar)
+				total_vdevs_started += ar->num_started_vdevs;
+		}
+
+		if (total_vdevs_started)
+			is_end = ((++ar->fw_stats.num_vdev_recvd) ==
+				  total_vdevs_started);
+
+		list_splice_tail_init(&stats.vdevs,
+				      &ar->fw_stats.vdevs);
+
+		if (is_end)
+			complete(&ar->fw_stats_done);
+
+		goto complete;
+	}
+
+	/* WMI_REQUEST_BCN_STAT is currently requested only via debugfs fw stats.
+	 * Hence, processing it in debugfs context
 	 */
 	ath11k_debugfs_fw_stats_process(ar, &stats);


Prompt:
Given the following original C code:
if (ret) {
		ath11k_err(ab, "failed to send firmware start: %d\n", ret);
		return ret;
	}

	return ret;
}

int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
{
	int ret;

	ret = ath11k_core_start_firmware(ab, ab->fw_mode);
	if (ret) {
		ath11k_err(ab, "failed to start firmware: %d\n", ret);
		return ret;
	}

	ret = ath11k_ce_init_pipes(ab);
	if (ret) {

Instruction:
wifi: ath11k: validate ath11k_crypto_mode on top of ath11k_core_qmi_firmware_ready

Return the diff that fixes it:

Response:
@@ -2135,6 +2135,20 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
 {
 	int ret;

+	switch (ath11k_crypto_mode) {
+	case ATH11K_CRYPT_MODE_SW:
+		set_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
+		set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
+		break;
+	case ATH11K_CRYPT_MODE_HW:
+		clear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
+		clear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
+		break;
+	default:
+		ath11k_info(ab, "invalid crypto_mode: %d\n", ath11k_crypto_mode);
+		return -EINVAL;
+	}
+
 	ret = ath11k_core_start_firmware(ab, ab->fw_mode);
 	if (ret) {
 		ath11k_err(ab, "failed to start firmware: %d\n", ret);
@@ -2153,20 +2167,6 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
 		goto err_firmware_stop;
 	}

-	switch (ath11k_crypto_mode) {
-	case ATH11K_CRYPT_MODE_SW:
-		set_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
-		set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
-		break;
-	case ATH11K_CRYPT_MODE_HW:
-		clear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
-		clear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
-		break;
-	default:
-		ath11k_info(ab, "invalid crypto_mode: %d\n", ath11k_crypto_mode);
-		return -EINVAL;
-	}
-
 	if (ath11k_frame_mode == ATH11K_HW_TXRX_RAW)
 		set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);


Prompt:
Given the following original C code:
/* REO cmd ring address */
	.hal_reo_cmd_ring_base = 0x0000028c,

	/* REO status ring address */
	.hal_reo_status_ring_base = 0x00000a84,

	/* CE base address */
	.hal_umac_ce0_src_reg_base = 0x01b80000,
	.hal_umac_ce0_dest_reg_base = 0x01b81000,
	.hal_umac_ce1_src_reg_base = 0x01b82000,
	.hal_umac_ce1_dest_reg_base = 0x01b83000,
};

static const struct ath12k_hw_regs qcn9274_v2_regs = {
	/* SW2TCL(x) R0 ring configuration address */
	.hal_tcl1_ring_id = 0x00000908,
	.hal_tcl1_ring_misc = 0x00000910,
	.hal_tcl1_ring_tp_addr_lsb = 0x0000091c,
	.hal_tcl1_ring_tp_addr_msb = 0x00000920,

Instruction:
wifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850

Return the diff that fixes it:

Response:
@@ -951,6 +951,8 @@ static const struct ath12k_hw_regs qcn9274_v1_regs = {
 	.hal_umac_ce0_dest_reg_base = 0x01b81000,
 	.hal_umac_ce1_src_reg_base = 0x01b82000,
 	.hal_umac_ce1_dest_reg_base = 0x01b83000,
+
+	.gcc_gcc_pcie_hot_rst = 0x1e38338,
 };

 static const struct ath12k_hw_regs qcn9274_v2_regs = {
@@ -1042,6 +1044,8 @@ static const struct ath12k_hw_regs qcn9274_v2_regs = {
 	.hal_umac_ce0_dest_reg_base = 0x01b81000,
 	.hal_umac_ce1_src_reg_base = 0x01b82000,
 	.hal_umac_ce1_dest_reg_base = 0x01b83000,
+
+	.gcc_gcc_pcie_hot_rst = 0x1e38338,
 };

 static const struct ath12k_hw_regs ipq5332_regs = {
@@ -1215,6 +1219,8 @@ static const struct ath12k_hw_regs wcn7850_regs = {
 	.hal_umac_ce0_dest_reg_base = 0x01b81000,
 	.hal_umac_ce1_src_reg_base = 0x01b82000,
 	.hal_umac_ce1_dest_reg_base = 0x01b83000,
+
+	.gcc_gcc_pcie_hot_rst = 0x1e40304,
 };

 static const struct ath12k_hw_hal_params ath12k_hw_hal_params_qcn9274 = {


Prompt:
Given the following original C code:
u32 hal_reo1_aging_thres_ix1;
	u32 hal_reo1_aging_thres_ix2;
	u32 hal_reo1_aging_thres_ix3;

	u32 hal_reo2_sw0_ring_base;

	u32 hal_sw2reo_ring_base;
	u32 hal_sw2reo1_ring_base;

	u32 hal_reo_cmd_ring_base;

	u32 hal_reo_status_ring_base;
};

static inline const char *ath12k_bd_ie_type_str(enum ath12k_bd_ie_type type)
{
	switch (type) {
	case ATH12K_BD_IE_BOARD:
		return "board data";
	case ATH12K_BD_IE_REGDB:

Instruction:
wifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850

Return the diff that fixes it:

Response:
@@ -375,6 +375,8 @@ struct ath12k_hw_regs {
 	u32 hal_reo_cmd_ring_base;

 	u32 hal_reo_status_ring_base;
+
+	u32 gcc_gcc_pcie_hot_rst;
 };

 static inline const char *ath12k_bd_ie_type_str(enum ath12k_bd_ie_type type)


Prompt:
Given the following original C code:
/* PCIE link seems very unstable after the Hot Reset*/
	for (i = 0; val != PARM_LTSSM_VALUE && i < 5; i++) {
		if (val == 0xffffffff)
			mdelay(5);

		ath12k_pci_write32(ab, PCIE_PCIE_PARF_LTSSM, PARM_LTSSM_VALUE);
		val = ath12k_pci_read32(ab, PCIE_PCIE_PARF_LTSSM);
	}

	ath12k_dbg(ab, ATH12K_DBG_PCI, "pci ltssm 0x%x\n", val);

	val = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);
	val |= GCC_GCC_PCIE_HOT_RST_VAL;
	ath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST, val);
	val = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);

	ath12k_dbg(ab, ATH12K_DBG_PCI, "pci pcie_hot_rst 0x%x\n", val);

	mdelay(5);

Instruction:
wifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850

Return the diff that fixes it:

Response:
@@ -292,10 +292,10 @@ static void ath12k_pci_enable_ltssm(struct ath12k_base *ab)

 	ath12k_dbg(ab, ATH12K_DBG_PCI, "pci ltssm 0x%x\n", val);

-	val = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);
+	val = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST(ab));
 	val |= GCC_GCC_PCIE_HOT_RST_VAL;
-	ath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST, val);
-	val = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);
+	ath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST(ab), val);
+	val = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST(ab));

 	ath12k_dbg(ab, ATH12K_DBG_PCI, "pci pcie_hot_rst 0x%x\n", val);


Prompt:
Given the following original C code:
#define PCIE_Q6_COOKIE_ADDR			0x01f80500
#define PCIE_Q6_COOKIE_DATA			0xc0000000

/* register to wake the UMAC from power collapse */
#define PCIE_SCRATCH_0_SOC_PCIE_REG		0x4040

/* register used for handshake mechanism to validate UMAC is awake */
#define PCIE_SOC_WAKE_PCIE_LOCAL_REG		0x3004

#define PCIE_PCIE_PARF_LTSSM			0x1e081b0
#define PARM_LTSSM_VALUE			0x111

#define GCC_GCC_PCIE_HOT_RST			0x1e38338
#define GCC_GCC_PCIE_HOT_RST_VAL		0x10

#define PCIE_PCIE_INT_ALL_CLEAR			0x1e08228
#define PCIE_SMLH_REQ_RST_LINK_DOWN		0x2
#define PCIE_INT_CLEAR_ALL			0xffffffff

#define PCIE_QSERDES_COM_SYSCLK_EN_SEL_REG(ab) \

Instruction:
wifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850

Return the diff that fixes it:

Response:
@@ -28,7 +28,9 @@
 #define PCIE_PCIE_PARF_LTSSM			0x1e081b0
 #define PARM_LTSSM_VALUE			0x111

-#define GCC_GCC_PCIE_HOT_RST			0x1e38338
+#define GCC_GCC_PCIE_HOT_RST(ab) \
+	((ab)->hw_params->regs->gcc_gcc_pcie_hot_rst)
+
 #define GCC_GCC_PCIE_HOT_RST_VAL		0x10

 #define PCIE_PCIE_INT_ALL_CLEAR			0x1e08228


Prompt:
Given the following original C code:
HAL_REO_CMD_UNBLOCK_CACHE       = 3,
	HAL_REO_CMD_FLUSH_TIMEOUT_LIST  = 4,
	HAL_REO_CMD_UPDATE_RX_QUEUE     = 5,
};

/**
 * enum hal_reo_cmd_status: Enum for execution status of REO command
 * @HAL_REO_CMD_SUCCESS: Command has successfully executed
 * @HAL_REO_CMD_BLOCKED: Command could not be executed as the queue
 *			 or cache was blocked
 * @HAL_REO_CMD_FAILED: Command execution failed, could be due to
 *			invalid queue desc
 * @HAL_REO_CMD_RESOURCE_BLOCKED:
 * @HAL_REO_CMD_DRAIN:
 */
enum hal_reo_cmd_status {
	HAL_REO_CMD_SUCCESS		= 0,
	HAL_REO_CMD_BLOCKED		= 1,
	HAL_REO_CMD_FAILED		= 2,
	HAL_REO_CMD_RESOURCE_BLOCKED	= 3,

Instruction:
wifi: ath12k: Fix hal_reo_cmd_status kernel-doc

Return the diff that fixes it:

Response:
@@ -585,7 +585,8 @@ enum hal_reo_cmd_type {
  *			 or cache was blocked
  * @HAL_REO_CMD_FAILED: Command execution failed, could be due to
  *			invalid queue desc
- * @HAL_REO_CMD_RESOURCE_BLOCKED:
+ * @HAL_REO_CMD_RESOURCE_BLOCKED: Command could not be executed because
+ *				  one or more descriptors were blocked
  * @HAL_REO_CMD_DRAIN:
  */
 enum hal_reo_cmd_status {


Prompt:
Given the following original C code:
int ret;

	ret = ath12k_core_panic_notifier_register(ab);
	if (ret)
		ath12k_warn(ab, "failed to register panic handler: %d\n", ret);

	mutex_lock(&ath12k_hw_group_mutex);

	ag = ath12k_core_hw_group_assign(ab);
	if (!ag) {
		mutex_unlock(&ath12k_hw_group_mutex);
		ath12k_warn(ab, "unable to get hw group\n");
		return -ENODEV;
	}

	mutex_unlock(&ath12k_hw_group_mutex);

	mutex_lock(&ag->mutex);

	ath12k_dbg(ab, ATH12K_DBG_BOOT, "num devices %d num probed %d\n",

Instruction:
wifi: ath12k: fix uaf in ath12k_core_init()

Return the diff that fixes it:

Response:
@@ -2129,7 +2129,8 @@ int ath12k_core_init(struct ath12k_base *ab)
 	if (!ag) {
 		mutex_unlock(&ath12k_hw_group_mutex);
 		ath12k_warn(ab, "unable to get hw group\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_unregister_notifier;
 	}

 	mutex_unlock(&ath12k_hw_group_mutex);
@@ -2144,7 +2145,7 @@ int ath12k_core_init(struct ath12k_base *ab)
 		if (ret) {
 			mutex_unlock(&ag->mutex);
 			ath12k_warn(ab, "unable to create hw group\n");
-			goto err;
+			goto err_destroy_hw_group;
 		}
 	}

@@ -2152,9 +2153,12 @@ int ath12k_core_init(struct ath12k_base *ab)

 	return 0;

-err:
+err_destroy_hw_group:
 	ath12k_core_hw_group_destroy(ab->ag);
 	ath12k_core_hw_group_unassign(ab);
+err_unregister_notifier:
+	ath12k_core_panic_notifier_unregister(ab);
+
 	return ret;
 }


Prompt:
Given the following original C code:
return 0;
}

int get_msr_fd(int cpu)
{
	char pathname[32];
	int fd;

	fd = fd_percpu[cpu];

	if (fd)
		return fd;

	sprintf(pathname, "/dev/cpu/%d/msr", cpu);
	fd = open(pathname, O_RDONLY);
	if (fd < 0)
		err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, "
		    "or run with --no-msr, or run as root", pathname);

	fd_percpu[cpu] = fd;

Instruction:
tools/power turbostat: Add Android support for MSR device handling

Return the diff that fixes it:

Response:
@@ -2140,13 +2140,20 @@ int get_msr_fd(int cpu)

 	if (fd)
 		return fd;
-
+#if defined(ANDROID)
+	sprintf(pathname, "/dev/msr%d", cpu);
+#else
 	sprintf(pathname, "/dev/cpu/%d/msr", cpu);
+#endif
 	fd = open(pathname, O_RDONLY);
 	if (fd < 0)
+#if defined(ANDROID)
+		err(-1, "%s open failed, try chown or chmod +r /dev/msr*, "
+		    "or run with --no-msr, or run as root", pathname);
+#else
 		err(-1, "%s open failed, try chown or chmod +r /dev/cpu/*/msr, "
 		    "or run with --no-msr, or run as root", pathname);
-
+#endif
 	fd_percpu[cpu] = fd;

 	return fd;
@@ -6476,8 +6483,11 @@ void check_dev_msr()

 	if (no_msr)
 		return;
-
+#if defined(ANDROID)
+	sprintf(pathname, "/dev/msr%d", base_cpu);
+#else
 	sprintf(pathname, "/dev/cpu/%d/msr", base_cpu);
+#endif
 	if (stat(pathname, &sb))
 		if (system("/sbin/modprobe msr > /dev/null 2>&1"))
 			no_msr = 1;
@@ -6527,7 +6537,11 @@ void check_msr_permission(void)
 	failed += check_for_cap_sys_rawio();

 	/* test file permissions */
+#if defined(ANDROID)
+	sprintf(pathname, "/dev/msr%d", base_cpu);
+#else
 	sprintf(pathname, "/dev/cpu/%d/msr", base_cpu);
+#endif
 	if (euidaccess(pathname, R_OK)) {
 		failed++;
 	}


Prompt:
Given the following original C code:
RAPL_PLATFORM_ENERGY_STATUS = BIT(18),	/* 0x64d MSR_PLATFORM_ENERGY_STATUS */
};

#define RAPL_PKG	(RAPL_PKG_ENERGY_STATUS | RAPL_PKG_POWER_LIMIT)
#define RAPL_DRAM	(RAPL_DRAM_ENERGY_STATUS | RAPL_DRAM_POWER_LIMIT)
#define RAPL_CORE	(RAPL_CORE_ENERGY_STATUS | RAPL_CORE_POWER_LIMIT)
#define RAPL_GFX	(RAPL_GFX_POWER_LIMIT | RAPL_GFX_ENERGY_STATUS)
#define RAPL_PSYS	(RAPL_PLATFORM_ENERGY_STATUS | RAPL_PLATFORM_ENERGY_LIMIT)

#define RAPL_PKG_ALL	(RAPL_PKG | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO)
#define RAPL_DRAM_ALL	(RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_DRAM_POWER_INFO)
#define RAPL_CORE_ALL	(RAPL_CORE | RAPL_CORE_POLICY)
#define RAPL_GFX_ALL	(RAPL_GFX | RAPL_GFX_POLIGY)

#define RAPL_AMD_F17H	(RAPL_AMD_PWR_UNIT | RAPL_AMD_CORE_ENERGY_STAT | RAPL_AMD_PKG_ENERGY_STAT)

/* For Cstates */
enum cstates {
	CC1 = BIT(0),
	CC3 = BIT(1),

Instruction:
tools/power turbostat: Fix RAPL_GFX_ALL typo

Return the diff that fixes it:

Response:
@@ -539,7 +539,7 @@ enum rapl_msrs {
 #define RAPL_PKG_ALL	(RAPL_PKG | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO)
 #define RAPL_DRAM_ALL	(RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_DRAM_POWER_INFO)
 #define RAPL_CORE_ALL	(RAPL_CORE | RAPL_CORE_POLICY)
-#define RAPL_GFX_ALL	(RAPL_GFX | RAPL_GFX_POLIGY)
+#define RAPL_GFX_ALL	(RAPL_GFX | RAPL_GFX_POLICY)

 #define RAPL_AMD_F17H	(RAPL_AMD_PWR_UNIT | RAPL_AMD_CORE_ENERGY_STAT | RAPL_AMD_PKG_ENERGY_STAT)


Prompt:
Given the following original C code:
{
	if (domain_id >= ppmt->num_domains)
		return 0;

	const unsigned long *pmmio = ppmt->domains[domain_id].pcounter;
	const unsigned long value = pmmio ? *pmmio : 0;
	const unsigned long value_mask = pmt_gen_value_mask(ppmt->lsb, ppmt->msb);
	const unsigned long value_shift = ppmt->lsb;

	return (value & value_mask) >> value_shift;
}

/*
 * get_counters(...)
 * migrate to cpu
 * acquire and record local counters for that cpu
 */
int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
{
	int cpu = t->cpu_id;

Instruction:
tools/power turbostat: Fix AMD package-energy reporting

Return the diff that fixes it:

Response:
@@ -4773,6 +4773,38 @@ unsigned long pmt_read_counter(struct pmt_counter *ppmt, unsigned int domain_id)
 	return (value & value_mask) >> value_shift;
 }

+
+/* Rapl domain enumeration helpers */
+static inline int get_rapl_num_domains(void)
+{
+	int num_packages = topo.max_package_id + 1;
+	int num_cores_per_package;
+	int num_cores;
+
+	if (!platform->has_per_core_rapl)
+		return num_packages;
+
+	num_cores_per_package = topo.max_core_id + 1;
+	num_cores = num_cores_per_package * num_packages;
+
+	return num_cores;
+}
+
+static inline int get_rapl_domain_id(int cpu)
+{
+	int nr_cores_per_package = topo.max_core_id + 1;
+	int rapl_core_id;
+
+	if (!platform->has_per_core_rapl)
+		return cpus[cpu].physical_package_id;
+
+	/* Compute the system-wide unique core-id for @cpu */
+	rapl_core_id = cpus[cpu].physical_core_id;
+	rapl_core_id += cpus[cpu].physical_package_id * nr_cores_per_package;
+
+	return rapl_core_id;
+}
+
 /*
  * get_counters(...)
  * migrate to cpu
@@ -4828,7 +4860,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
 		goto done;

 	if (platform->has_per_core_rapl) {
-		status = get_rapl_counters(cpu, c->core_id, c, p);
+		status = get_rapl_counters(cpu, get_rapl_domain_id(cpu), c, p);
 		if (status != 0)
 			return status;
 	}
@@ -4894,7 +4926,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
 		p->sys_lpi = cpuidle_cur_sys_lpi_us;

 	if (!platform->has_per_core_rapl) {
-		status = get_rapl_counters(cpu, p->package_id, c, p);
+		status = get_rapl_counters(cpu, get_rapl_domain_id(cpu), c, p);
 		if (status != 0)
 			return status;
 	}
@@ -7877,7 +7909,7 @@ void linux_perf_init(void)

 void rapl_perf_init(void)
 {
-	const unsigned int num_domains = (platform->has_per_core_rapl ? topo.max_core_id : topo.max_package_id) + 1;
+	const unsigned int num_domains = get_rapl_num_domains();
 	bool *domain_visited = calloc(num_domains, sizeof(bool));

 	rapl_counter_info_perdomain = calloc(num_domains, sizeof(*rapl_counter_info_perdomain));
@@ -7918,8 +7950,7 @@ void rapl_perf_init(void)
 				continue;

 			/* Skip already seen and handled RAPL domains */
-			next_domain =
-			    platform->has_per_core_rapl ? cpus[cpu].physical_core_id : cpus[cpu].physical_package_id;
+			next_domain = get_rapl_domain_id(cpu);

 			assert(next_domain < num_domains);


Prompt:
Given the following original C code:
if (fd != -1)
		close(fd);

	if (!has_access)
		warnx("Failed to access %s. Some of the counters may not be available\n"
		      "\tRun as root to enable them or use %s to disable the access explicitly",
		      "instructions retired perf counter", "--no-perf");

	return has_access;
}

int add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
			   double *scale_, enum rapl_unit *unit_)
{
	if (no_perf)
		return -1;

	const double scale = read_perf_scale(cai->perf_subsys, cai->perf_name);

Instruction:
tools/power turbostat: Remove add_rapl_perf_counter_()

Return the diff that fixes it:

Response:
@@ -7853,44 +7853,39 @@ static int has_instr_count_access(void)
 	return has_access;
 }

-int add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
+int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
 			   double *scale_, enum rapl_unit *unit_)
 {
+	int ret = -1;
+
 	if (no_perf)
 		return -1;

 	const double scale = read_perf_scale(cai->perf_subsys, cai->perf_name);

 	if (scale == 0.0)
-		return -1;
+		goto end;

 	const enum rapl_unit unit = read_perf_rapl_unit(cai->perf_subsys, cai->perf_name);

 	if (unit == RAPL_UNIT_INVALID)
-		return -1;
+		goto end;

 	const unsigned int rapl_type = read_perf_type(cai->perf_subsys);
 	const unsigned int rapl_energy_pkg_config = read_perf_config(cai->perf_subsys, cai->perf_name);

-	const int fd_counter =
-	    open_perf_counter(cpu, rapl_type, rapl_energy_pkg_config, rci->fd_perf, PERF_FORMAT_GROUP);
-	if (fd_counter == -1)
-		return -1;
+	ret = open_perf_counter(cpu, rapl_type, rapl_energy_pkg_config, rci->fd_perf, PERF_FORMAT_GROUP);
+	if (ret == -1)
+		goto end;

 	/* If it's the first counter opened, make it a group descriptor */
 	if (rci->fd_perf == -1)
-		rci->fd_perf = fd_counter;
+		rci->fd_perf = ret;

 	*scale_ = scale;
 	*unit_ = unit;
-	return fd_counter;
-}
-
-int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
-			  double *scale, enum rapl_unit *unit)
-{
-	int ret = add_rapl_perf_counter_(cpu, rci, cai, scale, unit);

+end:
 	if (debug >= 2)
 		fprintf(stderr, "%s: %d (cpu: %d)\n", __func__, ret, cpu);


Prompt:
Given the following original C code:
int *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *group_name)
{
	if (strcmp(group_name, "cstate_core") == 0)
		return &cci->fd_perf_core;

	if (strcmp(group_name, "cstate_pkg") == 0)
		return &cci->fd_perf_pkg;

	return NULL;
}

int add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)
{
	if (no_perf)
		return -1;

	int *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys);

	if (pfd_group == NULL)

Instruction:
tools/power turbostat: Remove add_cstate_perf_counter_()

Return the diff that fixes it:

Response:
@@ -8021,35 +8021,31 @@ int *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *gro
 	return NULL;
 }

-int add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)
+int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)
 {
+	int ret = -1;
+
 	if (no_perf)
 		return -1;

 	int *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys);

 	if (pfd_group == NULL)
-		return -1;
+		goto end;

 	const unsigned int type = read_perf_type(cai->perf_subsys);
 	const unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);

-	const int fd_counter = open_perf_counter(cpu, type, config, *pfd_group, PERF_FORMAT_GROUP);
+	ret = open_perf_counter(cpu, type, config, *pfd_group, PERF_FORMAT_GROUP);

-	if (fd_counter == -1)
-		return -1;
+	if (ret == -1)
+		goto end;

 	/* If it's the first counter opened, make it a group descriptor */
 	if (*pfd_group == -1)
-		*pfd_group = fd_counter;
-
-	return fd_counter;
-}
-
-int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)
-{
-	int ret = add_cstate_perf_counter_(cpu, cci, cai);
+		*pfd_group = ret;

+end:
 	if (debug >= 2)
 		fprintf(stderr, "%s: %d (cpu: %d)\n", __func__, ret, cpu);


Prompt:
Given the following original C code:
/* If it's the first counter opened, make it a group descriptor */
	if (*pfd_group == -1)
		*pfd_group = ret;

end:
	if (debug >= 2)
		fprintf(stderr, "%s: %d (cpu: %d)\n", __func__, ret, cpu);

	return ret;
}

int add_msr_perf_counter_(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)
{
	if (no_perf)
		return -1;

	const unsigned int type = read_perf_type(cai->perf_subsys);
	const unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);

Instruction:
tools/power turbostat: Remove add_msr_perf_counter_()

Return the diff that fixes it:

Response:
@@ -8052,30 +8052,26 @@ int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const st
 	return ret;
 }

-int add_msr_perf_counter_(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)
+int add_msr_perf_counter(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)
 {
+	int ret = -1;
+
 	if (no_perf)
 		return -1;

 	const unsigned int type = read_perf_type(cai->perf_subsys);
 	const unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);

-	const int fd_counter = open_perf_counter(cpu, type, config, cci->fd_perf, PERF_FORMAT_GROUP);
+	ret = open_perf_counter(cpu, type, config, cci->fd_perf, PERF_FORMAT_GROUP);

-	if (fd_counter == -1)
-		return -1;
+	if (ret == -1)
+		goto end;

 	/* If it's the first counter opened, make it a group descriptor */
 	if (cci->fd_perf == -1)
-		cci->fd_perf = fd_counter;
-
-	return fd_counter;
-}
-
-int add_msr_perf_counter(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)
-{
-	int ret = add_msr_perf_counter_(cpu, cci, cai);
+		cci->fd_perf = ret;

+end:
 	if (debug)
 		fprintf(stderr, "%s: %s/%s: %d (cpu: %d)\n", __func__, cai->perf_subsys, cai->perf_name, ret, cpu);


Prompt:
Given the following original C code:
assert(next_domain < num_domains);

			if (domain_visited[next_domain])
				continue;

			domain_visited[next_domain] = 1;

			if ((cai->flags & RAPL_COUNTER_FLAG_PLATFORM_COUNTER) && (cpu != base_cpu))
				continue;

			struct rapl_counter_info_t *rci = &rapl_counter_info_perdomain[next_domain];

			/* Use perf API for this counter */
			if (add_rapl_perf_counter(cpu, rci, cai, &scale, &unit) != -1) {
				rci->source[cai->rci_index] = COUNTER_SOURCE_PERF;
				rci->scale[cai->rci_index] = scale * cai->compat_scale;
				rci->unit[cai->rci_index] = unit;
				rci->flags[cai->rci_index] = cai->flags;

			/* Use MSR for this counter */

Instruction:
tools/power turbostat: Avoid probing the same perf counters

Return the diff that fixes it:

Response:
@@ -7991,6 +7991,21 @@ void rapl_perf_init(void)

 			struct rapl_counter_info_t *rci = &rapl_counter_info_perdomain[next_domain];

+			/*
+			 * rapl_counter_arch_infos[] can have multiple entries describing the same
+			 * counter, due to the difference from different platforms/Vendors.
+			 * E.g. rapl_counter_arch_infos[0] and rapl_counter_arch_infos[1] share the
+			 * same perf_subsys and perf_name, but with different MSR address.
+			 * rapl_counter_arch_infos[0] is for Intel and rapl_counter_arch_infos[1]
+			 * is for AMD.
+			 * In this case, it is possible that multiple rapl_counter_arch_infos[]
+			 * entries are probed just because their perf/msr is duplicate and valid.
+			 *
+			 * Thus need a check to avoid re-probe the same counters.
+			 */
+			if (rci->source[cai->rci_index] != COUNTER_SOURCE_NONE)
+				break;
+
 			/* Use perf API for this counter */
 			if (add_rapl_perf_counter(cpu, rci, cai, &scale, &unit) != -1) {
 				rci->source[cai->rci_index] = COUNTER_SOURCE_PERF;


Prompt:
Given the following original C code:
#define	BIC_Diec6		(1ULL << 58)
#define	BIC_SysWatt		(1ULL << 59)
#define	BIC_Sys_J		(1ULL << 60)
#define	BIC_NMI			(1ULL << 61)
#define	BIC_CPU_c1e		(1ULL << 62)
#define	BIC_pct_idle		(1ULL << 63)

#define BIC_GROUP_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)
#define BIC_GROUP_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)
#define BIC_GROUP_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)
#define BIC_GROUP_HW_IDLE (BIC_Busy | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)
#define BIC_GROUP_SW_IDLE (BIC_Busy | BIC_cpuidle | BIC_pct_idle )
#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle)
#define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)

#define BIC_DISABLED_BY_DEFAULT	(BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC | BIC_cpuidle)

unsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT);
unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_cpuidle | BIC_pct_idle | BIC_APIC | BIC_X2APIC;

Instruction:
tools/power turbostat: version 2025.06.08

Return the diff that fixes it:

Response:
@@ -280,7 +280,7 @@ struct msr_counter bic[] = {
 #define BIC_GROUP_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)
 #define BIC_GROUP_HW_IDLE (BIC_Busy | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)
 #define BIC_GROUP_SW_IDLE (BIC_Busy | BIC_cpuidle | BIC_pct_idle )
-#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle)
+#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle)
 #define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)

 #define BIC_DISABLED_BY_DEFAULT	(BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC | BIC_cpuidle)
@@ -1091,7 +1091,6 @@ void probe_platform_features(unsigned int family, unsigned int model)
 {
 	int i;

-
 	if (authentic_amd || hygon_genuine) {
 		/* fallback to default features on unsupported models */
 		force_load++;
@@ -1125,8 +1124,7 @@ void probe_platform_features(unsigned int family, unsigned int model)
 	if (platform)
 		return;

-	fprintf(stderr, "Unsupported platform detected.\n"
-		"\tSee RUN THE LATEST VERSION on turbostat(8)\n");
+	fprintf(stderr, "Unsupported platform detected.\n\tSee RUN THE LATEST VERSION on turbostat(8)\n");
 	exit(1);
 }

@@ -1146,7 +1144,8 @@ char *progname;

 #define CPU_SUBSET_MAXCPUS	8192	/* need to use before probe... */
 cpu_set_t *cpu_present_set, *cpu_possible_set, *cpu_effective_set, *cpu_allowed_set, *cpu_affinity_set, *cpu_subset;
-size_t cpu_present_setsize, cpu_possible_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize, cpu_subset_size;
+size_t cpu_present_setsize, cpu_possible_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize,
+    cpu_subset_size;
 #define MAX_ADDED_THREAD_COUNTERS 24
 #define MAX_ADDED_CORE_COUNTERS 8
 #define MAX_ADDED_PACKAGE_COUNTERS 16
@@ -2373,8 +2372,7 @@ void help(void)
 		"		  degrees Celsius\n"
 		"  -h, --help\n"
 		"		print this help message\n"
-		"  -v, --version\n"
-		"		print version information\n\nFor more help, run \"man turbostat\"\n");
+		"  -v, --version\n\t\tprint version information\n\nFor more help, run \"man turbostat\"\n");
 }

 /*
@@ -3989,7 +3987,6 @@ void compute_average(struct thread_data *t, struct core_data *c, struct pkg_data
 	if (average.threads.nmi_count > 9999999)
 		sums_need_wide_columns = 1;

-
 	average.cores.c3 /= topo.allowed_cores;
 	average.cores.c6 /= topo.allowed_cores;
 	average.cores.c7 /= topo.allowed_cores;
@@ -4812,7 +4809,6 @@ unsigned long pmt_read_counter(struct pmt_counter *ppmt, unsigned int domain_id)
 	return (value & value_mask) >> value_shift;
 }

-
 /* Rapl domain enumeration helpers */
 static inline int get_rapl_num_domains(void)
 {
@@ -6822,8 +6818,10 @@ static void probe_intel_uncore_frequency_cluster(void)
 		 * This allows "--show/--hide UncMHz" to be effective for
 		 * the clustered MHz counters, as a group.
 		 */
-		if BIC_IS_ENABLED(BIC_UNCORE_MHZ)
-			add_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0, package_id);
+		if BIC_IS_ENABLED
+			(BIC_UNCORE_MHZ)
+			    add_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0,
+					package_id);

 		if (quiet)
 			continue;
@@ -6895,17 +6893,21 @@ static void probe_graphics(void)
 		else
 			goto next;

-		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms", gt0_is_gt ? GFX_rc6 : SAM_mc6);
+		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms",
+				gt0_is_gt ? GFX_rc6 : SAM_mc6);

 		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt0/freq0/cur_freq", gt0_is_gt ? GFX_MHz : SAM_MHz);

-		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt0/freq0/act_freq", gt0_is_gt ? GFX_ACTMHz : SAM_ACTMHz);
+		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt0/freq0/act_freq",
+				gt0_is_gt ? GFX_ACTMHz : SAM_ACTMHz);

-		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt1/gtidle/idle_residency_ms", gt0_is_gt ? SAM_mc6 : GFX_rc6);
+		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt1/gtidle/idle_residency_ms",
+				gt0_is_gt ? SAM_mc6 : GFX_rc6);

 		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt1/freq0/cur_freq", gt0_is_gt ? SAM_MHz : GFX_MHz);

-		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt1/freq0/act_freq", gt0_is_gt ? SAM_ACTMHz : GFX_ACTMHz);
+		set_graphics_fp("/sys/class/drm/card0/device/tile0/gt1/freq0/act_freq",
+				gt0_is_gt ? SAM_ACTMHz : GFX_ACTMHz);

 		goto end;
 	}
@@ -7428,7 +7430,7 @@ static int fread_int(char *path, int *val)
 	FILE *filep;
 	int ret;

-	filep = fopen (path, "r");
+	filep = fopen(path, "r");
 	if (!filep)
 		return -1;

@@ -7442,7 +7444,7 @@ static int fread_ull(char *path, unsigned long long *val)
 	FILE *filep;
 	int ret;

-	filep = fopen (path, "r");
+	filep = fopen(path, "r");
 	if (!filep)
 		return -1;

@@ -7457,7 +7459,7 @@ static int fread_str(char *path, char *buf, int size)
 	int ret;
 	char *cp;

-	filep = fopen (path, "r");
+	filep = fopen(path, "r");
 	if (!filep)
 		return -1;

@@ -7500,17 +7502,16 @@ static int dump_one_domain(char *domain_path)
 		return 0;
 	}

-	for (constraint = 0;; constraint++)
-	{
+	for (constraint = 0;; constraint++) {
 		snprintf(path, PATH_MAX, "%s/constraint_%d_time_window_us", domain_path, constraint);
 		ret = fread_ull(path, &val);
 		if (ret <= 0)
 			break;

 		if (val > 1000000)
-			fprintf(outf, " %0.1fs", (double)val/1000000);
+			fprintf(outf, " %0.1fs", (double)val / 1000000);
 		else if (val > 1000)
-			fprintf(outf, " %0.1fms", (double)val/1000);
+			fprintf(outf, " %0.1fms", (double)val / 1000);
 		else
 			fprintf(outf, " %0.1fus", (double)val);

@@ -7541,30 +7542,29 @@ static int print_rapl_sysfs(void)
 		return 1;
 	}

-	while ((entry = readdir (dir)) != NULL) {
+	while ((entry = readdir(dir)) != NULL) {
 		if (strlen(entry->d_name) > 100)
-                        continue;
+			continue;

 		if (strncmp(entry->d_name, "intel-rapl", strlen("intel-rapl")))
-                        continue;
+			continue;

 		snprintf(path, PATH_MAX, "%s/%s/name", PATH_RAPL_SYSFS, entry->d_name);

 		/* Parse top level domains first, including package and psys */
 		fread_str(path, str, PATH_MAX);
-		if (strncmp(str, "package", strlen("package")) &&
-		    strncmp(str, "psys", strlen("psys")))
+		if (strncmp(str, "package", strlen("package")) && strncmp(str, "psys", strlen("psys")))
 			continue;

 		snprintf(path, PATH_MAX, "%s/%s", PATH_RAPL_SYSFS, entry->d_name);
 		if ((cdir = opendir(path)) == NULL) {
-			perror ("opendir() error");
+			perror("opendir() error");
 			return 1;
 		}

 		dump_one_domain(path);

-		while ((centry = readdir (cdir)) != NULL) {
+		while ((centry = readdir(cdir)) != NULL) {
 			if (strncmp(centry->d_name, "intel-rapl", strlen("intel-rapl")))
 				continue;
 			snprintf(path, PATH_MAX, "%s/%s/%s", PATH_RAPL_SYSFS, entry->d_name, centry->d_name);
@@ -8049,7 +8049,7 @@ static int has_instr_count_access(void)
 }

 int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
-			   double *scale_, enum rapl_unit *unit_)
+			  double *scale_, enum rapl_unit *unit_)
 {
 	int ret = -1;

@@ -8188,7 +8188,7 @@ void rapl_perf_init(void)
 				rci->unit[cai->rci_index] = unit;
 				rci->flags[cai->rci_index] = cai->flags;

-			/* Use MSR for this counter */
+				/* Use MSR for this counter */
 			} else if (add_rapl_msr_counter(cpu, cai) >= 0) {
 				rci->source[cai->rci_index] = COUNTER_SOURCE_MSR;
 				rci->msr[cai->rci_index] = cai->msr;
@@ -9299,15 +9299,14 @@ int added_perf_counters_init_(struct perf_counter_info *pinfo)
 					perf_device = "cpu_atom";
 					break;

-				default: /* Don't change, we will probably fail and report a problem soon. */
+				default:	/* Don't change, we will probably fail and report a problem soon. */
 					break;
 				}
 			}

 			perf_type = read_perf_type(perf_device);
 			if (perf_type == (unsigned int)-1) {
-				warnx("%s: perf/%s/%s: failed to read %s",
-				      __func__, perf_device, pinfo->event, "type");
+				warnx("%s: perf/%s/%s: failed to read %s", __func__, perf_device, pinfo->event, "type");
 				continue;
 			}

@@ -9409,7 +9408,7 @@ struct pmt_mmio *pmt_mmio_open(unsigned int target_guid)
 		return NULL;
 	}

-	for ( ; entry != NULL; entry = pmt_diriter_next(&pmt_iter)) {
+	for (; entry != NULL; entry = pmt_diriter_next(&pmt_iter)) {
 		if (fstatat(dirfd(pmt_iter.dir), entry->d_name, &st, 0) == -1)
 			break;

@@ -9849,7 +9848,7 @@ int get_and_dump_counters(void)

 void print_version()
 {
-	fprintf(outf, "turbostat version 2025.04.06 - Len Brown <lenb@kernel.org>\n");
+	fprintf(outf, "turbostat version 2025.06.08 - Len Brown <lenb@kernel.org>\n");
 }

 #define COMMAND_LINE_SIZE 2048
@@ -10305,7 +10304,7 @@ void parse_add_command_pmt(char *add_command)
 	unsigned int lsb;
 	unsigned int msb;
 	unsigned int guid;
-	unsigned int seq = 0; /* By default, pick first file in a sequence with a given GUID. */
+	unsigned int seq = 0;	/* By default, pick first file in a sequence with a given GUID. */
 	unsigned int domain_id;
 	enum counter_scope scope = 0;
 	enum pmt_datatype type = PMT_TYPE_RAW;


Prompt:
Given the following original C code:
n_slots = params_channels(params);
		slotw = dataw;
	}

	val = snd_soc_component_read(component, base + CS48L32_ASP_CONTROL2);
	val = (val & CS48L32_ASP_FMT_MASK) >> CS48L32_ASP_FMT_SHIFT;
	if (val == CS48L32_ASP_FMT_I2S_MODE)
		n_slots_multiple = 2;
	else
		n_slots_multiple = 1;

	sclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);

	for (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {
		if ((cs48l32_sclk_rates[i].freq >= sclk_target) &&
		    (cs48l32_sclk_rates[i].freq % rate == 0)) {
			sclk = cs48l32_sclk_rates[i].id;
			break;
		}
	}

Instruction:
ASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()

Return the diff that fixes it:

Response:
@@ -2162,6 +2162,10 @@ static int cs48l32_hw_params(struct snd_pcm_substream *substream,
 		n_slots_multiple = 1;

 	sclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);
+	if (sclk_target < 0) {
+		cs48l32_asp_err(dai, "Invalid parameters\n");
+		return sclk_target;
+	}

 	for (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {
 		if ((cs48l32_sclk_rates[i].freq >= sclk_target) &&


Prompt:
Given the following original C code:
// SPDX-License-Identifier: GPL-2.0
//
// Common functions for loongson I2S controller driver
//
// Copyright (C) 2023 Loongson Technology Corporation Limited.
// Author: Yingkun Meng <mengyingkun@loongson.cn>
//

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <linux/dma-mapping.h>
#include <sound/soc.h>
#include <linux/regmap.h>
#include <sound/pcm_params.h>
#include "loongson_i2s.h"

#define LOONGSON_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | \

Instruction:
ASoC: loongson: Fix build warnings about export.h

Return the diff that fixes it:

Response:
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/export.h>
 #include <linux/pm_runtime.h>
 #include <linux/dma-mapping.h>
 #include <sound/soc.h>


Prompt:
Given the following original C code:
// SPDX-License-Identifier: GPL-2.0-or-later
//
// max20086-regulator.c - MAX20086-MAX20089 camera power protector driver
//
// Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com>
// Copyright (C) 2018 Avnet, Inc.

#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>

Instruction:
regulator: max20086: Fix refcount leak in max20086_parse_regulators_dt()

Return the diff that fixes it:

Response:
@@ -5,6 +5,7 @@
 // Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com>
 // Copyright (C) 2018 Avnet, Inc.

+#include <linux/cleanup.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
@@ -133,11 +134,11 @@ static int max20086_regulators_register(struct max20086 *chip)
 static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on)
 {
 	struct of_regulator_match *matches;
-	struct device_node *node;
 	unsigned int i;
 	int ret;

-	node = of_get_child_by_name(chip->dev->of_node, "regulators");
+	struct device_node *node __free(device_node) =
+		of_get_child_by_name(chip->dev->of_node, "regulators");
 	if (!node) {
 		dev_err(chip->dev, "regulators node not found\n");
 		return -ENODEV;
@@ -153,7 +154,6 @@ static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on)

 	ret = of_regulator_match(chip->dev, node, matches,
 				 chip->info->num_outputs);
-	of_node_put(node);
 	if (ret < 0) {
 		dev_err(chip->dev, "Failed to match regulators\n");
 		return -EINVAL;


Prompt:
Given the following original C code:
/*
		 * Check if this transfer contains only one word;
		 */
		if (bits_per_word < 8 && tr->len == 1) {
			/* multi-mode is applicable, only one word (1..7 bits) */
		} else if (bits_per_word >= 8 && tr->len == bits_per_word / 8) {
			/* multi-mode is applicable, only one word (8..32 bits) */
		} else {
			/* multi-mode is not applicable: more than one word in the transfer */
			mcspi->use_multi_mode = false;
		}

		/* Check if transfer asks to change the CS status after the transfer */
		if (!tr->cs_change)
			mcspi->use_multi_mode = false;

		/*
		 * If at least one message is not compatible, switch back to single mode
		 *
		 * The bits_per_word of certain transfer can be different, but it will have no

Instruction:
spi: omap2-mcspi: Disable multi mode when CS should be kept asserted after message

Return the diff that fixes it:

Response:
@@ -1287,9 +1287,15 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
 			mcspi->use_multi_mode = false;
 		}

-		/* Check if transfer asks to change the CS status after the transfer */
-		if (!tr->cs_change)
-			mcspi->use_multi_mode = false;
+		if (list_is_last(&tr->transfer_list, &msg->transfers)) {
+			/* Check if transfer asks to keep the CS status after the whole message */
+			if (tr->cs_change)
+				mcspi->use_multi_mode = false;
+		} else {
+			/* Check if transfer asks to change the CS status after the transfer */
+			if (!tr->cs_change)
+				mcspi->use_multi_mode = false;
+		}

 		/*
 		 * If at least one message is not compatible, switch back to single mode


Prompt:
Given the following original C code:
unsigned long		phys;
	/* SPI1 has 4 channels, while SPI2 has 2 */
	struct omap2_mcspi_dma	*dma_channels;
	struct device		*dev;
	struct omap2_mcspi_regs ctx;
	struct clk		*ref_clk;
	int			fifo_depth;
	bool			target_aborted;
	unsigned int		pin_dir:1;
	size_t			max_xfer_len;
	u32			ref_clk_hz;
	bool			use_multi_mode;
};

struct omap2_mcspi_cs {
	void __iomem		*base;
	unsigned long		phys;
	int			word_len;
	u16			mode;
	struct list_head	node;

Instruction:
spi: omap2-mcspi: Disable multi-mode when the previous message kept CS asserted

Return the diff that fixes it:

Response:
@@ -134,6 +134,7 @@ struct omap2_mcspi {
 	size_t			max_xfer_len;
 	u32			ref_clk_hz;
 	bool			use_multi_mode;
+	bool			last_msg_kept_cs;
 };

 struct omap2_mcspi_cs {
@@ -1269,6 +1270,10 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
 	 * multi-mode is applicable.
 	 */
 	mcspi->use_multi_mode = true;
+
+	if (mcspi->last_msg_kept_cs)
+		mcspi->use_multi_mode = false;
+
 	list_for_each_entry(tr, &msg->transfers, transfer_list) {
 		if (!tr->bits_per_word)
 			bits_per_word = msg->spi->bits_per_word;
@@ -1289,22 +1294,17 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,

 		if (list_is_last(&tr->transfer_list, &msg->transfers)) {
 			/* Check if transfer asks to keep the CS status after the whole message */
-			if (tr->cs_change)
+			if (tr->cs_change) {
 				mcspi->use_multi_mode = false;
+				mcspi->last_msg_kept_cs = true;
+			} else {
+				mcspi->last_msg_kept_cs = false;
+			}
 		} else {
 			/* Check if transfer asks to change the CS status after the transfer */
 			if (!tr->cs_change)
 				mcspi->use_multi_mode = false;
 		}
-
-		/*
-		 * If at least one message is not compatible, switch back to single mode
-		 *
-		 * The bits_per_word of certain transfer can be different, but it will have no
-		 * impact on the signal itself.
-		 */
-		if (!mcspi->use_multi_mode)
-			break;
 	}

 	omap2_mcspi_set_mode(ctlr);


Prompt:
Given the following original C code:
// SPDX-License-Identifier: GPL-2.0+
// Loongson SPI Support
// Copyright (C) 2023 Loongson Technology Corporation Limited

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/spi/spi.h>

Instruction:
spi: loongson: Fix build warnings about export.h

Return the diff that fixes it:

Response:
@@ -5,6 +5,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/err.h>
+#include <linux/export.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>


Prompt:
Given the following original C code:
ret = pcim_request_all_regions(pdev, DRV_NAME);
			if (ret)
				return -ENOMEM;

			spi_bus->reg_base = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0));
			if (!spi_bus->reg_base)
				return -EINVAL;

			num_vector = pci_alloc_irq_vectors(pdev, 1, hw_inst_cnt,
							   PCI_IRQ_ALL_TYPES);
			if (num_vector < 0) {
				dev_err(&pdev->dev, "Error allocating MSI vectors\n");
				return ret;
			}

			init_completion(&spi_sub_ptr->spi_xfer_done);
			/* Initialize Interrupts - SPI_INT */
			regval = readl(spi_bus->reg_base +
				       SPI_MST_EVENT_MASK_REG_OFFSET(spi_sub_ptr->hw_inst));
			regval &= ~SPI_INTR;

Instruction:
spi: spi-pci1xxxx: Fix error code in probe

Return the diff that fixes it:

Response:
@@ -765,7 +765,7 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id *
 							   PCI_IRQ_ALL_TYPES);
 			if (num_vector < 0) {
 				dev_err(&pdev->dev, "Error allocating MSI vectors\n");
-				return ret;
+				return num_vector;
 			}

 			init_completion(&spi_sub_ptr->spi_xfer_done);


Prompt:
Given the following original C code:
unsigned int id;
	bool wide_bus_supported;
};

static const struct msm_dp_desc msm_dp_desc_sa8775p[] = {
	{ .io_start = 0x0af54000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },
	{ .io_start = 0x0af5c000, .id = MSM_DP_CONTROLLER_1, .wide_bus_supported = true },
	{ .io_start = 0x22154000, .id = MSM_DP_CONTROLLER_2, .wide_bus_supported = true },
	{ .io_start = 0x2215c000, .id = MSM_DP_CONTROLLER_3, .wide_bus_supported = true },
	{}
};

static const struct msm_dp_desc msm_dp_desc_sc7180[] = {
	{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },
	{}
};

static const struct msm_dp_desc msm_dp_desc_sc7280[] = {
	{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },
	{ .io_start = 0x0aea0000, .id = MSM_DP_CONTROLLER_1, .wide_bus_supported = true },

Instruction:
drm/msm/dp: Disable wide bus support for SDM845

Return the diff that fixes it:

Response:
@@ -128,6 +128,11 @@ static const struct msm_dp_desc msm_dp_desc_sa8775p[] = {
 	{}
 };

+static const struct msm_dp_desc msm_dp_desc_sdm845[] = {
+	{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0 },
+	{}
+};
+
 static const struct msm_dp_desc msm_dp_desc_sc7180[] = {
 	{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },
 	{}
@@ -180,7 +185,7 @@ static const struct of_device_id msm_dp_dt_match[] = {
 	{ .compatible = "qcom,sc8180x-edp", .data = &msm_dp_desc_sc8180x },
 	{ .compatible = "qcom,sc8280xp-dp", .data = &msm_dp_desc_sc8280xp },
 	{ .compatible = "qcom,sc8280xp-edp", .data = &msm_dp_desc_sc8280xp },
-	{ .compatible = "qcom,sdm845-dp", .data = &msm_dp_desc_sc7180 },
+	{ .compatible = "qcom,sdm845-dp", .data = &msm_dp_desc_sdm845 },
 	{ .compatible = "qcom,sm8350-dp", .data = &msm_dp_desc_sc7180 },
 	{ .compatible = "qcom,sm8650-dp", .data = &msm_dp_desc_sm8650 },
 	{ .compatible = "qcom,x1e80100-dp", .data = &msm_dp_desc_x1e80100 },


Prompt:
Given the following original C code:
timing->hsync_polarity = (mode->flags & DRM_MODE_FLAG_NHSYNC) ? 1 : 0;
	timing->vsync_polarity = (mode->flags & DRM_MODE_FLAG_NVSYNC) ? 1 : 0;
	timing->border_clr = 0;
	timing->underflow_clr = 0xff;
	timing->hsync_skew = mode->hskew;

	/* DSI controller cannot handle active-low sync signals. */
	if (phys_enc->hw_intf->cap->type == INTF_DSI) {
		timing->hsync_polarity = 0;
		timing->vsync_polarity = 0;
	}

	/* for DP/EDP, Shift timings to align it to bottom right */
	if (phys_enc->hw_intf->cap->type == INTF_DP) {
		timing->h_back_porch += timing->h_front_porch;
		timing->h_front_porch = 0;
		timing->v_back_porch += timing->v_front_porch;
		timing->v_front_porch = 0;
	}

Instruction:
drm/msm/disp: Correct porch timing for SDM845

Return the diff that fixes it:

Response:
@@ -94,17 +94,21 @@ static void drm_mode_to_intf_timing_params(
 		timing->vsync_polarity = 0;
 	}

-	/* for DP/EDP, Shift timings to align it to bottom right */
-	if (phys_enc->hw_intf->cap->type == INTF_DP) {
+	timing->wide_bus_en = dpu_encoder_is_widebus_enabled(phys_enc->parent);
+	timing->compression_en = dpu_encoder_is_dsc_enabled(phys_enc->parent);
+
+	/*
+	 *  For DP/EDP, Shift timings to align it to bottom right.
+	 *  wide_bus_en is set for everything excluding SDM845 &
+	 *  porch changes cause DisplayPort failure and HDMI tearing.
+	 */
+	if (phys_enc->hw_intf->cap->type == INTF_DP && timing->wide_bus_en) {
 		timing->h_back_porch += timing->h_front_porch;
 		timing->h_front_porch = 0;
 		timing->v_back_porch += timing->v_front_porch;
 		timing->v_front_porch = 0;
 	}

-	timing->wide_bus_en = dpu_encoder_is_widebus_enabled(phys_enc->parent);
-	timing->compression_en = dpu_encoder_is_dsc_enabled(phys_enc->parent);
-
 	/*
 	 * for DP, divide the horizonal parameters by 2 when
 	 * widebus is enabled


Prompt:
Given the following original C code:
ret = pll_10nm_register(pll_10nm, phy->provided_clocks->hws);
	if (ret) {
		DRM_DEV_ERROR(&pdev->dev, "failed to register PLL: %d\n", ret);
		return ret;
	}

	phy->vco_hw = &pll_10nm->clk_hw;

	/* TODO: Remove this when we have proper display handover support */
	msm_dsi_phy_pll_save_state(phy);

	return 0;
}

static int dsi_phy_hw_v3_0_is_pll_on(struct msm_dsi_phy *phy)
{
	void __iomem *base = phy->base;
	u32 data = 0;

Instruction:
drm/msm/dsi/dsi_phy_10nm: Fix missing initial VCO rate

Return the diff that fixes it:

Response:
@@ -704,6 +704,13 @@ static int dsi_pll_10nm_init(struct msm_dsi_phy *phy)
 	/* TODO: Remove this when we have proper display handover support */
 	msm_dsi_phy_pll_save_state(phy);

+	/*
+	 * Store also proper vco_current_rate, because its value will be used in
+	 * dsi_10nm_pll_restore_state().
+	 */
+	if (!dsi_pll_10nm_vco_recalc_rate(&pll_10nm->clk_hw, VCO_REF_CLK_RATE))
+		pll_10nm->vco_current_rate = pll_10nm->phy->cfg->min_pll_rate;
+
 	return 0;
 }


Prompt:
Given the following original C code:
*  Copyright © 2010 David Woodhouse <dwmw2@infradead.org>
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/acpi.h>
#include <linux/backlight.h>
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/dmi.h>
#include <linux/i8042.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>

Instruction:
platform/x86: ideapad-laptop: use usleep_range() for EC polling

Return the diff that fixes it:

Response:
@@ -15,6 +15,7 @@
 #include <linux/bug.h>
 #include <linux/cleanup.h>
 #include <linux/debugfs.h>
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/dmi.h>
 #include <linux/i8042.h>
@@ -267,6 +268,20 @@ static void ideapad_shared_exit(struct ideapad_private *priv)
  */
 #define IDEAPAD_EC_TIMEOUT 200 /* in ms */

+/*
+ * Some models (e.g., ThinkBook since 2024) have a low tolerance for being
+ * polled too frequently. Doing so may break the state machine in the EC,
+ * resulting in a hard shutdown.
+ *
+ * It is also observed that frequent polls may disturb the ongoing operation
+ * and notably delay the availability of EC response.
+ *
+ * These values are used as the delay before the first poll and the interval
+ * between subsequent polls to solve the above issues.
+ */
+#define IDEAPAD_EC_POLL_MIN_US 150
+#define IDEAPAD_EC_POLL_MAX_US 300
+
 static int eval_int(acpi_handle handle, const char *name, unsigned long *res)
 {
 	unsigned long long result;
@@ -383,7 +398,7 @@ static int read_ec_data(acpi_handle handle, unsigned long cmd, unsigned long *da
 	end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1;

 	while (time_before(jiffies, end_jiffies)) {
-		schedule();
+		usleep_range(IDEAPAD_EC_POLL_MIN_US, IDEAPAD_EC_POLL_MAX_US);

 		err = eval_vpcr(handle, 1, &val);
 		if (err)
@@ -414,7 +429,7 @@ static int write_ec_cmd(acpi_handle handle, unsigned long cmd, unsigned long dat
 	end_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1;

 	while (time_before(jiffies, end_jiffies)) {
-		schedule();
+		usleep_range(IDEAPAD_EC_POLL_MIN_US, IDEAPAD_EC_POLL_MAX_US);

 		err = eval_vpcr(handle, 1, &val);
 		if (err)


Prompt:
Given the following original C code:
sizeof(*tpmi_uncore->pd_info),
					    GFP_KERNEL);
	if (!tpmi_uncore->pd_info) {
		ret = -ENOMEM;
		goto err_rem_common;
	}

	tpmi_uncore->power_domain_count = num_resources;
	tpmi_uncore->write_blocked = write_blocked;

	/* Get the package ID from the TPMI core */
	plat_info = tpmi_get_platform_data(auxdev);
	if (plat_info)
		pkg = plat_info->package_id;
	else
		dev_info(&auxdev->dev, "Platform information is NULL\n");

	for (i = 0; i < num_resources; ++i) {
		struct tpmi_uncore_power_domain_info *pd_info;
		struct resource *res;

Instruction:
platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL

Return the diff that fixes it:

Response:
@@ -511,10 +511,13 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_

 	/* Get the package ID from the TPMI core */
 	plat_info = tpmi_get_platform_data(auxdev);
-	if (plat_info)
-		pkg = plat_info->package_id;
-	else
+	if (unlikely(!plat_info)) {
 		dev_info(&auxdev->dev, "Platform information is NULL\n");
+		ret = -ENODEV;
+		goto err_rem_common;
+	}
+
+	pkg = plat_info->package_id;

 	for (i = 0; i < num_resources; ++i) {
 		struct tpmi_uncore_power_domain_info *pd_info;


Prompt:
Given the following original C code:
SND_PCI_QUIRK(0x17aa, 0x2227, "Lenovo X1 Carbon 3rd Gen", 0),
	SND_PCI_QUIRK(0x17aa, 0x316e, "Lenovo ThinkCentre M70q", 0),
	/* https://bugzilla.redhat.com/show_bug.cgi?id=1689623 */
	SND_PCI_QUIRK(0x17aa, 0x367b, "Lenovo IdeaCentre B550", 0),
	/* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */
	SND_PCI_QUIRK(0x17aa, 0x36a7, "Lenovo C50 All in one", 0),
	/* https://bugs.launchpad.net/bugs/1821663 */
	SND_PCI_QUIRK(0x1631, 0xe017, "Packard Bell NEC IMEDIA 5204", 0),
	/* KONTRON SinglePC may cause a stall at runtime resume */
	SND_PCI_QUIRK(0x1734, 0x1232, "KONTRON SinglePC", 0),
	/* Dell ALC3271 */
	SND_PCI_QUIRK(0x1028, 0x0962, "Dell ALC3271", 0),
	{}
};

static void set_default_power_save(struct azx *chip)
{
	struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
	int val = power_save;

Instruction:
ALSA: hda/intel: Add Thinkpad E15 to PM deny list

Return the diff that fixes it:

Response:
@@ -2283,6 +2283,8 @@ static const struct snd_pci_quirk power_save_denylist[] = {
 	SND_PCI_QUIRK(0x1734, 0x1232, "KONTRON SinglePC", 0),
 	/* Dell ALC3271 */
 	SND_PCI_QUIRK(0x1028, 0x0962, "Dell ALC3271", 0),
+	/* https://bugzilla.kernel.org/show_bug.cgi?id=220210 */
+	SND_PCI_QUIRK(0x17aa, 0x5079, "Lenovo Thinkpad E15", 0),
 	{}
 };


Prompt:
Given the following original C code:
/* Check for MSR 0x54 presence */
	ret = rdmsrq_safe(MSR_PM_LOGICAL_ID, &data);
	if (ret)
		return ret;

	tpmi_power_domain_mask = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
					 sizeof(*tpmi_power_domain_mask), GFP_KERNEL);
	if (!tpmi_power_domain_mask)
		return -ENOMEM;

	domain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
				 sizeof(*domain_die_map), GFP_KERNEL);
	if (!domain_die_map)
		goto free_domain_mask;

	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
				"platform/x86/tpmi_power_domains:online",
				tpmi_cpu_online, NULL);
	if (ret < 0)
		goto free_domain_map;

Instruction:
platform/x86/intel: power-domains: Fix error code in tpmi_init()

Return the diff that fixes it:

Response:
@@ -228,8 +228,10 @@ static int __init tpmi_init(void)

 	domain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
 				 sizeof(*domain_die_map), GFP_KERNEL);
-	if (!domain_die_map)
+	if (!domain_die_map) {
+		ret = -ENOMEM;
 		goto free_domain_mask;
+	}

 	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
 				"platform/x86/tpmi_power_domains:online",


Prompt:
Given the following original C code:
u64 smu_phys_addr;

		amd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, true);
		amd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, true);
		smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);

		dev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr,
						  sizeof(struct smu_metrics));
		if (!dev->smu_virt_addr)
			return -ENOMEM;
	}

	/* Start the logging */
	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, false);
	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, false);

	return 0;
}

static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table)

Instruction:
platform/x86/amd: pmc: Clear metrics table at start of cycle

Return the diff that fixes it:

Response:
@@ -157,6 +157,8 @@ static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
 			return -ENOMEM;
 	}

+	memset_io(dev->smu_virt_addr, 0, sizeof(struct smu_metrics));
+
 	/* Start the logging */
 	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, false);
 	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, false);


Prompt:
Given the following original C code:
int ret;

	if (!msg)
		return -EINVAL;
	ret = validate_message(msg);
	if (ret)
		return ret;

	if (!hsmp_pdev.sock || msg->sock_ind >= hsmp_pdev.num_sockets)
		return -ENODEV;
	sock = &hsmp_pdev.sock[msg->sock_ind];

	/*
	 * The time taken by smu operation to complete is between
	 * 10us to 1ms. Sometime it may take more time.
	 * In SMP system timeout of 100 millisecs should
	 * be enough for the previous thread to finish the operation
	 */
	ret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT));
	if (ret < 0)

Instruction:
x86/platform/amd: replace down_timeout() with down_interruptible()

Return the diff that fixes it:

Response:
@@ -214,13 +214,7 @@ int hsmp_send_message(struct hsmp_message *msg)
 		return -ENODEV;
 	sock = &hsmp_pdev.sock[msg->sock_ind];

-	/*
-	 * The time taken by smu operation to complete is between
-	 * 10us to 1ms. Sometime it may take more time.
-	 * In SMP system timeout of 100 millisecs should
-	 * be enough for the previous thread to finish the operation
-	 */
-	ret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT));
+	ret = down_interruptible(&sock->hsmp_sem);
 	if (ret < 0)
 		return ret;


Prompt:
Given the following original C code:
static const struct of_device_id apq8064_pinctrl_of_match[] = {
	{ .compatible = "qcom,apq8064-pinctrl", },
	{ },
};

static struct platform_driver apq8064_pinctrl_driver = {
	.driver = {
		.name = "apq8064-pinctrl",
		.of_match_table = apq8064_pinctrl_of_match,
	},
	.probe = apq8064_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init apq8064_pinctrl_init(void)
{
	return platform_driver_register(&apq8064_pinctrl_driver);
}
arch_initcall(apq8064_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -629,7 +629,6 @@ static struct platform_driver apq8064_pinctrl_driver = {
 		.of_match_table = apq8064_pinctrl_of_match,
 	},
 	.probe = apq8064_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init apq8064_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id apq8084_pinctrl_of_match[] = {
	{ .compatible = "qcom,apq8084-pinctrl", },
	{ },
};

static struct platform_driver apq8084_pinctrl_driver = {
	.driver = {
		.name = "apq8084-pinctrl",
		.of_match_table = apq8084_pinctrl_of_match,
	},
	.probe = apq8084_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init apq8084_pinctrl_init(void)
{
	return platform_driver_register(&apq8084_pinctrl_driver);
}
arch_initcall(apq8084_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1207,7 +1207,6 @@ static struct platform_driver apq8084_pinctrl_driver = {
 		.of_match_table = apq8084_pinctrl_of_match,
 	},
 	.probe = apq8084_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init apq8084_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq4019_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq4019-pinctrl", },
	{ },
};

static struct platform_driver ipq4019_pinctrl_driver = {
	.driver = {
		.name = "ipq4019-pinctrl",
		.of_match_table = ipq4019_pinctrl_of_match,
	},
	.probe = ipq4019_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq4019_pinctrl_init(void)
{
	return platform_driver_register(&ipq4019_pinctrl_driver);
}
arch_initcall(ipq4019_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -710,7 +710,6 @@ static struct platform_driver ipq4019_pinctrl_driver = {
 		.of_match_table = ipq4019_pinctrl_of_match,
 	},
 	.probe = ipq4019_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq4019_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq5018_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq5018-tlmm", },
	{ }
};
MODULE_DEVICE_TABLE(of, ipq5018_pinctrl_of_match);

static struct platform_driver ipq5018_pinctrl_driver = {
	.driver = {
		.name = "ipq5018-tlmm",
		.of_match_table = ipq5018_pinctrl_of_match,
	},
	.probe = ipq5018_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq5018_pinctrl_init(void)
{
	return platform_driver_register(&ipq5018_pinctrl_driver);
}
arch_initcall(ipq5018_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -754,7 +754,6 @@ static struct platform_driver ipq5018_pinctrl_driver = {
 		.of_match_table = ipq5018_pinctrl_of_match,
 	},
 	.probe = ipq5018_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq5018_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq5332_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq5332-tlmm", },
	{ },
};
MODULE_DEVICE_TABLE(of, ipq5332_pinctrl_of_match);

static struct platform_driver ipq5332_pinctrl_driver = {
	.driver = {
		.name = "ipq5332-tlmm",
		.of_match_table = ipq5332_pinctrl_of_match,
	},
	.probe = ipq5332_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq5332_pinctrl_init(void)
{
	return platform_driver_register(&ipq5332_pinctrl_driver);
}
arch_initcall(ipq5332_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -834,7 +834,6 @@ static struct platform_driver ipq5332_pinctrl_driver = {
 		.of_match_table = ipq5332_pinctrl_of_match,
 	},
 	.probe = ipq5332_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq5332_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq5424_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq5424-tlmm", },
	{ },
};
MODULE_DEVICE_TABLE(of, ipq5424_pinctrl_of_match);

static struct platform_driver ipq5424_pinctrl_driver = {
	.driver = {
		.name = "ipq5424-tlmm",
		.of_match_table = ipq5424_pinctrl_of_match,
	},
	.probe = ipq5424_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq5424_pinctrl_init(void)
{
	return platform_driver_register(&ipq5424_pinctrl_driver);
}
arch_initcall(ipq5424_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -791,7 +791,6 @@ static struct platform_driver ipq5424_pinctrl_driver = {
 		.of_match_table = ipq5424_pinctrl_of_match,
 	},
 	.probe = ipq5424_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq5424_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq6018_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq6018-pinctrl", },
	{ },
};

static struct platform_driver ipq6018_pinctrl_driver = {
	.driver = {
		.name = "ipq6018-pinctrl",
		.of_match_table = ipq6018_pinctrl_of_match,
	},
	.probe = ipq6018_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq6018_pinctrl_init(void)
{
	return platform_driver_register(&ipq6018_pinctrl_driver);
}
arch_initcall(ipq6018_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1080,7 +1080,6 @@ static struct platform_driver ipq6018_pinctrl_driver = {
 		.of_match_table = ipq6018_pinctrl_of_match,
 	},
 	.probe = ipq6018_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq6018_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq8064_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq8064-pinctrl", },
	{ },
};

static struct platform_driver ipq8064_pinctrl_driver = {
	.driver = {
		.name = "ipq8064-pinctrl",
		.of_match_table = ipq8064_pinctrl_of_match,
	},
	.probe = ipq8064_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq8064_pinctrl_init(void)
{
	return platform_driver_register(&ipq8064_pinctrl_driver);
}
arch_initcall(ipq8064_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -631,7 +631,6 @@ static struct platform_driver ipq8064_pinctrl_driver = {
 		.of_match_table = ipq8064_pinctrl_of_match,
 	},
 	.probe = ipq8064_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq8064_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq8074_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq8074-pinctrl", },
	{ },
};

static struct platform_driver ipq8074_pinctrl_driver = {
	.driver = {
		.name = "ipq8074-pinctrl",
		.of_match_table = ipq8074_pinctrl_of_match,
	},
	.probe = ipq8074_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq8074_pinctrl_init(void)
{
	return platform_driver_register(&ipq8074_pinctrl_driver);
}
arch_initcall(ipq8074_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1041,7 +1041,6 @@ static struct platform_driver ipq8074_pinctrl_driver = {
 		.of_match_table = ipq8074_pinctrl_of_match,
 	},
 	.probe = ipq8074_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq8074_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id ipq9574_pinctrl_of_match[] = {
	{ .compatible = "qcom,ipq9574-tlmm", },
	{ }
};
MODULE_DEVICE_TABLE(of, ipq9574_pinctrl_of_match);

static struct platform_driver ipq9574_pinctrl_driver = {
	.driver = {
		.name = "ipq9574-tlmm",
		.of_match_table = ipq9574_pinctrl_of_match,
	},
	.probe = ipq9574_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init ipq9574_pinctrl_init(void)
{
	return platform_driver_register(&ipq9574_pinctrl_driver);
}
arch_initcall(ipq9574_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -799,7 +799,6 @@ static struct platform_driver ipq9574_pinctrl_driver = {
 		.of_match_table = ipq9574_pinctrl_of_match,
 	},
 	.probe = ipq9574_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init ipq9574_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id mdm9607_pinctrl_of_match[] = {
	{ .compatible = "qcom,mdm9607-tlmm", },
	{ }
};

static struct platform_driver mdm9607_pinctrl_driver = {
	.driver = {
		.name = "mdm9607-pinctrl",
		.of_match_table = mdm9607_pinctrl_of_match,
	},
	.probe = mdm9607_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init mdm9607_pinctrl_init(void)
{
	return platform_driver_register(&mdm9607_pinctrl_driver);
}
arch_initcall(mdm9607_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1059,7 +1059,6 @@ static struct platform_driver mdm9607_pinctrl_driver = {
 		.of_match_table = mdm9607_pinctrl_of_match,
 	},
 	.probe = mdm9607_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init mdm9607_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id mdm9615_pinctrl_of_match[] = {
	{ .compatible = "qcom,mdm9615-pinctrl", },
	{ },
};

static struct platform_driver mdm9615_pinctrl_driver = {
	.driver = {
		.name = "mdm9615-pinctrl",
		.of_match_table = mdm9615_pinctrl_of_match,
	},
	.probe = mdm9615_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init mdm9615_pinctrl_init(void)
{
	return platform_driver_register(&mdm9615_pinctrl_driver);
}
arch_initcall(mdm9615_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -446,7 +446,6 @@ static struct platform_driver mdm9615_pinctrl_driver = {
 		.of_match_table = mdm9615_pinctrl_of_match,
 	},
 	.probe = mdm9615_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init mdm9615_pinctrl_init(void)


Prompt:
Given the following original C code:
gpio_irq_chip_set_chip(girq, &msm_gpio_irq_chip);
	girq->parent_handler = msm_gpio_irq_handler;
	girq->fwnode = dev_fwnode(pctrl->dev);
	girq->num_parents = 1;
	girq->parents = devm_kcalloc(pctrl->dev, 1, sizeof(*girq->parents),
				     GFP_KERNEL);
	if (!girq->parents)
		return -ENOMEM;
	girq->default_type = IRQ_TYPE_NONE;
	girq->handler = handle_bad_irq;
	girq->parents[0] = pctrl->irq;

	ret = gpiochip_add_data(&pctrl->chip, pctrl);
	if (ret) {
		dev_err(pctrl->dev, "Failed register gpiochip\n");
		return ret;
	}

	/*
	 * For DeviceTree-supported systems, the gpio core checks the

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1442,7 +1442,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
 	girq->handler = handle_bad_irq;
 	girq->parents[0] = pctrl->irq;

-	ret = gpiochip_add_data(&pctrl->chip, pctrl);
+	ret = devm_gpiochip_add_data(pctrl->dev, &pctrl->chip, pctrl);
 	if (ret) {
 		dev_err(pctrl->dev, "Failed register gpiochip\n");
 		return ret;
@@ -1463,7 +1463,6 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
 			dev_name(pctrl->dev), 0, 0, chip->ngpio);
 		if (ret) {
 			dev_err(pctrl->dev, "Failed to add pin range\n");
-			gpiochip_remove(&pctrl->chip);
 			return ret;
 		}
 	}
@@ -1599,13 +1598,5 @@ int msm_pinctrl_probe(struct platform_device *pdev,
 }
 EXPORT_SYMBOL(msm_pinctrl_probe);

-void msm_pinctrl_remove(struct platform_device *pdev)
-{
-	struct msm_pinctrl *pctrl = platform_get_drvdata(pdev);
-
-	gpiochip_remove(&pctrl->chip);
-}
-EXPORT_SYMBOL(msm_pinctrl_remove);
-
 MODULE_DESCRIPTION("Qualcomm Technologies, Inc. TLMM driver");
 MODULE_LICENSE("GPL v2");


Prompt:
Given the following original C code:
const int *reserved_gpios;
	const struct msm_gpio_wakeirq_map *wakeirq_map;
	unsigned int nwakeirq_map;
	bool wakeirq_dual_edge_errata;
	unsigned int gpio_func;
	unsigned int egpio_func;
};

extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;

int msm_pinctrl_probe(struct platform_device *pdev,
		      const struct msm_pinctrl_soc_data *soc_data);
void msm_pinctrl_remove(struct platform_device *pdev);

#endif

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -171,6 +171,5 @@ extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;

 int msm_pinctrl_probe(struct platform_device *pdev,
 		      const struct msm_pinctrl_soc_data *soc_data);
-void msm_pinctrl_remove(struct platform_device *pdev);

 #endif


Prompt:
Given the following original C code:
static const struct of_device_id msm8226_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8226-pinctrl", },
	{ },
};

static struct platform_driver msm8226_pinctrl_driver = {
	.driver = {
		.name = "msm8226-pinctrl",
		.of_match_table = msm8226_pinctrl_of_match,
	},
	.probe = msm8226_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8226_pinctrl_init(void)
{
	return platform_driver_register(&msm8226_pinctrl_driver);
}
arch_initcall(msm8226_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -654,7 +654,6 @@ static struct platform_driver msm8226_pinctrl_driver = {
 		.of_match_table = msm8226_pinctrl_of_match,
 	},
 	.probe = msm8226_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8226_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8660_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8660-pinctrl", },
	{ },
};

static struct platform_driver msm8660_pinctrl_driver = {
	.driver = {
		.name = "msm8660-pinctrl",
		.of_match_table = msm8660_pinctrl_of_match,
	},
	.probe = msm8660_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8660_pinctrl_init(void)
{
	return platform_driver_register(&msm8660_pinctrl_driver);
}
arch_initcall(msm8660_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -981,7 +981,6 @@ static struct platform_driver msm8660_pinctrl_driver = {
 		.of_match_table = msm8660_pinctrl_of_match,
 	},
 	.probe = msm8660_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8660_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8909_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8909-tlmm", },
	{ },
};
MODULE_DEVICE_TABLE(of, msm8909_pinctrl_of_match);

static struct platform_driver msm8909_pinctrl_driver = {
	.driver = {
		.name = "msm8909-pinctrl",
		.of_match_table = msm8909_pinctrl_of_match,
	},
	.probe = msm8909_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8909_pinctrl_init(void)
{
	return platform_driver_register(&msm8909_pinctrl_driver);
}
arch_initcall(msm8909_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -929,7 +929,6 @@ static struct platform_driver msm8909_pinctrl_driver = {
 		.of_match_table = msm8909_pinctrl_of_match,
 	},
 	.probe = msm8909_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8909_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8916_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8916-pinctrl", },
	{ },
};

static struct platform_driver msm8916_pinctrl_driver = {
	.driver = {
		.name = "msm8916-pinctrl",
		.of_match_table = msm8916_pinctrl_of_match,
	},
	.probe = msm8916_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8916_pinctrl_init(void)
{
	return platform_driver_register(&msm8916_pinctrl_driver);
}
arch_initcall(msm8916_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -969,7 +969,6 @@ static struct platform_driver msm8916_pinctrl_driver = {
 		.of_match_table = msm8916_pinctrl_of_match,
 	},
 	.probe = msm8916_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8916_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8917_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8917-pinctrl", },
	{ },
};
MODULE_DEVICE_TABLE(of, msm8917_pinctrl_of_match);

static struct platform_driver msm8917_pinctrl_driver = {
	.driver = {
		.name = "msm8917-pinctrl",
		.of_match_table = msm8917_pinctrl_of_match,
	},
	.probe = msm8917_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8917_pinctrl_init(void)
{
	return platform_driver_register(&msm8917_pinctrl_driver);
}
arch_initcall(msm8917_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1607,7 +1607,6 @@ static struct platform_driver msm8917_pinctrl_driver = {
 		.of_match_table = msm8917_pinctrl_of_match,
 	},
 	.probe = msm8917_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8917_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8953_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8953-pinctrl", },
	{ },
};

static struct platform_driver msm8953_pinctrl_driver = {
	.driver = {
		.name = "msm8953-pinctrl",
		.of_match_table = msm8953_pinctrl_of_match,
	},
	.probe = msm8953_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8953_pinctrl_init(void)
{
	return platform_driver_register(&msm8953_pinctrl_driver);
}
arch_initcall(msm8953_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1816,7 +1816,6 @@ static struct platform_driver msm8953_pinctrl_driver = {
 		.of_match_table = msm8953_pinctrl_of_match,
 	},
 	.probe = msm8953_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8953_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8960_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8960-pinctrl", },
	{ },
};

static struct platform_driver msm8960_pinctrl_driver = {
	.driver = {
		.name = "msm8960-pinctrl",
		.of_match_table = msm8960_pinctrl_of_match,
	},
	.probe = msm8960_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8960_pinctrl_init(void)
{
	return platform_driver_register(&msm8960_pinctrl_driver);
}
arch_initcall(msm8960_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1246,7 +1246,6 @@ static struct platform_driver msm8960_pinctrl_driver = {
 		.of_match_table = msm8960_pinctrl_of_match,
 	},
 	.probe = msm8960_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8960_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8976_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8976-pinctrl", },
	{ },
};

static struct platform_driver msm8976_pinctrl_driver = {
	.driver = {
		.name = "msm8976-pinctrl",
		.of_match_table = msm8976_pinctrl_of_match,
	},
	.probe = msm8976_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8976_pinctrl_init(void)
{
	return platform_driver_register(&msm8976_pinctrl_driver);
}
arch_initcall(msm8976_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1096,7 +1096,6 @@ static struct platform_driver msm8976_pinctrl_driver = {
 		.of_match_table = msm8976_pinctrl_of_match,
 	},
 	.probe = msm8976_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8976_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8994_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8992-pinctrl", },
	{ .compatible = "qcom,msm8994-pinctrl", },
	{ }
};

static struct platform_driver msm8994_pinctrl_driver = {
	.driver = {
		.name = "msm8994-pinctrl",
		.of_match_table = msm8994_pinctrl_of_match,
	},
	.probe = msm8994_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8994_pinctrl_init(void)
{
	return platform_driver_register(&msm8994_pinctrl_driver);
}
arch_initcall(msm8994_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1343,7 +1343,6 @@ static struct platform_driver msm8994_pinctrl_driver = {
 		.of_match_table = msm8994_pinctrl_of_match,
 	},
 	.probe = msm8994_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8994_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8996_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8996-pinctrl", },
	{ }
};

static struct platform_driver msm8996_pinctrl_driver = {
	.driver = {
		.name = "msm8996-pinctrl",
		.of_match_table = msm8996_pinctrl_of_match,
	},
	.probe = msm8996_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8996_pinctrl_init(void)
{
	return platform_driver_register(&msm8996_pinctrl_driver);
}
arch_initcall(msm8996_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1920,7 +1920,6 @@ static struct platform_driver msm8996_pinctrl_driver = {
 		.of_match_table = msm8996_pinctrl_of_match,
 	},
 	.probe = msm8996_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8996_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8998_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8998-pinctrl", },
	{ },
};

static struct platform_driver msm8998_pinctrl_driver = {
	.driver = {
		.name = "msm8998-pinctrl",
		.of_match_table = msm8998_pinctrl_of_match,
	},
	.probe = msm8998_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8998_pinctrl_init(void)
{
	return platform_driver_register(&msm8998_pinctrl_driver);
}
arch_initcall(msm8998_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1535,7 +1535,6 @@ static struct platform_driver msm8998_pinctrl_driver = {
 		.of_match_table = msm8998_pinctrl_of_match,
 	},
 	.probe = msm8998_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8998_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id msm8x74_pinctrl_of_match[] = {
	{ .compatible = "qcom,msm8974-pinctrl", },
	{ },
};

static struct platform_driver msm8x74_pinctrl_driver = {
	.driver = {
		.name = "msm8x74-pinctrl",
		.of_match_table = msm8x74_pinctrl_of_match,
	},
	.probe = msm8x74_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init msm8x74_pinctrl_init(void)
{
	return platform_driver_register(&msm8x74_pinctrl_driver);
}
arch_initcall(msm8x74_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1083,7 +1083,6 @@ static struct platform_driver msm8x74_pinctrl_driver = {
 		.of_match_table = msm8x74_pinctrl_of_match,
 	},
 	.probe = msm8x74_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init msm8x74_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id qcm2290_pinctrl_of_match[] = {
	{ .compatible = "qcom,qcm2290-tlmm", },
	{ },
};

static struct platform_driver qcm2290_pinctrl_driver = {
	.driver = {
		.name = "qcm2290-pinctrl",
		.of_match_table = qcm2290_pinctrl_of_match,
	},
	.probe = qcm2290_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init qcm2290_pinctrl_init(void)
{
	return platform_driver_register(&qcm2290_pinctrl_driver);
}
arch_initcall(qcm2290_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1125,7 +1125,6 @@ static struct platform_driver qcm2290_pinctrl_driver = {
 		.of_match_table = qcm2290_pinctrl_of_match,
 	},
 	.probe = qcm2290_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init qcm2290_pinctrl_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id qcs404_pinctrl_of_match[] = {
	{ .compatible = "qcom,qcs404-pinctrl", },
	{ },
};

static struct platform_driver qcs404_pinctrl_driver = {
	.driver = {
		.name = "qcs404-pinctrl",
		.of_match_table = qcs404_pinctrl_of_match,
	},
	.probe = qcs404_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init qcs404_pinctrl_init(void)
{
	return platform_driver_register(&qcs404_pinctrl_driver);
}
arch_initcall(qcs404_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1644,7 +1644,6 @@ static struct platform_driver qcs404_pinctrl_driver = {
 		.of_match_table = qcs404_pinctrl_of_match,
 	},
 	.probe = qcs404_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init qcs404_pinctrl_init(void)


Prompt:
Given the following original C code:
static int qcs615_tlmm_probe(struct platform_device *pdev)
{
	return  msm_pinctrl_probe(pdev, &qcs615_tlmm);
}

static struct platform_driver qcs615_tlmm_driver = {
	.driver = {
		.name = "qcs615-tlmm",
		.of_match_table = qcs615_tlmm_of_match,
	},
	.probe = qcs615_tlmm_probe,
	.remove = msm_pinctrl_remove,
};

static int __init qcs615_tlmm_init(void)
{
	return platform_driver_register(&qcs615_tlmm_driver);
}
arch_initcall(qcs615_tlmm_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1087,7 +1087,6 @@ static struct platform_driver qcs615_tlmm_driver = {
 		.of_match_table = qcs615_tlmm_of_match,
 	},
 	.probe = qcs615_tlmm_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init qcs615_tlmm_init(void)


Prompt:
Given the following original C code:
static const struct of_device_id qcs8300_pinctrl_of_match[] = {
	{ .compatible = "qcom,qcs8300-tlmm", },
	{ },
};
MODULE_DEVICE_TABLE(of, qcs8300_pinctrl_of_match);

static struct platform_driver qcs8300_pinctrl_driver = {
	.driver = {
		.name = "qcs8300-tlmm",
		.of_match_table = qcs8300_pinctrl_of_match,
	},
	.probe = qcs8300_pinctrl_probe,
	.remove = msm_pinctrl_remove,
};

static int __init qcs8300_pinctrl_init(void)
{
	return platform_driver_register(&qcs8300_pinctrl_driver);
}
arch_initcall(qcs8300_pinctrl_init);

Instruction:
pinctrl: qcom: switch to devm_gpiochip_add_data()

Return the diff that fixes it:

Response:
@@ -1227,7 +1227,6 @@ static struct platform_driver qcs8300_pinctrl_driver = {
 		.of_match_table = qcs8300_pinctrl_of_match,
 	},
 	.probe = qcs8300_pinctrl_probe,
-	.remove = msm_pinctrl_remove,
 };

 static int __init qcs8300_pinctrl_init(void)