Эх сурвалжийг харах

Merge tag 'driver-core-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core fixes from Greg KH:
 "Here are a small number of debugfs, ISA, and one driver core fix for
  4.7-rc4.

  All of these resolve reported issues.  The ISA ones have spent the
  least amount of time in linux-next, sorry about that, I didn't realize
  they were regressions that needed to get in now (thanks to Thorsten
  for the prodding!) but they do all pass the 0-day bot tests.  The
  others have been in linux-next for a while now.

  Full details about them are in the shortlog below"

* tag 'driver-core-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  isa: Dummy isa_register_driver should return error code
  isa: Call isa_bus_init before dependent ISA bus drivers register
  watchdog: ebc-c384_wdt: Allow build for X86_64
  iio: stx104: Allow build for X86_64
  gpio: Allow PC/104 devices on X86_64
  isa: Allow ISA-style drivers on modern systems
  base: make module_create_drivers_dir race-free
  debugfs: open_proxy_open(): avoid double fops release
  debugfs: full_proxy_open(): free proxy on ->open() failure
  kernel/kcov: unproxify debugfs file's fops
Linus Torvalds 9 жил өмнө
parent
commit
607117a153

+ 3 - 0
arch/Kconfig

@@ -606,6 +606,9 @@ config HAVE_ARCH_HASH
 	  file which provides platform-specific implementations of some
 	  file which provides platform-specific implementations of some
 	  functions in <linux/hash.h> or fs/namei.c.
 	  functions in <linux/hash.h> or fs/namei.c.
 
 
+config ISA_BUS_API
+	def_bool ISA
+
 #
 #
 # ABI hall of shame
 # ABI hall of shame
 #
 #

+ 9 - 0
arch/x86/Kconfig

@@ -2439,6 +2439,15 @@ config PCI_CNB20LE_QUIRK
 
 
 source "drivers/pci/Kconfig"
 source "drivers/pci/Kconfig"
 
 
+config ISA_BUS
+	bool "ISA-style bus support on modern systems" if EXPERT
+	select ISA_BUS_API
+	help
+	  Enables ISA-style drivers on modern systems. This is necessary to
+	  support PC/104 devices on X86_64 platforms.
+
+	  If unsure, say N.
+
 # x86_64 have no ISA slots, but can have ISA-style DMA.
 # x86_64 have no ISA slots, but can have ISA-style DMA.
 config ISA_DMA_API
 config ISA_DMA_API
 	bool "ISA-style DMA support" if (X86_64 && EXPERT)
 	bool "ISA-style DMA support" if (X86_64 && EXPERT)

+ 1 - 1
drivers/base/Makefile

@@ -10,7 +10,7 @@ obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
 obj-y			+= power/
 obj-y			+= power/
 obj-$(CONFIG_HAS_DMA)	+= dma-mapping.o
 obj-$(CONFIG_HAS_DMA)	+= dma-mapping.o
 obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
 obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
-obj-$(CONFIG_ISA)	+= isa.o
+obj-$(CONFIG_ISA_BUS_API)	+= isa.o
 obj-$(CONFIG_FW_LOADER)	+= firmware_class.o
 obj-$(CONFIG_FW_LOADER)	+= firmware_class.o
 obj-$(CONFIG_NUMA)	+= node.o
 obj-$(CONFIG_NUMA)	+= node.o
 obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o
 obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o

+ 1 - 1
drivers/base/isa.c

@@ -180,4 +180,4 @@ static int __init isa_bus_init(void)
 	return error;
 	return error;
 }
 }
 
 
-device_initcall(isa_bus_init);
+postcore_initcall(isa_bus_init);

+ 5 - 3
drivers/base/module.c

@@ -24,10 +24,12 @@ static char *make_driver_name(struct device_driver *drv)
 
 
 static void module_create_drivers_dir(struct module_kobject *mk)
 static void module_create_drivers_dir(struct module_kobject *mk)
 {
 {
-	if (!mk || mk->drivers_dir)
-		return;
+	static DEFINE_MUTEX(drivers_dir_mutex);
 
 
-	mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj);
+	mutex_lock(&drivers_dir_mutex);
+	if (mk && !mk->drivers_dir)
+		mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj);
+	mutex_unlock(&drivers_dir_mutex);
 }
 }
 
 
 void module_add_driver(struct module *mod, struct device_driver *drv)
 void module_add_driver(struct module *mod, struct device_driver *drv)

+ 4 - 4
drivers/gpio/Kconfig

@@ -531,7 +531,7 @@ menu "Port-mapped I/O GPIO drivers"
 
 
 config GPIO_104_DIO_48E
 config GPIO_104_DIO_48E
 	tristate "ACCES 104-DIO-48E GPIO support"
 	tristate "ACCES 104-DIO-48E GPIO support"
-	depends on ISA
+	depends on ISA_BUS_API
 	select GPIOLIB_IRQCHIP
 	select GPIOLIB_IRQCHIP
 	help
 	help
 	  Enables GPIO support for the ACCES 104-DIO-48E series (104-DIO-48E,
 	  Enables GPIO support for the ACCES 104-DIO-48E series (104-DIO-48E,
@@ -541,7 +541,7 @@ config GPIO_104_DIO_48E
 
 
 config GPIO_104_IDIO_16
 config GPIO_104_IDIO_16
 	tristate "ACCES 104-IDIO-16 GPIO support"
 	tristate "ACCES 104-IDIO-16 GPIO support"
-	depends on ISA
+	depends on ISA_BUS_API
 	select GPIOLIB_IRQCHIP
 	select GPIOLIB_IRQCHIP
 	help
 	help
 	  Enables GPIO support for the ACCES 104-IDIO-16 family (104-IDIO-16,
 	  Enables GPIO support for the ACCES 104-IDIO-16 family (104-IDIO-16,
@@ -552,7 +552,7 @@ config GPIO_104_IDIO_16
 
 
 config GPIO_104_IDI_48
 config GPIO_104_IDI_48
 	tristate "ACCES 104-IDI-48 GPIO support"
 	tristate "ACCES 104-IDI-48 GPIO support"
-	depends on ISA
+	depends on ISA_BUS_API
 	select GPIOLIB_IRQCHIP
 	select GPIOLIB_IRQCHIP
 	help
 	help
 	  Enables GPIO support for the ACCES 104-IDI-48 family (104-IDI-48A,
 	  Enables GPIO support for the ACCES 104-IDI-48 family (104-IDI-48A,
@@ -628,7 +628,7 @@ config GPIO_TS5500
 
 
 config GPIO_WS16C48
 config GPIO_WS16C48
 	tristate "WinSystems WS16C48 GPIO support"
 	tristate "WinSystems WS16C48 GPIO support"
-	depends on ISA
+	depends on ISA_BUS_API
 	select GPIOLIB_IRQCHIP
 	select GPIOLIB_IRQCHIP
 	help
 	help
 	  Enables GPIO support for the WinSystems WS16C48. The base port
 	  Enables GPIO support for the WinSystems WS16C48. The base port

+ 1 - 1
drivers/iio/dac/Kconfig

@@ -247,7 +247,7 @@ config MCP4922
 
 
 config STX104
 config STX104
 	tristate "Apex Embedded Systems STX104 DAC driver"
 	tristate "Apex Embedded Systems STX104 DAC driver"
-	depends on X86 && ISA
+	depends on X86 && ISA_BUS_API
 	help
 	help
 	  Say yes here to build support for the 2-channel DAC on the Apex
 	  Say yes here to build support for the 2-channel DAC on the Apex
 	  Embedded Systems STX104 integrated analog PC/104 card. The base port
 	  Embedded Systems STX104 integrated analog PC/104 card. The base port

+ 1 - 1
drivers/watchdog/Kconfig

@@ -746,7 +746,7 @@ config ALIM7101_WDT
 
 
 config EBC_C384_WDT
 config EBC_C384_WDT
 	tristate "WinSystems EBC-C384 Watchdog Timer"
 	tristate "WinSystems EBC-C384 Watchdog Timer"
-	depends on X86 && ISA
+	depends on X86 && ISA_BUS_API
 	select WATCHDOG_CORE
 	select WATCHDOG_CORE
 	help
 	help
 	  Enables watchdog timer support for the watchdog timer on the
 	  Enables watchdog timer support for the watchdog timer on the

+ 4 - 3
fs/debugfs/file.c

@@ -127,7 +127,6 @@ static int open_proxy_open(struct inode *inode, struct file *filp)
 		r = real_fops->open(inode, filp);
 		r = real_fops->open(inode, filp);
 
 
 out:
 out:
-	fops_put(real_fops);
 	debugfs_use_file_finish(srcu_idx);
 	debugfs_use_file_finish(srcu_idx);
 	return r;
 	return r;
 }
 }
@@ -262,8 +261,10 @@ static int full_proxy_open(struct inode *inode, struct file *filp)
 
 
 	if (real_fops->open) {
 	if (real_fops->open) {
 		r = real_fops->open(inode, filp);
 		r = real_fops->open(inode, filp);
-
-		if (filp->f_op != proxy_fops) {
+		if (r) {
+			replace_fops(filp, d_inode(dentry)->i_fop);
+			goto free_proxy;
+		} else if (filp->f_op != proxy_fops) {
 			/* No protection against file removal anymore. */
 			/* No protection against file removal anymore. */
 			WARN(1, "debugfs file owner replaced proxy fops: %pd",
 			WARN(1, "debugfs file owner replaced proxy fops: %pd",
 				dentry);
 				dentry);

+ 3 - 2
include/linux/isa.h

@@ -6,6 +6,7 @@
 #define __LINUX_ISA_H
 #define __LINUX_ISA_H
 
 
 #include <linux/device.h>
 #include <linux/device.h>
+#include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/kernel.h>
 
 
 struct isa_driver {
 struct isa_driver {
@@ -22,13 +23,13 @@ struct isa_driver {
 
 
 #define to_isa_driver(x) container_of((x), struct isa_driver, driver)
 #define to_isa_driver(x) container_of((x), struct isa_driver, driver)
 
 
-#ifdef CONFIG_ISA
+#ifdef CONFIG_ISA_BUS_API
 int isa_register_driver(struct isa_driver *, unsigned int);
 int isa_register_driver(struct isa_driver *, unsigned int);
 void isa_unregister_driver(struct isa_driver *);
 void isa_unregister_driver(struct isa_driver *);
 #else
 #else
 static inline int isa_register_driver(struct isa_driver *d, unsigned int i)
 static inline int isa_register_driver(struct isa_driver *d, unsigned int i)
 {
 {
-	return 0;
+	return -ENODEV;
 }
 }
 
 
 static inline void isa_unregister_driver(struct isa_driver *d)
 static inline void isa_unregister_driver(struct isa_driver *d)

+ 6 - 1
kernel/kcov.c

@@ -264,7 +264,12 @@ static const struct file_operations kcov_fops = {
 
 
 static int __init kcov_init(void)
 static int __init kcov_init(void)
 {
 {
-	if (!debugfs_create_file("kcov", 0600, NULL, NULL, &kcov_fops)) {
+	/*
+	 * The kcov debugfs file won't ever get removed and thus,
+	 * there is no need to protect it against removal races. The
+	 * use of debugfs_create_file_unsafe() is actually safe here.
+	 */
+	if (!debugfs_create_file_unsafe("kcov", 0600, NULL, NULL, &kcov_fops)) {
 		pr_err("failed to create kcov in debugfs\n");
 		pr_err("failed to create kcov in debugfs\n");
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}