mbox series

[v3,0/5] device property: Consitify a few APIs and

Message ID 20221004092129.19412-1-andriy.shevchenko@linux.intel.com
Headers show
Series device property: Consitify a few APIs and | expand

Message

Andy Shevchenko Oct. 4, 2022, 9:21 a.m. UTC
The property.h has inconsistency in how we annotate the parameters which
are not modified anyhow by the certain APIs. Also dev_fwnode() needs to
be rectified in sense of the handling const qualifier.

This series improves the above with only a couple of APIs left for now
untouched (PHY, which I believe doesn't belong to property.h to begin
with).

Changelog v3:
- used _Generic() to hide the _const API (Sakari, Greg)

Changelog v2:
- fixed USB Type-C compilation issues (LKP)
- added tags (Sakari, Heikki)

Andy Shevchenko (5):
  device property: Allow const parameter to dev_fwnode()
  device property: Constify fwnode connection match APIs
  device property: Constify parameter in fwnode_graph_is_endpoint()
  device property: Constify device child node APIs
  device property: Constify parameter in device_dma_supported() and
    device_get_dma_attr()

 drivers/base/property.c     | 29 ++++++++++++++++++-----------
 drivers/usb/roles/class.c   |  2 +-
 drivers/usb/typec/mux.c     |  8 ++++----
 drivers/usb/typec/retimer.c |  2 +-
 include/linux/property.h    | 34 +++++++++++++++++++---------------
 5 files changed, 43 insertions(+), 32 deletions(-)

Comments

Andy Shevchenko Oct. 4, 2022, 9:34 a.m. UTC | #1
On Tue, Oct 04, 2022 at 12:21:25PM +0300, Andy Shevchenko wrote:
> It's not fully correct to take a const parameter pointer to a struct
> and return a non-const pointer to a member of that struct.
> 
> Instead, introduce a const version of the dev_fwnode() API which takes
> and returns const pointers and use it where it's applicable.
> 
> With this, convert dev_fwnode() to be a macro wrapper on top of const
> and non-const APIs that chooses one based on the type.

Hmm... it missed the device_get_match_data() implementation (reverse) change
somehow. And it still compiles to me, probably I rebased wrongly and the hunk
went to another patch. I'll investigate and resend as v4 the fixed version.
Greg Kroah-Hartman Oct. 22, 2022, 11:50 a.m. UTC | #2
On Tue, Oct 04, 2022 at 02:11:10PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Oct 04, 2022 at 12:21:24PM +0300, Andy Shevchenko wrote:
> > The property.h has inconsistency in how we annotate the parameters which
> > are not modified anyhow by the certain APIs. Also dev_fwnode() needs to
> > be rectified in sense of the handling const qualifier.
> > 
> > This series improves the above with only a couple of APIs left for now
> > untouched (PHY, which I believe doesn't belong to property.h to begin
> > with).
> 
> Looks sane at first glance.  I'll look at it some more once 6.1-rc1 is
> out, thanks.

All now applied, thanks.,

greg k-h