linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, jason@lakedaemon.net, andrew@lunn.ch,
	sebastian.hesselbarth@gmail.com,
	gregory.clement@free-electrons.com, linux@armlinux.org.uk,
	vivien.didelot@savoirfairelinux.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org
Subject: Re: [PATCH net-next v2 05/10] drivers: base: Add device_find_class()
Date: Thu, 12 Jan 2017 14:50:39 -0800	[thread overview]
Message-ID: <81f5965c-3484-92d9-5c04-94c5b73735d0@gmail.com> (raw)
In-Reply-To: <20170112.162135.441956368122992032.davem@davemloft.net>

On 01/12/2017 01:21 PM, David Miller wrote:
> From: Florian Fainelli <f.fainelli@gmail.com>
> Date: Wed, 11 Jan 2017 19:41:16 -0800
> 
>> 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.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>  drivers/base/core.c    | 19 +++++++++++++++++++
>>  include/linux/device.h |  1 +
>>  2 files changed, 20 insertions(+)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 020ea7f05520..3dd6047c10d8 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -2065,6 +2065,25 @@ struct device *device_find_child(struct device *parent, void *data,
>>  }
>>  EXPORT_SYMBOL_GPL(device_find_child);
>>  
>> +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,
                ^
drivers/base/core.c:2083:2: warning: passing argument 3 of
'device_find_child' from incompatible pointer type [enabled by default]
  return device_find_child(parent, class, dev_is_class);
  ^
drivers/base/core.c:2050:16: note: expected 'int (*)(struct device *,
void *)' but argument is of type 'int (*)(struct device *, const char *)'
 struct device *device_find_child(struct device *parent, void *data,
                ^

-- 
Florian

  reply	other threads:[~2017-01-12 22:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12  3:41 [PATCH net-next v2 00/10] net: dsa: Support for pdata in dsa2 Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 01/10] net: dsa: Pass device pointer to dsa_register_switch Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 02/10] net: dsa: Make most functions take a dsa_port argument Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 03/10] net: dsa: Suffix function manipulating device_node with _dn Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 04/10] net: dsa: Move ports assignment closer to error checking Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 05/10] drivers: base: Add device_find_class() Florian Fainelli
2017-01-12 21:21   ` David Miller
2017-01-12 22:50     ` Florian Fainelli [this message]
2017-01-13  4:16       ` David Miller
2017-01-13 10:55       ` David Laight
2017-01-14 19:01         ` Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 06/10] net: dsa: Migrate to device_find_class() Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 07/10] net: Relocate dev_to_net_device() into core Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 08/10] net: dsa: Add support for platform data Florian Fainelli
2017-01-13 14:04   ` Andrew Lunn
2017-01-13 22:37     ` Florian Fainelli
2017-01-14 19:12       ` Florian Fainelli
2017-01-13 14:11   ` Andrew Lunn
2017-01-13 22:39     ` Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 09/10] net: phy: Allow pre-declaration of MDIO devices Florian Fainelli
2017-01-12  3:41 ` [PATCH net-next v2 10/10] ARM: orion: Register DSA switch as a MDIO device Florian Fainelli
2017-01-13  2:34 ` [PATCH net-next v2 00/10] net: dsa: Support for pdata in dsa2 Vivien Didelot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81f5965c-3484-92d9-5c04-94c5b73735d0@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=vivien.didelot@savoirfairelinux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).