Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b313398b authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Avoid mixing signed and unsigned ints in kgsl_sysfs_store"

parents 1d0274af 30a2b230
Loading
Loading
Loading
Loading
+27 −29
Original line number Diff line number Diff line
@@ -2075,15 +2075,15 @@ static ssize_t _ft_policy_store(struct device *dev,
				     const char *buf, size_t count)
{
	struct adreno_device *adreno_dev = _get_adreno_dev(dev);
	ssize_t ret;
	int ret;
	if (adreno_dev == NULL)
		return 0;

	mutex_lock(&adreno_dev->dev.mutex);
	ret = kgsl_sysfs_store(buf, count, &adreno_dev->ft_policy);
	ret = kgsl_sysfs_store(buf, &adreno_dev->ft_policy);
	mutex_unlock(&adreno_dev->dev.mutex);

	return ret;
	return ret < 0 ? ret : count;
}

/**
@@ -2132,11 +2132,11 @@ static ssize_t _ft_pagefault_policy_store(struct device *dev,
		return 0;

	mutex_lock(&adreno_dev->dev.mutex);
	/* MMU option changed call function to reset MMU options */
	if (count != kgsl_sysfs_store(buf, count, &policy))
		ret = -EINVAL;

	if (!ret) {
	ret = kgsl_sysfs_store(buf, &policy);
	if (ret)
		goto out;

	policy &= (KGSL_FT_PAGEFAULT_INT_ENABLE |
			KGSL_FT_PAGEFAULT_GPUHALT_ENABLE |
			KGSL_FT_PAGEFAULT_LOG_ONE_PER_PAGE |
@@ -2145,13 +2145,10 @@ static ssize_t _ft_pagefault_policy_store(struct device *dev,
			adreno_dev->ft_pf_policy);
	if (!ret)
		adreno_dev->ft_pf_policy = policy;
	}
	mutex_unlock(&adreno_dev->dev.mutex);

	if (!ret)
		return count;
	else
		return 0;
out:
	mutex_unlock(&adreno_dev->dev.mutex);
	return ret < 0 ? ret : count;
}

/**
@@ -2198,7 +2195,7 @@ static ssize_t _ft_fast_hang_detect_store(struct device *dev,

	tmp = adreno_dev->fast_hang_detect;

	ret = kgsl_sysfs_store(buf, count, &adreno_dev->fast_hang_detect);
	ret = kgsl_sysfs_store(buf, &adreno_dev->fast_hang_detect);

	if (tmp != adreno_dev->fast_hang_detect) {
		if (adreno_dev->fast_hang_detect) {
@@ -2214,7 +2211,7 @@ static ssize_t _ft_fast_hang_detect_store(struct device *dev,

	mutex_unlock(&adreno_dev->dev.mutex);

	return ret;
	return ret < 0 ? ret : count;

}

@@ -2257,10 +2254,10 @@ static ssize_t _ft_long_ib_detect_store(struct device *dev,
		return 0;

	mutex_lock(&adreno_dev->dev.mutex);
	ret = kgsl_sysfs_store(buf, count, &adreno_dev->long_ib_detect);
	ret = kgsl_sysfs_store(buf, &adreno_dev->long_ib_detect);
	mutex_unlock(&adreno_dev->dev.mutex);

	return ret;
	return ret < 0 ? ret : count;

}

@@ -2303,8 +2300,8 @@ static ssize_t _ft_hang_intr_status_store(struct device *dev,
	adreno_dev = ADRENO_DEVICE(device);

	mutex_lock(&device->mutex);
	ret = kgsl_sysfs_store(buf, count, &new_setting);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &new_setting);
	if (ret)
		goto done;
	if (new_setting)
		new_setting = 1;
@@ -2351,7 +2348,7 @@ static ssize_t _ft_hang_intr_status_store(struct device *dev,
	}
done:
	mutex_unlock(&device->mutex);
	return ret;
	return ret < 0 ? ret : count;
}

/**
@@ -2385,7 +2382,8 @@ static ssize_t _wake_timeout_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	return kgsl_sysfs_store(buf, count, &_wake_timeout);
	int ret = kgsl_sysfs_store(buf, &_wake_timeout);
	return ret < 0 ? ret : count;
}

/**
+2 −2
Original line number Diff line number Diff line
@@ -1673,8 +1673,8 @@ static ssize_t _store_uint(struct adreno_dispatcher *dispatcher,
	unsigned int val = 0;
	int ret;

	ret = kgsl_sysfs_store(buf, size, &val);
	if (ret != size)
	ret = kgsl_sysfs_store(buf, &val);
	if (ret)
		return ret;

	if (!val || (attr->max && (val > attr->max)))
+2 −4
Original line number Diff line number Diff line
@@ -767,11 +767,9 @@ static inline int kgsl_property_read_u32(struct kgsl_device *device,
/**
 * kgsl_sysfs_store() - parse a string from a sysfs store function
 * @buf: Incoming string to parse
 * @count: Size of the incoming string
 * @ptr: Pointer to an unsigned int to store the value
 */
static inline ssize_t kgsl_sysfs_store(const char *buf, size_t count,
		unsigned int *ptr)
static inline int kgsl_sysfs_store(const char *buf, unsigned int *ptr)
{
	unsigned int val;
	int rc;
@@ -783,6 +781,6 @@ static inline ssize_t kgsl_sysfs_store(const char *buf, size_t count,
	if (ptr)
		*ptr = val;

	return count;
	return 0;
}
#endif  /* __KGSL_DEVICE_H */
+36 −30
Original line number Diff line number Diff line
@@ -108,10 +108,12 @@ static void update_clk_statistics(struct kgsl_device *device,
 * return the nearest possible level
 */

static inline int _adjust_pwrlevel(struct kgsl_pwrctrl *pwr, int level)
static inline unsigned int _adjust_pwrlevel(struct kgsl_pwrctrl *pwr, int level)
{
	int max_pwrlevel = max_t(int, pwr->thermal_pwrlevel, pwr->max_pwrlevel);
	int min_pwrlevel = max_t(int, pwr->thermal_pwrlevel, pwr->min_pwrlevel);
	unsigned int max_pwrlevel = max_t(unsigned int, pwr->thermal_pwrlevel,
		pwr->max_pwrlevel);
	unsigned int min_pwrlevel = max_t(unsigned int, pwr->thermal_pwrlevel,
		pwr->min_pwrlevel);

	if (level < max_pwrlevel)
		return max_pwrlevel;
@@ -197,9 +199,9 @@ static ssize_t kgsl_pwrctrl_thermal_pwrlevel_store(struct device *dev,

	pwr = &device->pwrctrl;

	ret = kgsl_sysfs_store(buf, count, &level);
	ret = kgsl_sysfs_store(buf, &level);

	if (ret != count)
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
@@ -242,15 +244,16 @@ static ssize_t kgsl_pwrctrl_max_pwrlevel_store(struct device *dev,
{
	struct kgsl_device *device = kgsl_device_from_dev(dev);
	struct kgsl_pwrctrl *pwr;
	int ret, level = 0, max_level;
	int ret;
	unsigned int max_level, level = 0;

	if (device == NULL)
		return 0;

	pwr = &device->pwrctrl;

	ret = kgsl_sysfs_store(buf, count, &level);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &level);
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
@@ -262,7 +265,8 @@ static ssize_t kgsl_pwrctrl_max_pwrlevel_store(struct device *dev,
	pwr->max_pwrlevel = level;


	max_level = max_t(int, pwr->thermal_pwrlevel, pwr->max_pwrlevel);
	max_level = max_t(unsigned int, pwr->thermal_pwrlevel,
		pwr->max_pwrlevel);

	/*
	 * If there is no policy then move to max by default.  Otherwise only
@@ -285,7 +289,7 @@ static ssize_t kgsl_pwrctrl_max_pwrlevel_show(struct device *dev,
	if (device == NULL)
		return 0;
	pwr = &device->pwrctrl;
	return snprintf(buf, PAGE_SIZE, "%d\n", pwr->max_pwrlevel);
	return snprintf(buf, PAGE_SIZE, "%u\n", pwr->max_pwrlevel);
}

static ssize_t kgsl_pwrctrl_min_pwrlevel_store(struct device *dev,
@@ -293,14 +297,15 @@ static ssize_t kgsl_pwrctrl_min_pwrlevel_store(struct device *dev,
					 const char *buf, size_t count)
{	struct kgsl_device *device = kgsl_device_from_dev(dev);
	struct kgsl_pwrctrl *pwr;
	int ret, level = 0, min_level;
	int ret;
	unsigned int min_level, level = 0;

	if (device == NULL)
		return 0;

	pwr = &device->pwrctrl;

	ret = kgsl_sysfs_store(buf, count, &level);
	ret = kgsl_sysfs_store(buf, &level);
	if (ret != count)
		return ret;

@@ -314,7 +319,8 @@ static ssize_t kgsl_pwrctrl_min_pwrlevel_store(struct device *dev,

	pwr->min_pwrlevel = level;

	min_level = max_t(int, pwr->thermal_pwrlevel, pwr->min_pwrlevel);
	min_level = max_t(unsigned int, pwr->thermal_pwrlevel,
		pwr->min_pwrlevel);

	/* Only move the power level higher if minimum is higher then the
	 * current level
@@ -337,7 +343,7 @@ static ssize_t kgsl_pwrctrl_min_pwrlevel_show(struct device *dev,
	if (device == NULL)
		return 0;
	pwr = &device->pwrctrl;
	return snprintf(buf, PAGE_SIZE, "%d\n", pwr->min_pwrlevel);
	return snprintf(buf, PAGE_SIZE, "%u\n", pwr->min_pwrlevel);
}

static ssize_t kgsl_pwrctrl_num_pwrlevels_show(struct device *dev,
@@ -374,15 +380,15 @@ static ssize_t kgsl_pwrctrl_max_gpuclk_store(struct device *dev,
	struct kgsl_device *device = kgsl_device_from_dev(dev);
	struct kgsl_pwrctrl *pwr;
	unsigned int val = 0;
	int ret, level;
	int level, ret;

	if (device == NULL)
		return 0;

	pwr = &device->pwrctrl;

	ret = kgsl_sysfs_store(buf, count, &val);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &val);
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
@@ -390,7 +396,7 @@ static ssize_t kgsl_pwrctrl_max_gpuclk_store(struct device *dev,
	if (level < 0)
		goto done;

	pwr->thermal_pwrlevel = level;
	pwr->thermal_pwrlevel = (unsigned int) level;

	/*
	 * if the thermal limit is lower than the current setting,
@@ -433,14 +439,14 @@ static ssize_t kgsl_pwrctrl_gpuclk_store(struct device *dev,

	pwr = &device->pwrctrl;

	ret = kgsl_sysfs_store(buf, count, &val);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &val);
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
	level = _get_nearest_pwrlevel(pwr, val);
	if (level >= 0)
		kgsl_pwrctrl_pwrlevel_change(device, level);
		kgsl_pwrctrl_pwrlevel_change(device, (unsigned int) level);

	mutex_unlock(&device->mutex);
	return count;
@@ -470,8 +476,8 @@ static ssize_t kgsl_pwrctrl_idle_timer_store(struct device *dev,
	if (device == NULL)
		return 0;

	ret = kgsl_sysfs_store(buf, count, &val);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &val);
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
@@ -509,8 +515,8 @@ static ssize_t kgsl_pwrctrl_pmqos_latency_store(struct device *dev,
	if (device == NULL)
		return 0;

	ret = kgsl_sysfs_store(buf, count, &val);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &val);
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
@@ -653,8 +659,8 @@ static ssize_t __force_on_store(struct device *dev,
	if (device == NULL)
		return 0;

	ret = kgsl_sysfs_store(buf, count, &val);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &val);
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
@@ -728,8 +734,8 @@ static ssize_t kgsl_pwrctrl_bus_split_store(struct device *dev,
	if (device == NULL)
		return 0;

	ret = kgsl_sysfs_store(buf, count, &val);
	if (ret != count)
	ret = kgsl_sysfs_store(buf, &val);
	if (ret)
		return ret;

	mutex_lock(&device->mutex);
@@ -999,7 +1005,7 @@ EXPORT_SYMBOL(kgsl_pwrctrl_irq);
int kgsl_pwrctrl_init(struct kgsl_device *device)
{
	int i, k, m, n = 0, result = 0;
	int freq_i;
	unsigned int freq_i;
	struct clk *clk;
	struct platform_device *pdev =
		container_of(device->parentdev, struct platform_device, dev);
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ struct kgsl_pwrctrl {
	unsigned long ctrl_flags;
	struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS];
	unsigned int active_pwrlevel;
	int thermal_pwrlevel;
	unsigned int thermal_pwrlevel;
	unsigned int default_pwrlevel;
	unsigned int init_pwrlevel;
	unsigned int wakeup_maxpwrlevel;
Loading