8000 Merge tag 'gpio-v4.7-5' of git://git.kernel.org/pub/scm/linux/kernel/… · bsd-unix/linux@18b1667 · GitHub
[go: up one dir, main page]

Skip to content

Commit 18b1667

Browse files
committed
Merge tag 'gpio-v4.7-5' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "I don't like to toss in last minute patches, but these are all for things that are broken, and have bitten people for real. Two of them go into stable. Maybe all of them if the compile test problem is a pain in the ass also for stable folks. Final (hopefully) GPIO fixes for v4.7: - Fix an oops on the Asus Eee PC 1201 - Revert a patch trying to split GPIO parsing and GPIO configuration - Revert a too liberal compile testing thing" * tag 'gpio-v4.7-5' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: Revert "gpio: gpiolib-of: Allow compile testing" Revert "gpiolib: Split GPIO flags parsing and GPIO configuration" gpio: sch: Fix Oops on module load on Asus Eee PC 1201
2 parents 1d110cf + 92c74bc commit 18b1667

File tree

4 files changed

+31
-52
lines changed

4 files changed

+31
-52
lines changed

drivers/gpio/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ config GPIO_DEVRES
4949

5050
config OF_GPIO
5151
def_bool y
52-
depends on OF || COMPILE_TEST
52+
depends on OF
5353

5454
config GPIO_ACPI
5555
def_bool y

drivers/gpio/gpio-sch.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ static unsigned sch_gpio_bit(struct sch_gpio *sch, unsigned gpio)
6161
return gpio % 8;
6262
}
6363

64-
static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg)
64+
static int sch_gpio_reg_get(struct sch_gpio *sch, unsigned gpio, unsigned reg)
6565
{
66-
struct sch_gpio *sch = gpiochip_get_data(gc);
6766
unsigned short offset, bit;
6867
u8 reg_val;
6968

@@ -75,10 +74,9 @@ static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg)
7574
return reg_val;
7675
}
7776

78-
static void sch_gpio_reg_set(struct gpio_chip *gc, unsigned gpio, unsigned reg,
77+
static void sch_gpio_reg_set(struct sch_gpio *sch, unsigned gpio, unsigned reg,
7978
int val)
8079
{
81-
struct sch_gpio *sch = gpiochip_get_data(gc);
8280
unsigned short offset, bit;
8381
u8 reg_val;
8482

@@ -98,22 +96,23 @@ static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num)
9896
struct sch_gpio *sch = gpiochip_get_data(gc);
9997

10098
spin_lock(&sch->lock);
101-
sch_gpio_reg_set(gc, gpio_num, GIO, 1);
99+
sch_gpio_reg_set(sch, gpio_num, GIO, 1);
102100
spin_unlock(&sch->lock);
103101
return 0;
104102
}
105103

106104
static int sch_gpio_get(struct gpio_chip *gc, unsigned gpio_num)
107105
{
108-
return sch_gpio_reg_get(gc, gpio_num, GLV);
106+
struct sch_gpio *sch = gpiochip_get_data(gc);
107+
return sch_gpio_reg_get(sch, gpio_num, GLV);
109108
}
110109

111110
static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val)
112111
{
113112
struct sch_gpio *sch = gpiochip_get_data(gc);
114113

115114
spin_lock(&sch->lock);
116-
sch_gpio_reg_set(gc, gpio_num, GLV, val);
115+
sch_gpio_reg_set(sch, gpio_num, GLV, val);
117116
spin_unlock(&sch->lock);
118117
}
119118

@@ -123,7 +122,7 @@ static int sch_gpio_direction_out(struct gpio_chip *gc, unsigned gpio_num,
123122
struct sch_gpio *sch = gpiochip_get_data(gc);
124123

125124
spin_lock(&sch->lock);
126-
sch_gpio_reg_set(gc, gpio_num, GIO, 0);
125+
sch_gpio_reg_set(sch, gpio_num, GIO, 0);
127126
spin_unlock(&sch->lock);
128127

129128
/*
@@ -182,13 +181,13 @@ static int sch_gpio_probe(struct platform_device *pdev)
182181
* GPIO7 is configured by the CMC as SLPIOVR
183182
* Enable GPIO[9:8] core powered gpios explicitly
184183
*/
185-
sch_gpio_reg_set(&sch->chip, 8, GEN, 1);
186-
sch_gpio_reg_set(&sch->chip, 9, GEN, 1);
184+
sch_gpio_reg_set(sch, 8, GEN, 1);
185+
sch_gpio_reg_set(sch, 9, GEN, 1);
187186
/*
188187
* SUS_GPIO[2:0] enabled by default
189188
* Enable SUS_GPIO3 resume powered gpio explicitly
190189
*/
191-
sch_gpio_reg_set(&sch->chip, 13, GEN, 1);
190+
sch_gpio_reg_set(sch, 13, GEN, 1);
192191
break;
193192

194193
case PCI_DEVICE_ID_INTEL_ITC_LPC:

drivers/gpio/gpiolib-legacy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
2828
if (!desc && gpio_is_valid(gpio))
2929
return -EPROBE_DEFER;
3030

31+
err = gpiod_request(desc, label);
32+
if (err)
33+
return err;
34+
3135
if (flags & GPIOF_OPEN_DRAIN)
3236
set_bit(FLAG_OPEN_DRAIN, &desc->flags);
3337

@@ -37,10 +41,6 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
3741
if (flags & GPIOF_ACTIVE_LOW)
3842
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
3943

40-
err = gpiod_request(desc, label);
41-
if (err)
42- return err;
43-
4444
if (flags & GPIOF_DIR_IN)
4545
err = gpiod_direction_input(desc);
4646
else

drivers/gpio/gpiolib.c

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,14 +1352,6 @@ static int __gpiod_request(struct gpio_desc *desc, const char *label)
13521352
spin_lock_irqsave(&gpio_lock, flags);
13531353
}
13541354
done:
1355-
if (status < 0) {
1356-
/* Clear flags that might have been set by the caller before
1357-
* requesting the GPIO.
1358-
*/
1359-
clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
1360-
clear_bit(FLAG_OPEN_DRAIN, &desc->flags);
1361-
clear_bit(FLAG_OPEN_SOURCE, &desc->flags);
1362-
}
13631355
spin_unlock_irqrestore(&gpio_lock, flags);
13641356
return status;
13651357
}
@@ -2587,39 +2579,31 @@ struct gpio_desc *__must_check gpiod_get_optional(struct device *dev,
25872579
}
25882580
EXPORT_SYMBOL_GPL(gpiod_get_optional);
25892581

2590-
/**
2591-
* gpiod_parse_flags - helper function to parse GPIO lookup flags
2592-
* @desc: gpio to be setup
2593-
* @lflags: gpio_lookup_flags - returned from of_find_gpio() or
2594-
* of_get_gpio_hog()
2595-
*
2596-
* Set the GPIO descriptor flags based on the given GPIO lookup flags.
2597-
*/
2598-
static void gpiod_parse_flags(struct gpio_desc *desc, unsigned long lflags)
2599-
{
2600-
if (lflags & GPIO_ACTIVE_LOW)
2601-
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
2602-
if (lflags & GPIO_OPEN_DRAIN)
2603-
set_bit(FLAG_OPEN_DRAIN, &desc->flags);
2604-
if (lflags & GPIO_OPEN_SOURCE)
2605-
set_bit(FLAG_OPEN_SOURCE, &desc->flags);
2606-
}
26072582

26082583
/**
26092584
* gpiod_configure_flags - helper function to configure a given GPIO
26102585
* @desc: gpio whose value will be assigned
26112586
* @con_id: function within the GPIO consumer
2587+
* @lflags: gpio_lookup_flags - returned from of_find_gpio() or
2588+
* of_get_gpio_hog()
26122589
* @dflags: gpiod_flags - optional GPIO initialization flags
26132590
*
26142591
* Return 0 on success, -ENOENT if no GPIO has been assigned to the
26152592
* requested function and/or index, or another IS_ERR() code if an error
26162593
* occurred while trying to acquire the GPIO.
26172594
*/
26182595
static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
2619-
enum gpiod_flags dflags)
2596+
unsigned long lflags, enum gpiod_flags dflags)
26202597
{
26212598
int status;
26222599

2600+
if (lflags & GPIO_ACTIVE_LOW)
2601+
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
2602+
if (lflags & GPIO_OPEN_DRAIN)
2603+
set_bit(FLAG_OPEN_DRAIN, &desc->flags);
2604+
if (lflags & GPIO_OPEN_SOURCE)
2605+
set_bit(FLAG_OPEN_SOURCE, &desc->flags);
2606+
26232607
/* No particular flag request, return here... */
26242608
if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {
26252609
pr_debug("no flags found for %s\n", con_id);
@@ -2686,13 +2670,11 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
26862670
return desc;
26872671
}
26882672

2689-
gpiod_parse_flags(desc, lookupflags);
2690-
26912673
status = gpiod_request(desc, con_id);
26922674
if (status < 0)
26932675
return ERR_PTR(status);
26942676

2695-
status = gpiod_configure_flags(desc, con_id, flags);
2677+
status = gpiod_configure_flags(desc, con_id, lookupflags, flags);
26962678
if (status < 0) {
26972679
dev_dbg(dev, "setup of GPIO %s failed\n", con_id);
26982680
gpiod_put(desc);
@@ -2748,6 +2730,10 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
27482730
if (IS_ERR(desc))
27492731
return desc;
27502732

2733+
ret = gpiod_request(desc, NULL);
2734+
if (ret)
2735+
return ERR_PTR(ret);
2736+
27512737
if (active_low)
27522738
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
27532739

@@ -2758,10 +2744,6 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
27582744
set_bit(FLAG_OPEN_SOURCE, &desc->flags);
27592745
}
27602746

2761-
ret = gpiod_request(desc, NULL);
2762-
if (ret)
2763-
return ERR_PTR(ret);
2764-
27652747
return desc;
27662748
}
27672749
EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);
@@ -2814,8 +2796,6 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
28142796
chip = gpiod_to_chip(desc);
28152797
hwnum = gpio_chip_hwgpio(desc);
28162798

2817-
gpiod_parse_flags(desc, lflags);
2818-
28192799
local_desc = gpiochip_request_own_desc(chip, hwnum, name);
28202800
if (IS_ERR(local_desc)) {
28212801
status = PTR_ERR(local_desc);
@@ -2824,7 +2804,7 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
28242804
return status;
28252805
}
28262806

2827-
status = gpiod_configure_flags(desc, name, dflags);
2807+
status = gpiod_configure_flags(desc, name, lflags, dflags);
28282808
if (status < 0) {
28292809
pr_err("setup of hog GPIO %s (chip %s, offset %d) failed, %d\n",
28302810
name, chip->label, hwnum, status);

0 commit comments

Comments
 (0)
0