drivers/net/wireless/intel/iwlwifi/mld/thermal.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/intel/iwlwifi/mld/thermal.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/intel/iwlwifi/mld/thermal.c
Extension
.c
Size
10950 bytes
Lines
468
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct iwl_trip_walk_data {
	__le16 *thresholds;
	int count;
};

static int iwl_trip_temp_iter(struct thermal_trip *trip, void *arg)
{
	struct iwl_trip_walk_data *twd = arg;

	if (trip->temperature == THERMAL_TEMP_INVALID)
		return 0;

	twd->thresholds[twd->count++] =
		cpu_to_le16((s16)(trip->temperature / 1000));
	return 0;
}
#endif

int iwl_mld_config_temp_report_ths(struct iwl_mld *mld)
{
	struct temp_report_ths_cmd cmd = {0};
	int ret;
#ifdef CONFIG_THERMAL
	struct iwl_trip_walk_data twd = {
		.thresholds = cmd.thresholds,
		.count = 0
	};

	if (!mld->tzone)
		goto send;

	/* The thermal core holds an array of temperature trips that are
	 * unsorted and uncompressed, the FW should get it compressed and
	 * sorted.
	 */

	/* compress trips to cmd array, remove uninitialized values*/
	for_each_thermal_trip(mld->tzone, iwl_trip_temp_iter, &twd);

	cmd.num_temps = cpu_to_le32(twd.count);
	if (twd.count)
		sort(cmd.thresholds, twd.count, sizeof(s16),
		     compare_temps, NULL);

send:
#endif
	lockdep_assert_wiphy(mld->wiphy);

	ret = iwl_mld_send_cmd_pdu(mld, WIDE_ID(PHY_OPS_GROUP,
						TEMP_REPORTING_THRESHOLDS_CMD),
				   &cmd);
	if (ret)
		IWL_ERR(mld, "TEMP_REPORT_THS_CMD command failed (err=%d)\n",
			ret);

	return ret;
}

#ifdef CONFIG_THERMAL
static int iwl_mld_tzone_get_temp(struct thermal_zone_device *device,
				  int *temperature)
{
	struct iwl_mld *mld = thermal_zone_device_priv(device);
	int temp;
	int ret = 0;

	wiphy_lock(mld->wiphy);

	if (!mld->fw_status.running) {
		/* Tell the core that there is no valid temperature value to
		 * return, but it need not worry about this.
		 */
		*temperature = THERMAL_TEMP_INVALID;
		goto unlock;
	}

	ret = iwl_mld_get_temp(mld, &temp);
	if (ret)
		goto unlock;

	*temperature = temp * 1000;
unlock:
	wiphy_unlock(mld->wiphy);
	return ret;
}

static int iwl_mld_tzone_set_trip_temp(struct thermal_zone_device *device,
				       const struct thermal_trip *trip,
				       int temp)
{

Annotation

Implementation Notes