public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/6] Driver core: Encourage use of const attributes
@ 2009-12-17 18:12 Phil Carmody
  2009-12-17 18:12 ` [RFC 1/6] Driver core: device_attribute parameters can often be const* Phil Carmody
  2009-12-17 23:16 ` [RFC 0/6] Driver core: Encourage use of const attributes Greg KH
  0 siblings, 2 replies; 16+ messages in thread
From: Phil Carmody @ 2009-12-17 18:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel

I know now's probably a bad time to be mentioning const issues
but I recently a reviewed a patch where 'const' was being removed 
from a device_attribute structure, and I enquired why. The reason
was simply so that device_create_file() could be called, it taking
a non-const attribute pointer. Looking inside, all that function 
did was pass a pointer to sysfs_create_file, which itself took a
const pointer. Non-constness was not required at all.

So here I offer a small patchset which I hope will permit and 
encourage device and other attributes to be made const, and put 
in read-only sections.

1-3 address the three attribute types which seemed to be trivially 
const-able, and are the important part of the set.

4 adds a new macro to encourage the use of Const ATTRibutes,
and may need a better name. (I wanted to avoid RO, for example.)

5 and 6 are merely two quick examples of how easy it is to adopt 
the new const convention. In reality, these structures have been
constant and treated as constant by the driver core all along, it's
just that one word was missing from a few important places.

I would hope to submit a patchset with 1-3 and a possibly modified 
4. The migrations themselves will belong in different trees.

These have been compile/sparse tested against arm and x86_64 targets, 
and through my usual suite of tests on the arm platform I use.

Regards,
Phil

Phil Carmody (6):
  Driver core: device_attribute parameters can often be const*
  Driver core: bin_attribute parameters can often be const*
  Driver core: driver_attribute parameters can often be const*
  Driver core: Easy macros to encourage const attributes
  PM: Example of how easy it is to mark attributes const
  gpio: Example of how easy it is to mark attributes const

 drivers/base/core.c      |   12 ++++++++----
 drivers/base/driver.c    |    4 ++--
 drivers/gpio/gpiolib.c   |   12 ++++++------
 drivers/regulator/core.c |   38 +++++++++++++++++++-------------------
 fs/sysfs/bin.c           |    6 ++++--
 include/linux/device.h   |   20 ++++++++++++++------
 include/linux/sysfs.h    |    9 +++++----
 7 files changed, 58 insertions(+), 43 deletions(-)


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-12-18 17:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-17 18:12 [RFC 0/6] Driver core: Encourage use of const attributes Phil Carmody
2009-12-17 18:12 ` [RFC 1/6] Driver core: device_attribute parameters can often be const* Phil Carmody
2009-12-17 18:12   ` [RFC 2/6] Driver core: bin_attribute " Phil Carmody
2009-12-17 18:12     ` [RFC 3/6] Driver core: driver_attribute " Phil Carmody
2009-12-17 18:12       ` [RFC 4/6] Driver core: Easy macros to encourage const attributes Phil Carmody
2009-12-17 18:12         ` [RFC 5/6] PM: Example of how easy it is to mark attributes const Phil Carmody
2009-12-17 18:12           ` [RFC 6/6] gpio: " Phil Carmody
2009-12-17 23:16 ` [RFC 0/6] Driver core: Encourage use of const attributes Greg KH
2009-12-18  0:42   ` Stephen Rothwell
2009-12-18  4:20     ` Greg KH
2009-12-18 13:34       ` [PATCH 0/3] " Phil Carmody
2009-12-18 13:34         ` [PATCH 1/3] Driver core: device_attribute parameters can often be const* Phil Carmody
2009-12-18 13:34           ` [PATCH 2/3] Driver core: bin_attribute " Phil Carmody
2009-12-18 13:34             ` [PATCH 3/3] Driver core: driver_attribute " Phil Carmody
2009-12-18  8:52   ` [RFC 0/6] Driver core: Encourage use of const attributes Phil Carmody
2009-12-18 16:10     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox