forked from Minki/linux
hwmon: (gpio-fan) Rename GPIO line state variables
The "ctrl" and "num_ctrl" entries in the state container struct is ambiguously named "ctrl" and "num_ctrl" overlapping with some hwmon lingo and making it hard to understand. Since this array actually contains the GPIO line numbers, from the Linux global GPIO numberspace, used to control the different fan speeds. Rename these fields to "gpios" (pluralis) and "num_gpios" so as to make it unambiguous. Convert some instances of "unsigned" to "unsigned int" to keep checkpatch happy. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
c9933cb16f
commit
e99c2e5d6c
@ -46,8 +46,8 @@ struct gpio_fan_data {
|
|||||||
/* Cooling device if any */
|
/* Cooling device if any */
|
||||||
struct thermal_cooling_device *cdev;
|
struct thermal_cooling_device *cdev;
|
||||||
struct mutex lock; /* lock GPIOs operations. */
|
struct mutex lock; /* lock GPIOs operations. */
|
||||||
int num_ctrl;
|
int num_gpios;
|
||||||
unsigned *ctrl;
|
unsigned int *gpios;
|
||||||
int num_speed;
|
int num_speed;
|
||||||
struct gpio_fan_speed *speed;
|
struct gpio_fan_speed *speed;
|
||||||
int speed_index;
|
int speed_index;
|
||||||
@ -134,8 +134,9 @@ static void __set_fan_ctrl(struct gpio_fan_data *fan_data, int ctrl_val)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < fan_data->num_ctrl; i++)
|
for (i = 0; i < fan_data->num_gpios; i++)
|
||||||
gpio_set_value_cansleep(fan_data->ctrl[i], (ctrl_val >> i) & 1);
|
gpio_set_value_cansleep(fan_data->gpios[i],
|
||||||
|
(ctrl_val >> i) & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
|
static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
|
||||||
@ -143,10 +144,10 @@ static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
|
|||||||
int i;
|
int i;
|
||||||
int ctrl_val = 0;
|
int ctrl_val = 0;
|
||||||
|
|
||||||
for (i = 0; i < fan_data->num_ctrl; i++) {
|
for (i = 0; i < fan_data->num_gpios; i++) {
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
value = gpio_get_value_cansleep(fan_data->ctrl[i]);
|
value = gpio_get_value_cansleep(fan_data->gpios[i]);
|
||||||
ctrl_val |= (value << i);
|
ctrl_val |= (value << i);
|
||||||
}
|
}
|
||||||
return ctrl_val;
|
return ctrl_val;
|
||||||
@ -331,7 +332,7 @@ static umode_t gpio_fan_is_visible(struct kobject *kobj,
|
|||||||
|
|
||||||
if (index == 0 && !data->alarm_gpio)
|
if (index == 0 && !data->alarm_gpio)
|
||||||
return 0;
|
return 0;
|
||||||
if (index > 0 && !data->ctrl)
|
if (index > 0 && !data->gpios)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return attr->mode;
|
return attr->mode;
|
||||||
@ -362,18 +363,18 @@ static const struct attribute_group *gpio_fan_groups[] = {
|
|||||||
static int fan_ctrl_init(struct gpio_fan_data *fan_data)
|
static int fan_ctrl_init(struct gpio_fan_data *fan_data)
|
||||||
{
|
{
|
||||||
struct device *dev = fan_data->dev;
|
struct device *dev = fan_data->dev;
|
||||||
int num_ctrl = fan_data->num_ctrl;
|
int num_gpios = fan_data->num_gpios;
|
||||||
unsigned int *ctrl = fan_data->ctrl;
|
unsigned int *gpios = fan_data->gpios;
|
||||||
int i, err;
|
int i, err;
|
||||||
|
|
||||||
for (i = 0; i < num_ctrl; i++) {
|
for (i = 0; i < num_gpios; i++) {
|
||||||
err = devm_gpio_request(dev, ctrl[i],
|
err = devm_gpio_request(dev, gpios[i],
|
||||||
"GPIO fan control");
|
"GPIO fan control");
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = gpio_direction_output(ctrl[i],
|
err = gpio_direction_output(gpios[i],
|
||||||
gpio_get_value_cansleep(ctrl[i]));
|
gpio_get_value_cansleep(gpios[i]));
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -436,7 +437,7 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data)
|
|||||||
struct gpio_fan_speed *speed;
|
struct gpio_fan_speed *speed;
|
||||||
struct device *dev = fan_data->dev;
|
struct device *dev = fan_data->dev;
|
||||||
struct device_node *np = dev->of_node;
|
struct device_node *np = dev->of_node;
|
||||||
unsigned *ctrl;
|
unsigned int *gpios;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
u32 u;
|
u32 u;
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
@ -455,26 +456,26 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fill GPIO pin array */
|
/* Fill GPIO pin array */
|
||||||
fan_data->num_ctrl = of_gpio_count(np);
|
fan_data->num_gpios = of_gpio_count(np);
|
||||||
if (fan_data->num_ctrl <= 0) {
|
if (fan_data->num_gpios <= 0) {
|
||||||
if (fan_data->alarm_gpio)
|
if (fan_data->alarm_gpio)
|
||||||
return 0;
|
return 0;
|
||||||
dev_err(dev, "DT properties empty / missing");
|
dev_err(dev, "DT properties empty / missing");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
ctrl = devm_kzalloc(dev, fan_data->num_ctrl * sizeof(unsigned int),
|
gpios = devm_kzalloc(dev, fan_data->num_gpios * sizeof(unsigned int),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!ctrl)
|
if (!gpios)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
for (i = 0; i < fan_data->num_ctrl; i++) {
|
for (i = 0; i < fan_data->num_gpios; i++) {
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
val = of_get_gpio(np, i);
|
val = of_get_gpio(np, i);
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
return val;
|
return val;
|
||||||
ctrl[i] = val;
|
gpios[i] = val;
|
||||||
}
|
}
|
||||||
fan_data->ctrl = ctrl;
|
fan_data->gpios = gpios;
|
||||||
|
|
||||||
/* Get number of RPM/ctrl_val pairs in speed map */
|
/* Get number of RPM/ctrl_val pairs in speed map */
|
||||||
prop = of_find_property(np, "gpio-fan,speed-map", &i);
|
prop = of_find_property(np, "gpio-fan,speed-map", &i);
|
||||||
@ -549,7 +550,7 @@ static int gpio_fan_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Configure control GPIOs if available. */
|
/* Configure control GPIOs if available. */
|
||||||
if (fan_data->ctrl && fan_data->num_ctrl > 0) {
|
if (fan_data->gpios && fan_data->num_gpios > 0) {
|
||||||
if (!fan_data->speed || fan_data->num_speed <= 1)
|
if (!fan_data->speed || fan_data->num_speed <= 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
err = fan_ctrl_init(fan_data);
|
err = fan_ctrl_init(fan_data);
|
||||||
@ -583,7 +584,7 @@ static int gpio_fan_remove(struct platform_device *pdev)
|
|||||||
if (!IS_ERR(fan_data->cdev))
|
if (!IS_ERR(fan_data->cdev))
|
||||||
thermal_cooling_device_unregister(fan_data->cdev);
|
thermal_cooling_device_unregister(fan_data->cdev);
|
||||||
|
|
||||||
if (fan_data->ctrl)
|
if (fan_data->gpios)
|
||||||
set_fan_speed(fan_data, 0);
|
set_fan_speed(fan_data, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -599,7 +600,7 @@ static int gpio_fan_suspend(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
|
struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (fan_data->ctrl) {
|
if (fan_data->gpios) {
|
||||||
fan_data->resume_speed = fan_data->speed_index;
|
fan_data->resume_speed = fan_data->speed_index;
|
||||||
set_fan_speed(fan_data, 0);
|
set_fan_speed(fan_data, 0);
|
||||||
}
|
}
|
||||||
@ -611,7 +612,7 @@ static int gpio_fan_resume(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
|
struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (fan_data->ctrl)
|
if (fan_data->gpios)
|
||||||
set_fan_speed(fan_data, fan_data->resume_speed);
|
set_fan_speed(fan_data, fan_data->resume_speed);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user