Skip to content

Commit d90be6e

Browse files
committed
Merge tag 'driver-core-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH: "Here is the small set of driver core and kernfs changes for 6.10-rc1. Nothing major here at all, just a small set of changes for some driver core apis, and minor fixups. Included in here are: - sysfs_bin_attr_simple_read() helper added and used - device_show_string() helper added and used All usages of these were acked by the various maintainers. Also in here are: - kernfs minor cleanup - removed unused functions - typo fix in documentation - pay attention to sysfs_create_link() failures in module.c finally All of these have been in linux-next for a very long time with no reported problems" * tag 'driver-core-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: device property: Fix a typo in the description of device_get_child_node_count() kernfs: mount: Remove unnecessary ‘NULL’ values from knparent scsi: Use device_show_string() helper for sysfs attributes platform/x86: Use device_show_string() helper for sysfs attributes perf: Use device_show_string() helper for sysfs attributes IB/qib: Use device_show_string() helper for sysfs attributes hwmon: Use device_show_string() helper for sysfs attributes driver core: Add device_show_string() helper for sysfs attributes treewide: Use sysfs_bin_attr_simple_read() helper sysfs: Add sysfs_bin_attr_simple_read() helper module: don't ignore sysfs_create_link() failures driver core: Remove unused platform_notify, platform_notify_remove
2 parents be81389 + 880a746 commit d90be6e

File tree

45 files changed

+188
-422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+188
-422
lines changed

arch/powerpc/perf/hv-24x7.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,6 @@ static char *memdup_to_str(char *maybe_str, int max_len, gfp_t gfp)
425425
return kasprintf(gfp, "%.*s", max_len, maybe_str);
426426
}
427427

428-
static ssize_t device_show_string(struct device *dev,
429-
struct device_attribute *attr, char *buf)
430-
{
431-
struct dev_ext_attribute *d;
432-
433-
d = container_of(attr, struct dev_ext_attribute, attr);
434-
435-
return sprintf(buf, "%s\n", (char *)d->var);
436-
}
437-
438428
static ssize_t cpumask_show(struct device *dev,
439429
struct device_attribute *attr, char *buf)
440430
{

arch/powerpc/platforms/powernv/opal.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -792,14 +792,6 @@ static int __init opal_sysfs_init(void)
792792
return 0;
793793
}
794794

795-
static ssize_t export_attr_read(struct file *fp, struct kobject *kobj,
796-
struct bin_attribute *bin_attr, char *buf,
797-
loff_t off, size_t count)
798-
{
799-
return memory_read_from_buffer(buf, count, &off, bin_attr->private,
800-
bin_attr->size);
801-
}
802-
803795
static int opal_add_one_export(struct kobject *parent, const char *export_name,
804796
struct device_node *np, const char *prop_name)
805797
{
@@ -826,7 +818,7 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
826818
sysfs_bin_attr_init(attr);
827819
attr->attr.name = name;
828820
attr->attr.mode = 0400;
829-
attr->read = export_attr_read;
821+
attr->read = sysfs_bin_attr_simple_read;
830822
attr->private = __va(vals[0]);
831823
attr->size = vals[1];
832824

arch/x86/events/intel/core.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5645,18 +5645,11 @@ lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
56455645

56465646
static char pmu_name_str[30];
56475647

5648-
static ssize_t pmu_name_show(struct device *cdev,
5649-
struct device_attribute *attr,
5650-
char *buf)
5651-
{
5652-
return snprintf(buf, PAGE_SIZE, "%s\n", pmu_name_str);
5653-
}
5654-
5655-
static DEVICE_ATTR_RO(pmu_name);
5648+
static DEVICE_STRING_ATTR_RO(pmu_name, 0444, pmu_name_str);
56565649

56575650
static struct attribute *intel_pmu_caps_attrs[] = {
5658-
&dev_attr_pmu_name.attr,
5659-
NULL
5651+
&dev_attr_pmu_name.attr.attr,
5652+
NULL
56605653
};
56615654

56625655
static DEVICE_ATTR(allow_tsx_force_abort, 0644,

drivers/acpi/bgrt.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ BGRT_SHOW(type, image_type);
2929
BGRT_SHOW(xoffset, image_offset_x);
3030
BGRT_SHOW(yoffset, image_offset_y);
3131

32-
static ssize_t image_read(struct file *file, struct kobject *kobj,
33-
struct bin_attribute *attr, char *buf, loff_t off, size_t count)
34-
{
35-
memcpy(buf, attr->private + off, count);
36-
return count;
37-
}
38-
39-
static BIN_ATTR_RO(image, 0); /* size gets filled in later */
32+
static BIN_ATTR_SIMPLE_RO(image);
4033

4134
static struct attribute *bgrt_attributes[] = {
4235
&bgrt_attr_version.attr,

drivers/base/base.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,14 @@ extern struct kset *devices_kset;
192192
void devices_kset_move_last(struct device *dev);
193193

194194
#if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS)
195-
void module_add_driver(struct module *mod, struct device_driver *drv);
195+
int module_add_driver(struct module *mod, struct device_driver *drv);
196196
void module_remove_driver(struct device_driver *drv);
197197
#else
198-
static inline void module_add_driver(struct module *mod,
199-
struct device_driver *drv) { }
198+
static inline int module_add_driver(struct module *mod,
199+
struct device_driver *drv)
200+
{
201+
return 0;
202+
}
200203
static inline void module_remove_driver(struct device_driver *drv) { }
201204
#endif
202205

drivers/base/bus.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,12 @@ int bus_add_driver(struct device_driver *drv)
674674
if (error)
675675
goto out_del_list;
676676
}
677-
module_add_driver(drv->owner, drv);
677+
error = module_add_driver(drv->owner, drv);
678+
if (error) {
679+
printk(KERN_ERR "%s: failed to create module links for %s\n",
680+
__func__, drv->name);
681+
goto out_detach;
682+
}
678683

679684
error = driver_create_file(drv, &driver_attr_uevent);
680685
if (error) {
@@ -699,6 +704,8 @@ int bus_add_driver(struct device_driver *drv)
699704

700705
return 0;
701706

707+
out_detach:
708+
driver_detach(drv);
702709
out_del_list:
703710
klist_del(&priv->knode_bus);
704711
out_unregister:

drivers/base/core.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,8 +2346,6 @@ static void fw_devlink_link_device(struct device *dev)
23462346

23472347
/* Device links support end. */
23482348

2349-
int (*platform_notify)(struct device *dev) = NULL;
2350-
int (*platform_notify_remove)(struct device *dev) = NULL;
23512349
static struct kobject *dev_kobj;
23522350

23532351
/* /sys/dev/char */
@@ -2395,16 +2393,10 @@ static void device_platform_notify(struct device *dev)
23952393
acpi_device_notify(dev);
23962394

23972395
software_node_notify(dev);
2398-
2399-
if (platform_notify)
2400-
platform_notify(dev);
24012396
}
24022397

24032398
static void device_platform_notify_remove(struct device *dev)
24042399
{
2405-
if (platform_notify_remove)
2406-
platform_notify_remove(dev);
2407-
24082400
software_node_notify_remove(dev);
24092401

24102402
acpi_device_notify_remove(dev);
@@ -2546,6 +2538,15 @@ ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
25462538
}
25472539
EXPORT_SYMBOL_GPL(device_show_bool);
25482540

2541+
ssize_t device_show_string(struct device *dev,
2542+
struct device_attribute *attr, char *buf)
2543+
{
2544+
struct dev_ext_attribute *ea = to_ext_attr(attr);
2545+
2546+
return sysfs_emit(buf, "%s\n", (char *)ea->var);
2547+
}
2548+
EXPORT_SYMBOL_GPL(device_show_string);
2549+
25492550
/**
25502551
* device_release - free device structure.
25512552
* @kobj: device's kobject.

drivers/base/module.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ static void module_create_drivers_dir(struct module_kobject *mk)
3030
mutex_unlock(&drivers_dir_mutex);
3131
}
3232

33-
void module_add_driver(struct module *mod, struct device_driver *drv)
33+
int module_add_driver(struct module *mod, struct device_driver *drv)
3434
{
3535
char *driver_name;
36-
int no_warn;
3736
struct module_kobject *mk = NULL;
37+
int ret;
3838

3939
if (!drv)
40-
return;
40+
return 0;
4141

4242
if (mod)
4343
mk = &mod->mkobj;
@@ -56,17 +56,37 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
5656
}
5757

5858
if (!mk)
59-
return;
59+
return 0;
60+
61+
ret = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module");
62+
if (ret)
63+
return ret;
6064

61-
/* Don't check return codes; these calls are idempotent */
62-
no_warn = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module");
6365
driver_name = make_driver_name(drv);
64-
if (driver_name) {
65-
module_create_drivers_dir(mk);
66-
no_warn = sysfs_create_link(mk->drivers_dir, &drv->p->kobj,
67-
driver_name);
68-
kfree(driver_name);
66+
if (!driver_name) {
67+
ret = -ENOMEM;
68+
goto out;
69+
}
70+
71+
module_create_drivers_dir(mk);
72+
if (!mk->drivers_dir) {
73+
ret = -EINVAL;
74+
goto out;
6975
}
76+
77+
ret = sysfs_create_link(mk->drivers_dir, &drv->p->kobj, driver_name);
78+
if (ret)
79+
goto out;
80+
81+
kfree(driver_name);
82+
83+
return 0;
84+
out:
85+
sysfs_remove_link(&drv->p->kobj, "module");
86+
sysfs_remove_link(mk->drivers_dir, driver_name);
87+
kfree(driver_name);
88+
89+
return ret;
7090
}
7191

7292
void module_remove_driver(struct device_driver *drv)

drivers/base/property.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ EXPORT_SYMBOL_GPL(fwnode_device_is_available);
905905

906906
/**
907907
* device_get_child_node_count - return the number of child nodes for device
908-
* @dev: Device to cound the child nodes for
908+
* @dev: Device to count the child nodes for
909909
*
910910
* Return: the number of child nodes for a given device.
911911
*/

drivers/firmware/dmi_scan.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -761,16 +761,8 @@ static void __init dmi_scan_machine(void)
761761
pr_info("DMI not present or invalid.\n");
762762
}
763763

764-
static ssize_t raw_table_read(struct file *file, struct kobject *kobj,
765-
struct bin_attribute *attr, char *buf,
766-
loff_t pos, size_t count)
767-
{
768-
memcpy(buf, attr->private + pos, count);
769-
return count;
770-
}
771-
772-
static BIN_ATTR(smbios_entry_point, S_IRUSR, raw_table_read, NULL, 0);
773-
static BIN_ATTR(DMI, S_IRUSR, raw_table_read, NULL, 0);
764+
static BIN_ATTR_SIMPLE_ADMIN_RO(smbios_entry_point);
765+
static BIN_ATTR_SIMPLE_ADMIN_RO(DMI);
774766

775767
static int __init dmi_init(void)
776768
{

0 commit comments

Comments
 (0)