Skip to content

Commit

Permalink
gpiolib: Clean up headers
Browse files Browse the repository at this point in the history
There is a few things done:
- include only the headers we are direct user of
- when pointer is in use, provide a forward declaration
- add missing headers
- group generic headers and subsystem headers
- sort each group alphabetically

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  • Loading branch information
andy-shev authored and intel-lab-lkp committed Feb 7, 2023
1 parent 5401ddd commit 1b29af5
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 35 deletions.
10 changes: 6 additions & 4 deletions drivers/gpio/gpiolib-acpi.c
Expand Up @@ -7,17 +7,19 @@
* Mika Westerberg <mika.westerberg@linux.intel.com>
*/

#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/errno.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>
#include <linux/export.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/mutex.h>
#include <linux/pinctrl/pinctrl.h>

#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>

#include "gpiolib.h"
#include "gpiolib-acpi.h"

Expand Down
1 change: 0 additions & 1 deletion drivers/gpio/gpiolib-acpi.h
Expand Up @@ -9,7 +9,6 @@
#define GPIOLIB_ACPI_H

#include <linux/err.h>
#include <linux/errno.h>
#include <linux/types.h>

#include <linux/gpio/consumer.h>
Expand Down
6 changes: 4 additions & 2 deletions drivers/gpio/gpiolib-of.c
Expand Up @@ -10,14 +10,16 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/slab.h>
#include <linux/string.h>

#include <linux/gpio/consumer.h>
#include <linux/gpio/machine.h>

#include "gpiolib.h"
Expand Down
1 change: 0 additions & 1 deletion drivers/gpio/gpiolib-of.h
Expand Up @@ -4,7 +4,6 @@
#define GPIOLIB_OF_H

#include <linux/err.h>
#include <linux/errno.h>
#include <linux/types.h>

#include <linux/notifier.h>
Expand Down
5 changes: 3 additions & 2 deletions drivers/gpio/gpiolib-swnode.c
Expand Up @@ -6,13 +6,14 @@
*/
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/kernel.h>
#include <linux/printk.h>
#include <linux/property.h>
#include <linux/string.h>

#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>

#include "gpiolib.h"
#include "gpiolib-swnode.h"

Expand Down
21 changes: 16 additions & 5 deletions drivers/gpio/gpiolib-sysfs.c
@@ -1,18 +1,29 @@
// SPDX-License-Identifier: GPL-2.0

#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/idr.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kdev_t.h>
#include <linux/kstrtox.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/printk.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/types.h>

#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/kdev_t.h>
#include <linux/slab.h>
#include <linux/ctype.h>

#include "gpiolib.h"
#include "gpiolib-sysfs.h"

struct kernfs_node;

#define GPIO_IRQF_TRIGGER_NONE 0
#define GPIO_IRQF_TRIGGER_FALLING BIT(0)
#define GPIO_IRQF_TRIGGER_RISING BIT(1)
Expand Down
9 changes: 6 additions & 3 deletions drivers/gpio/gpiolib.c
Expand Up @@ -6,22 +6,25 @@
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/gpio.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>
#include <linux/idr.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/spinlock.h>

#include <linux/gpio.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>

#include <uapi/linux/gpio.h>

#include "gpiolib-acpi.h"
Expand Down
9 changes: 3 additions & 6 deletions include/linux/gpio.h
Expand Up @@ -12,7 +12,7 @@
#ifndef __LINUX_GPIO_H
#define __LINUX_GPIO_H

#include <linux/errno.h>
struct device;

/* see Documentation/driver-api/gpio/legacy.rst */

Expand Down Expand Up @@ -132,20 +132,17 @@ void gpio_free_array(const struct gpio *array, size_t num);

/* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */

struct device;

int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
int devm_gpio_request_one(struct device *dev, unsigned gpio,
unsigned long flags, const char *label);

#else /* ! CONFIG_GPIOLIB */

#include <linux/bug.h>
#include <linux/kernel.h>
#include <linux/types.h>

struct device;
struct gpio_chip;
#include <asm/bug.h>
#include <asm/errno.h>

static inline bool gpio_is_valid(int number)
{
Expand Down
14 changes: 10 additions & 4 deletions include/linux/gpio/consumer.h
Expand Up @@ -3,15 +3,14 @@
#define __LINUX_GPIO_CONSUMER_H

#include <linux/bits.h>
#include <linux/bug.h>
#include <linux/compiler_types.h>
#include <linux/err.h>
#include <linux/types.h>

struct acpi_device;
struct device;
struct fwnode_handle;
struct gpio_desc;

struct gpio_array;
struct gpio_desc;

/**
* struct gpio_descs - Struct containing an array of descriptors that can be
Expand Down Expand Up @@ -185,8 +184,11 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,

#else /* CONFIG_GPIOLIB */

#include <linux/err.h>
#include <linux/kernel.h>

#include <asm/bug.h>

static inline int gpiod_count(struct device *dev, const char *con_id)
{
return 0;
Expand Down Expand Up @@ -616,6 +618,8 @@ struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char

#else /* CONFIG_GPIOLIB && CONFIG_ACPI */

#include <linux/err.h>

static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
const struct acpi_gpio_mapping *gpios)
{
Expand Down Expand Up @@ -647,6 +651,8 @@ void gpiod_unexport(struct gpio_desc *desc);

#else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */

#include <asm/errno.h>

static inline int gpiod_export(struct gpio_desc *desc,
bool direction_may_change)
{
Expand Down
30 changes: 23 additions & 7 deletions include/linux/gpio/driver.h
Expand Up @@ -2,27 +2,35 @@
#ifndef __LINUX_GPIO_DRIVER_H
#define __LINUX_GPIO_DRIVER_H

#include <linux/device.h>
#include <linux/irq.h>
#include <linux/bits.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h>
#include <linux/irqhandler.h>
#include <linux/lockdep.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/property.h>
#include <linux/spinlock_types.h>
#include <linux/types.h>

#ifdef CONFIG_GENERIC_MSI_IRQ
#include <asm/msi.h>
#endif

struct gpio_desc;
struct device;
struct irq_chip;
struct irq_data;
struct module;
struct of_phandle_args;
struct pinctrl_dev;
struct seq_file;
struct gpio_device;
struct module;
enum gpiod_flags;
enum gpio_lookup_flags;

struct gpio_chip;
struct gpio_desc;
struct gpio_device;

enum gpio_lookup_flags;
enum gpiod_flags;

union gpio_irq_fwspec {
struct irq_fwspec fwspec;
Expand Down Expand Up @@ -691,6 +699,10 @@ bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gc,
int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
struct irq_domain *domain);
#else

#include <asm/bug.h>
#include <asm/errno.h>

static inline int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
struct irq_domain *domain)
{
Expand Down Expand Up @@ -768,6 +780,10 @@ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);

#else /* CONFIG_GPIOLIB */

#include <linux/err.h>

#include <asm/bug.h>

static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
{
/* GPIO can never have been requested */
Expand Down

0 comments on commit 1b29af5

Please sign in to comment.