lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <373d3620-fa60-8306-1119-22d197d6ba93@arm.com>
Date:   Tue, 4 Jun 2019 09:36:08 +0100
From:   Suzuki K Poulose <suzuki.poulose@....com>
To:     gregkh@...uxfoundation.org
Cc:     linux-kernel@...r.kernel.org, rafael@...nel.org
Subject: Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()



On 03/06/2019 20:11, Greg KH wrote:
> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
>> Add a wrappers to lookup a device by name for a given driver, by various
>> generic properties of a device. This can avoid the proliferation of custom
>> match functions throughout the drivers.
>>
>> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@...nel.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@....com>
>> ---
>>   include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 44 insertions(+)
>>
>> diff --git a/include/linux/device.h b/include/linux/device.h
>> index 52d59d5..68d6e04 100644
>> --- a/include/linux/device.h
>> +++ b/include/linux/device.h
>> @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv,
>>   				  struct device *start, void *data,
>>   				  int (*match)(struct device *dev, const void *data));
>>   
>> +/**
>> + * driver_find_device_by_name - device iterator for locating a particular device
>> + * of a specific name.
>> + * @driver: the driver we're iterating
>> + * @start: Device to begin with
>> + * @name: name of the device to match
>> + */
>> +static inline struct device *driver_find_device_by_name(struct device_driver *drv,
>> +							struct device *start,
>> +							const char *name)
>> +{
>> +	return driver_find_device(drv, start, (void *)name, device_match_name);
> 
> Why is the cast needed?
> 
>> +}
>> +
>> +/**
>> + * driver_find_device_by_of_node- device iterator for locating a particular device
>> + * by of_node pointer.
>> + * @driver: the driver we're iterating
>> + * @start: Device to begin with
>> + * @np: of_node pointer to match.
>> + */
>> +static inline struct device *
>> +driver_find_device_by_of_node(struct device_driver *drv,
>> +			      struct device *start,
>> +			      const struct device_node *np)
>> +{
>> +	return driver_find_device(drv, start, (void *)np, device_match_of_node);
> 
> Same here.
> 
>> +}
>> +
>> +/**
>> + * driver_find_device_by_fwnode- device iterator for locating a particular device
>> + * by fwnode pointer.
>> + * @driver: the driver we're iterating
>> + * @start: Device to begin with
>> + * @fwnode: fwnode pointer to match.
>> + */
>> +static inline struct device *
>> +driver_find_device_by_fwnode(struct device_driver *drv,
>> +			     struct device *start,
>> +			     const struct fwnode_handle *fwnode)
>> +{
>> +	return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode);
> 
> And here

Because the driver_find_device() expects a "void *" and not a "const void *".
May be we could promote that to "const void *" in the core API too, since we
have converted the "match" to const void * already. Thoughts ?

Suzuki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ