Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'intel-gpio-v5.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel into devel

intel-gpio for v5.1-1

Small clean up for Intel PMIC GPIO drivers, includes:
- optimizing IRQ handlers by usage of for_each_set_bit()
- sorting headers alphabetically for better maintenance
- conversion to SPDX identifier

The following is an automated git shortlog grouped by driver:

crystalcove:
- Convert to use SPDX identifier
- Sort headers alphabetically
- Use for_each_set_bit() in IRQ handler

msic:
- Convert to use SPDX identifier
- Sort headers alphabetically
- Remove duplicate check in IRQ handler

wcove:
- Convert to use SPDX identifier
- Fix indentation
- Sort headers alphabetically
- Allow return negative error code from to_reg()

+29 -64
+10 -20
drivers/gpio/gpio-crystalcove.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * gpio-crystalcove.c - Intel Crystal Cove GPIO Driver 3 + * Intel Crystal Cove GPIO Driver 3 4 * 4 5 * Copyright (C) 2012, 2014 Intel Corporation. All rights reserved. 5 - * 6 - * This program is free software; you can redistribute it and/or 7 - * modify it under the terms of the GNU General Public License version 8 - * 2 as published by the Free Software Foundation. 9 - * 10 - * This program is distributed in the hope that it will be useful, 11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 - * GNU General Public License for more details. 14 6 * 15 7 * Author: Yang, Bin <bin.yang@intel.com> 16 8 */ 17 9 10 + #include <linux/bitops.h> 11 + #include <linux/gpio/driver.h> 18 12 #include <linux/interrupt.h> 13 + #include <linux/mfd/intel_soc_pmic.h> 19 14 #include <linux/module.h> 20 15 #include <linux/platform_device.h> 21 - #include <linux/gpio/driver.h> 22 - #include <linux/seq_file.h> 23 - #include <linux/bitops.h> 24 16 #include <linux/regmap.h> 25 - #include <linux/mfd/intel_soc_pmic.h> 17 + #include <linux/seq_file.h> 26 18 27 19 #define CRYSTALCOVE_GPIO_NUM 16 28 20 #define CRYSTALCOVE_VGPIO_NUM 95 ··· 271 279 static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data) 272 280 { 273 281 struct crystalcove_gpio *cg = data; 282 + unsigned long pending; 274 283 unsigned int p0, p1; 275 - int pending; 276 284 int gpio; 277 285 unsigned int virq; 278 286 ··· 285 293 286 294 pending = p0 | p1 << 8; 287 295 288 - for (gpio = 0; gpio < CRYSTALCOVE_GPIO_NUM; gpio++) { 289 - if (pending & BIT(gpio)) { 290 - virq = irq_find_mapping(cg->chip.irq.domain, gpio); 291 - handle_nested_irq(virq); 292 - } 296 + for_each_set_bit(gpio, &pending, CRYSTALCOVE_GPIO_NUM) { 297 + virq = irq_find_mapping(cg->chip.irq.domain, gpio); 298 + handle_nested_irq(virq); 293 299 } 294 300 295 301 return IRQ_HANDLED;
+9 -25
drivers/gpio/gpio-msic.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Intel Medfield MSIC GPIO driver> 3 4 * Copyright (c) 2011, Intel Corporation. 4 5 * 5 6 * Author: Mathias Nyman <mathias.nyman@linux.intel.com> 6 7 * Based on intel_pmic_gpio.c 7 - * 8 - * This program is free software; you can redistribute it and/or modify it 9 - * under the terms and conditions of the GNU General Public License, 10 - * version 2, as published by the Free Software Foundation. 11 - * 12 - * This program is distributed in the hope it will be useful, but WITHOUT 13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 - * more details. 16 - * 17 - * You should have received a copy of the GNU General Public License along with 18 - * this program; if not, write to the Free Software Foundation, Inc., 19 - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 20 - * 21 8 */ 22 9 23 - #include <linux/kernel.h> 24 - #include <linux/slab.h> 25 - #include <linux/interrupt.h> 26 - #include <linux/init.h> 27 10 #include <linux/gpio/driver.h> 28 - #include <linux/platform_device.h> 11 + #include <linux/init.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/kernel.h> 29 14 #include <linux/mfd/intel_msic.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/slab.h> 30 17 31 18 /* the offset for the mapping of global gpio pin to irq */ 32 19 #define MSIC_GPIO_IRQ_OFFSET 0x100 ··· 224 237 struct msic_gpio *mg = irq_data_get_irq_handler_data(data); 225 238 struct irq_chip *chip = irq_data_get_irq_chip(data); 226 239 struct intel_msic *msic = pdev_to_intel_msic(mg->pdev); 240 + unsigned long pending; 227 241 int i; 228 242 int bitnr; 229 243 u8 pin; 230 - unsigned long pending = 0; 231 244 232 245 for (i = 0; i < (mg->chip.ngpio / BITS_PER_BYTE); i++) { 233 246 intel_msic_irq_read(msic, INTEL_MSIC_GPIO0LVIRQ + i, &pin); 234 247 pending = pin; 235 248 236 - if (pending) { 237 - for_each_set_bit(bitnr, &pending, BITS_PER_BYTE) 238 - generic_handle_irq(mg->irq_base + 239 - (i * BITS_PER_BYTE) + bitnr); 240 - } 249 + for_each_set_bit(bitnr, &pending, BITS_PER_BYTE) 250 + generic_handle_irq(mg->irq_base + i * BITS_PER_BYTE + bitnr); 241 251 } 242 252 chip->irq_eoi(data); 243 253 }
+10 -19
drivers/gpio/gpio-wcove.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Intel Whiskey Cove PMIC GPIO Driver 3 4 * 4 5 * This driver is written based on gpio-crystalcove.c 5 6 * 6 7 * Copyright (C) 2016 Intel Corporation. All rights reserved. 7 - * 8 - * This program is free software; you can redistribute it and/or 9 - * modify it under the terms of the GNU General Public License version 10 - * 2 as published by the Free Software Foundation. 11 - * 12 - * This program is distributed in the hope that it will be useful, 13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 - * GNU General Public License for more details. 16 8 */ 17 9 18 10 #include <linux/bitops.h> 19 - #include <linux/module.h> 20 - #include <linux/interrupt.h> 21 11 #include <linux/gpio/driver.h> 12 + #include <linux/interrupt.h> 22 13 #include <linux/mfd/intel_soc_pmic.h> 14 + #include <linux/module.h> 23 15 #include <linux/platform_device.h> 24 16 #include <linux/regmap.h> 25 17 #include <linux/seq_file.h> 26 18 27 19 /* 28 20 * Whiskey Cove PMIC has 13 physical GPIO pins divided into 3 banks: 29 - * Bank 0: Pin 0 - 6 30 - * Bank 1: Pin 7 - 10 31 - * Bank 2: Pin 11 -12 21 + * Bank 0: Pin 0 - 6 22 + * Bank 1: Pin 7 - 10 23 + * Bank 2: Pin 11 - 12 32 24 * Each pin has one output control register and one input control register. 33 25 */ 34 26 #define BANK0_NR_PINS 7 ··· 67 75 #define CTLO_RVAL_50KDOWN (2 << 1) 68 76 #define CTLO_RVAL_50KUP (3 << 1) 69 77 70 - #define CTLO_INPUT_SET (CTLO_DRV_CMOS | CTLO_DRV_REN | CTLO_RVAL_2KUP) 71 - #define CTLO_OUTPUT_SET (CTLO_DIR_OUT | CTLO_INPUT_SET) 78 + #define CTLO_INPUT_SET (CTLO_DRV_CMOS | CTLO_DRV_REN | CTLO_RVAL_2KUP) 79 + #define CTLO_OUTPUT_SET (CTLO_DIR_OUT | CTLO_INPUT_SET) 72 80 73 81 enum ctrl_register { 74 82 CTRL_IN, ··· 97 105 bool set_irq_mask; 98 106 }; 99 107 100 - static inline unsigned int to_reg(int gpio, enum ctrl_register reg_type) 108 + static inline int to_reg(int gpio, enum ctrl_register reg_type) 101 109 { 102 110 unsigned int reg; 103 111 ··· 195 203 return val & 0x1; 196 204 } 197 205 198 - static void wcove_gpio_set(struct gpio_chip *chip, 199 - unsigned int gpio, int value) 206 + static void wcove_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value) 200 207 { 201 208 struct wcove_gpio *wg = gpiochip_get_data(chip); 202 209 int reg = to_reg(gpio, CTRL_OUT);