Thread (22 messages) flat view 22 messages, 5 authors, 2017-01-14

RE: [PATCH net-next v2 05/10] drivers: base: Add device_find_class()

From: David Laight <hidden>
Date: 2017-01-13 10:55:46
Also in: linux-arm-kernel, lkml

From: Florian Fainelli
Sent: 12 January 2017 22:51
On 01/12/2017 01:21 PM, David Miller wrote:
quoted
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Wed, 11 Jan 2017 19:41:16 -0800
quoted
Add a helper function to lookup a device reference given a class name.
This is a preliminary patch to remove adhoc code from net/dsa/dsa.c and
make it more generic.
...
quoted
quoted
+static int dev_is_class(struct device *dev, void *class)
I know you are just moving code, but this class argumnet is a string
and thus should be "char *" or even "const char *".
Well, this is really so that we don't need to cast the arguments passed
to device_find_child(), which takes a void *data as well. If we made
that a const char *class, we'd get warnings that look like these:

drivers/base/core.c: In function 'device_find_class':
drivers/base/core.c:2083:2: warning: passing argument 2 of
'device_find_child' discards 'const' qualifier from pointer target type
[enabled by default]
  return device_find_child(parent, class, dev_is_class);
  ^
drivers/base/core.c:2050:16: note: expected 'void *' but argument is of
type 'const char *'
 struct device *device_find_child(struct device *parent, void *data,
                ^
...

Maybe device_find_child() needs changing to take 'const void *' ?

	David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help