Skip to content

Commit 79e63f5

Browse files
committed
Merge tag 'gpio-v4.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "Some GPIO fixes for the v4.4 series: - Fix a bunch of possible NULL references found by Coccinelle jockeys. - Stop creating Tegra's debugfs on everything and its dog. This is an ARM multiplatform kernel issue. - Fix an oops in gpiolib for NULL names on named GPIOs. - Fix a complex OMAP1 bug in the OMAP driver" * tag 'gpio-v4.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpio: omap: drop omap1 mpuio specific irq_mask/unmask callbacks gpiolib: fix oops, if gpio name is NULL gpio-tegra: Do not create the debugfs entry by default gpio: palmas: fix a possible NULL dereference gpio: syscon: fix a possible NULL dereference gpio: 74xx: fix a possible NULL dereference
2 parents 6a24e72 + 000255b commit 79e63f5

File tree

6 files changed

+69
-55
lines changed

6 files changed

+69
-55
lines changed

drivers/gpio/gpio-74xx-mmio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,16 @@ static int mmio_74xx_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
113113

114114
static int mmio_74xx_gpio_probe(struct platform_device *pdev)
115115
{
116-
const struct of_device_id *of_id =
117-
of_match_device(mmio_74xx_gpio_ids, &pdev->dev);
116+
const struct of_device_id *of_id;
118117
struct mmio_74xx_gpio_priv *priv;
119118
struct resource *res;
120119
void __iomem *dat;
121120
int err;
122121

122+
of_id = of_match_device(mmio_74xx_gpio_ids, &pdev->dev);
123+
if (!of_id)
124+
return -ENODEV;
125+
123126
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
124127
if (!priv)
125128
return -ENOMEM;

drivers/gpio/gpio-omap.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
11221122
/* MPUIO is a bit different, reading IRQ status clears it */
11231123
if (bank->is_mpuio) {
11241124
irqc->irq_ack = dummy_irq_chip.irq_ack;
1125-
irqc->irq_mask = irq_gc_mask_set_bit;
1126-
irqc->irq_unmask = irq_gc_mask_clr_bit;
11271125
if (!bank->regs->wkup_en)
11281126
irqc->irq_set_wake = NULL;
11291127
}

drivers/gpio/gpio-palmas.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ static int palmas_gpio_probe(struct platform_device *pdev)
167167
const struct palmas_device_data *dev_data;
168168

169169
match = of_match_device(of_palmas_gpio_match, &pdev->dev);
170+
if (!match)
171+
return -ENODEV;
170172
dev_data = match->data;
171173
if (!dev_data)
172174
dev_data = &palmas_dev_data;

drivers/gpio/gpio-syscon.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,15 @@ MODULE_DEVICE_TABLE(of, syscon_gpio_ids);
187187
static int syscon_gpio_probe(struct platform_device *pdev)
188188
{
189189
struct device *dev = &pdev->dev;
190-
const struct of_device_id *of_id = of_match_device(syscon_gpio_ids, dev);
190+
const struct of_device_id *of_id;
191191
struct syscon_gpio_priv *priv;
192192
struct device_node *np = dev->of_node;
193193
int ret;
194194

195+
of_id = of_match_device(syscon_gpio_ids, dev);
196+
if (!of_id)
197+
return -ENODEV;
198+
195199
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
196200
if (!priv)
197201
return -ENOMEM;

drivers/gpio/gpio-tegra.c

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,60 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
375375
}
376376
#endif
377377

378+
#ifdef CONFIG_DEBUG_FS
379+
380+
#include <linux/debugfs.h>
381+
#include <linux/seq_file.h>
382+
383+
static int dbg_gpio_show(struct seq_file *s, void *unused)
384+
{
385+
int i;
386+
int j;
387+
388+
for (i = 0; i < tegra_gpio_bank_count; i++) {
389+
for (j = 0; j < 4; j++) {
390+
int gpio = tegra_gpio_compose(i, j, 0);
391+
seq_printf(s,
392+
"%d:%d %02x %02x %02x %02x %02x %02x %06x\n",
393+
i, j,
394+
tegra_gpio_readl(GPIO_CNF(gpio)),
395+
tegra_gpio_readl(GPIO_OE(gpio)),
396+
tegra_gpio_readl(GPIO_OUT(gpio)),
397+
tegra_gpio_readl(GPIO_IN(gpio)),
398+
tegra_gpio_readl(GPIO_INT_STA(gpio)),
399+
tegra_gpio_readl(GPIO_INT_ENB(gpio)),
400+
tegra_gpio_readl(GPIO_INT_LVL(gpio)));
401+
}
402+
}
403+
return 0;
404+
}
405+
406+
static int dbg_gpio_open(struct inode *inode, struct file *file)
407+
{
408+
return single_open(file, dbg_gpio_show, &inode->i_private);
409+
}
410+
411+
static const struct file_operations debug_fops = {
412+
.open = dbg_gpio_open,
413+
.read = seq_read,
414+
.llseek = seq_lseek,
415+
.release = single_release,
416+
};
417+
418+
static void tegra_gpio_debuginit(void)
419+
{
420+
(void) debugfs_create_file("tegra_gpio", S_IRUGO,
421+
NULL, NULL, &debug_fops);
422+
}
423+
424+
#else
425+
426+
static inline void tegra_gpio_debuginit(void)
427+
{
428+
}
429+
430+
#endif
431+
378432
static struct irq_chip tegra_gpio_irq_chip = {
379433
.name = "GPIO",
380434
.irq_ack = tegra_gpio_irq_ack,
@@ -519,6 +573,8 @@ static int tegra_gpio_probe(struct platform_device *pdev)
519573
spin_lock_init(&bank->lvl_lock[j]);
520574
}
521575

576+
tegra_gpio_debuginit();
577+
522578
return 0;
523579
}
524580

@@ -536,52 +592,3 @@ static int __init tegra_gpio_init(void)
536592
return platform_driver_register(&tegra_gpio_driver);
537593
}
538594
postcore_initcall(tegra_gpio_init);
539-
540-
#ifdef CONFIG_DEBUG_FS
541-
542-
#include <linux/debugfs.h>
543-
#include <linux/seq_file.h>
544-
545-
static int dbg_gpio_show(struct seq_file *s, void *unused)
546-
{
547-
int i;
548-
int j;
549-
550-
for (i = 0; i < tegra_gpio_bank_count; i++) {
551-
for (j = 0; j < 4; j++) {
552-
int gpio = tegra_gpio_compose(i, j, 0);
553-
seq_printf(s,
554-
"%d:%d %02x %02x %02x %02x %02x %02x %06x\n",
555-
i, j,
556-
tegra_gpio_readl(GPIO_CNF(gpio)),
557-
tegra_gpio_readl(GPIO_OE(gpio)),
558-
tegra_gpio_readl(GPIO_OUT(gpio)),
559-
tegra_gpio_readl(GPIO_IN(gpio)),
560-
tegra_gpio_readl(GPIO_INT_STA(gpio)),
561-
tegra_gpio_readl(GPIO_INT_ENB(gpio)),
562-
tegra_gpio_readl(GPIO_INT_LVL(gpio)));
563-
}
564-
}
565-
return 0;
566-
}
567-
568-
static int dbg_gpio_open(struct inode *inode, struct file *file)
569-
{
570-
return single_open(file, dbg_gpio_show, &inode->i_private);
571-
}
572-
573-
static const struct file_operations debug_fops = {
574-
.open = dbg_gpio_open,
575-
.read = seq_read,
576-
.llseek = seq_lseek,
577-
.release = single_release,
578-
};
579-
580-
static int __init tegra_gpio_debuginit(void)
581-
{
582-
(void) debugfs_create_file("tegra_gpio", S_IRUGO,
583-
NULL, NULL, &debug_fops);
584-
return 0;
585-
}
586-
late_initcall(tegra_gpio_debuginit);
587-
#endif

drivers/gpio/gpiolib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
233233
for (i = 0; i != chip->ngpio; ++i) {
234234
struct gpio_desc *gpio = &chip->desc[i];
235235

236-
if (!gpio->name)
236+
if (!gpio->name || !name)
237237
continue;
238238

239239
if (!strcmp(gpio->name, name)) {

0 commit comments

Comments
 (0)