Skip to content

Misc driver core changes (constness)

Dmitry Torokhov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5kobject_hotplug() should use kobject_name()lib/kobject_uevent.c+2 -20 replies
2/5sysfs_{create|remove}_link should take const char *fs/sysfs/symlink.c include/linux/sysfs.h+9 -90 replies
3/5Make kobject's name be const char *include/linux/kobject.h lib/kobject.c lib/kobject_uevent.c+6 -60 replies
4/5kset_hotplug_ops->name shoudl return const char *drivers/base/class.c drivers/base/core.c include/linux/kobject.h+3 -30 replies
5/5make driver's name be const char *drivers/usb/core/devices.c include/linux/device.h+7 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] Misc driver core changes (constness)

Hi,

It all started when code like this:

static const char driver_name = "blah";
static struct device_driver {
.name = driver_name,
};

would give me compiler warning about removing constness because driver core has "name" fields drclared simply as "char *". I think it is a good idea to have them as "const char *" since whoever accesses them should not try to change them.

01-hotplug-use-kobject-name.patch
- kobject_hotplug should use kobject_name() instead of accessing kobj->name directly since for objects with long names it can contain garbage.

02-sysfs-link-constness.patch
- make sysfs_{create|remove}_link to take const char * name.

03-kobject-const-name.patch
- make kobject's name const char * since users should not attempt to change it (except by calling kobject_rename).

04-kset-name-const.patch
- change name() method in kset_hiotplug_ops return const char * since users shoudl not try to modify returned data.

05-driver-const-name.patch
- change driver's, bus's, class's and platform device's names to be const char * so one can use const char *drv_name = "asdfg"; when initializing structures.
Also kill couple of whitespaces.

Please consider for inclusion.

Signature · 1 line
Dmitry