Commit c4142ed6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'driver-core-4.14-rc4' of...

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

Pull driver core fixes from Greg KH:
 "Here are a few small fixes for 4.14-rc4.

  The removal of DRIVER_ATTR() was almost completed by 4.14-rc1, but one
  straggler made it in through some other tree (odds are, one of
  mine...) So there's a simple removal of the last user, and then
  finally the macro is removed from the tree.

  There's a fix for old crazy udev instances that insist on reloading a
  module when it is removed from the kernel due to the new uevents for
  bind/unbind. This fixes the reported regression, hopefully some year
  in the future we can drop the workaround, once users update to the
  latest version, but I'm not holding my breath.

  And then there's a build fix for a linker warning, and a buffer
  overflow fix to match the PCI fixes you took through the PCI tree in
  the same area.

  All of these have been in linux-next for a few weeks while I've been
  traveling, sorry for the delay"

* tag 'driver-core-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  driver core: remove DRIVER_ATTR
  fpga: altera-cvp: remove DRIVER_ATTR() usage
  driver core: platform: Don't read past the end of "driver_override" buffer
  base: arch_topology: fix section mismatch build warnings
  driver core: suppress sending MODALIAS in UNBIND uevents
parents 3a98be09 850fdec8
...@@ -196,12 +196,13 @@ struct driver_attribute { ...@@ -196,12 +196,13 @@ struct driver_attribute {
}; };
Device drivers can export attributes via their sysfs directories. Device drivers can export attributes via their sysfs directories.
Drivers can declare attributes using a DRIVER_ATTR macro that works Drivers can declare attributes using a DRIVER_ATTR_RW and DRIVER_ATTR_RO
identically to the DEVICE_ATTR macro. macro that works identically to the DEVICE_ATTR_RW and DEVICE_ATTR_RO
macros.
Example: Example:
DRIVER_ATTR(debug,0644,show_debug,store_debug); DRIVER_ATTR_RW(debug);
This is equivalent to declaring: This is equivalent to declaring:
......
...@@ -366,7 +366,8 @@ struct driver_attribute { ...@@ -366,7 +366,8 @@ struct driver_attribute {
Declaring: Declaring:
DRIVER_ATTR(_name, _mode, _show, _store) DRIVER_ATTR_RO(_name)
DRIVER_ATTR_RW(_name)
Creation/Removal: Creation/Removal:
......
...@@ -166,11 +166,11 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) ...@@ -166,11 +166,11 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
} }
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
static cpumask_var_t cpus_to_visit; static cpumask_var_t cpus_to_visit __initdata;
static void parsing_done_workfn(struct work_struct *work); static void __init parsing_done_workfn(struct work_struct *work);
static DECLARE_WORK(parsing_done_work, parsing_done_workfn); static __initdata DECLARE_WORK(parsing_done_work, parsing_done_workfn);
static int static int __init
init_cpu_capacity_callback(struct notifier_block *nb, init_cpu_capacity_callback(struct notifier_block *nb,
unsigned long val, unsigned long val,
void *data) void *data)
...@@ -206,7 +206,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, ...@@ -206,7 +206,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
return 0; return 0;
} }
static struct notifier_block init_cpu_capacity_notifier = { static struct notifier_block init_cpu_capacity_notifier __initdata = {
.notifier_call = init_cpu_capacity_callback, .notifier_call = init_cpu_capacity_callback,
}; };
...@@ -232,7 +232,7 @@ static int __init register_cpufreq_notifier(void) ...@@ -232,7 +232,7 @@ static int __init register_cpufreq_notifier(void)
} }
core_initcall(register_cpufreq_notifier); core_initcall(register_cpufreq_notifier);
static void parsing_done_workfn(struct work_struct *work) static void __init parsing_done_workfn(struct work_struct *work)
{ {
cpufreq_unregister_notifier(&init_cpu_capacity_notifier, cpufreq_unregister_notifier(&init_cpu_capacity_notifier,
CPUFREQ_POLICY_NOTIFIER); CPUFREQ_POLICY_NOTIFIER);
......
...@@ -868,7 +868,8 @@ static ssize_t driver_override_store(struct device *dev, ...@@ -868,7 +868,8 @@ static ssize_t driver_override_store(struct device *dev,
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
char *driver_override, *old, *cp; char *driver_override, *old, *cp;
if (count > PATH_MAX) /* We need to keep extra room for a newline */
if (count >= (PAGE_SIZE - 1))
return -EINVAL; return -EINVAL;
driver_override = kstrndup(buf, count, GFP_KERNEL); driver_override = kstrndup(buf, count, GFP_KERNEL);
......
...@@ -361,12 +361,12 @@ static const struct fpga_manager_ops altera_cvp_ops = { ...@@ -361,12 +361,12 @@ static const struct fpga_manager_ops altera_cvp_ops = {
.write_complete = altera_cvp_write_complete, .write_complete = altera_cvp_write_complete,
}; };
static ssize_t show_chkcfg(struct device_driver *dev, char *buf) static ssize_t chkcfg_show(struct device_driver *dev, char *buf)
{ {
return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg); return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg);
} }
static ssize_t store_chkcfg(struct device_driver *drv, const char *buf, static ssize_t chkcfg_store(struct device_driver *drv, const char *buf,
size_t count) size_t count)
{ {
int ret; int ret;
...@@ -378,7 +378,7 @@ static ssize_t store_chkcfg(struct device_driver *drv, const char *buf, ...@@ -378,7 +378,7 @@ static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
return count; return count;
} }
static DRIVER_ATTR(chkcfg, 0600, show_chkcfg, store_chkcfg); static DRIVER_ATTR_RW(chkcfg);
static int altera_cvp_probe(struct pci_dev *pdev, static int altera_cvp_probe(struct pci_dev *pdev,
const struct pci_device_id *dev_id); const struct pci_device_id *dev_id);
......
...@@ -307,8 +307,6 @@ struct driver_attribute { ...@@ -307,8 +307,6 @@ struct driver_attribute {
size_t count); size_t count);
}; };
#define DRIVER_ATTR(_name, _mode, _show, _store) \
struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
#define DRIVER_ATTR_RW(_name) \ #define DRIVER_ATTR_RW(_name) \
struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
#define DRIVER_ATTR_RO(_name) \ #define DRIVER_ATTR_RO(_name) \
......
...@@ -294,6 +294,26 @@ static void cleanup_uevent_env(struct subprocess_info *info) ...@@ -294,6 +294,26 @@ static void cleanup_uevent_env(struct subprocess_info *info)
} }
#endif #endif
static void zap_modalias_env(struct kobj_uevent_env *env)
{
static const char modalias_prefix[] = "MODALIAS=";
int i;
for (i = 0; i < env->envp_idx;) {
if (strncmp(env->envp[i], modalias_prefix,
sizeof(modalias_prefix) - 1)) {
i++;
continue;
}
if (i != env->envp_idx - 1)
memmove(&env->envp[i], &env->envp[i + 1],
sizeof(env->envp[i]) * env->envp_idx - 1);
env->envp_idx--;
}
}
/** /**
* kobject_uevent_env - send an uevent with environmental data * kobject_uevent_env - send an uevent with environmental data
* *
...@@ -409,16 +429,29 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, ...@@ -409,16 +429,29 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
} }
} }
switch (action) {
case KOBJ_ADD:
/* /*
* Mark "add" and "remove" events in the object to ensure proper * Mark "add" event so we can make sure we deliver "remove"
* events to userspace during automatic cleanup. If the object did * event to userspace during automatic cleanup. If
* send an "add" event, "remove" will automatically generated by * the object did send an "add" event, "remove" will
* the core, if not already done by the caller. * automatically generated by the core, if not already done
* by the caller.
*/ */
if (action == KOBJ_ADD)
kobj->state_add_uevent_sent = 1; kobj->state_add_uevent_sent = 1;
else if (action == KOBJ_REMOVE) break;
case KOBJ_REMOVE:
kobj->state_remove_uevent_sent = 1; kobj->state_remove_uevent_sent = 1;
break;
case KOBJ_UNBIND:
zap_modalias_env(env);
break;
default:
break;
}
mutex_lock(&uevent_sock_mutex); mutex_lock(&uevent_sock_mutex);
/* we will send an event, so request a new sequence number */ /* we will send an event, so request a new sequence number */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment