All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Nowak <lnowak.tyco@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH udev 01/15] udevng: simplify logic in check_usb_device
Date: Mon, 27 Mar 2017 10:00:24 +0100	[thread overview]
Message-ID: <0dc9a746-3586-11bc-6bde-932b5e563451@gmail.com> (raw)
In-Reply-To: <20170325165805.28166-2-jonas@southpole.se>

[-- Attachment #1: Type: text/plain, Size: 2858 bytes --]

This works fine for me. I have dropped my parent based patch and rebased the setup_telitqmi changes on top of this.

Lukasz


On 25/03/17 16:57, Jonas Bonn wrote:
> This patch simplifies and cleans up the check_usb_device function a bit
> by doing the two following (slightly intertwined) things:
> 
> 1)  The parent "usb_device" is searched for early in this function and this
> device will always have the ID_VENDOR_ID and ID_MODEL_ID properties.
> As such, we can get them from this device and thereby be certain that
> we _always_ have them available.
> 
> 2)  The logic of iterating the vendor_list table is cleaned up.  It's
> easier to follow and won't be any less efficient.
> ---
>  plugins/udevng.c | 37 ++++++++++++-------------------------
>  1 file changed, 12 insertions(+), 25 deletions(-)
> 
> diff --git a/plugins/udevng.c b/plugins/udevng.c
> index 2279bbe..ce2bc28 100644
> --- a/plugins/udevng.c
> +++ b/plugins/udevng.c
> @@ -1225,9 +1225,12 @@ static void check_usb_device(struct udev_device *device)
>  	if (devname == NULL)
>  		return;
>  
> +	vendor = udev_device_get_property_value(usb_device, "ID_VENDOR_ID");
> +	model = udev_device_get_property_value(usb_device, "ID_MODEL_ID");
> +
>  	driver = udev_device_get_property_value(usb_device, "OFONO_DRIVER");
>  	if (driver == NULL) {
> -		const char *drv, *vid, *pid;
> +		const char *drv;
>  		unsigned int i;
>  
>  		drv = udev_device_get_property_value(device, "ID_USB_DRIVER");
> @@ -1246,40 +1249,24 @@ static void check_usb_device(struct udev_device *device)
>  			}
>  		}
>  
> -		vid = udev_device_get_property_value(device, "ID_VENDOR_ID");
> -		pid = udev_device_get_property_value(device, "ID_MODEL_ID");
>  
> -		DBG("%s [%s:%s]", drv, vid, pid);
> +		DBG("%s [%s:%s]", drv, vendor, model);
>  
>  		for (i = 0; vendor_list[i].driver; i++) {
>  			if (g_str_equal(vendor_list[i].drv, drv) == FALSE)
>  				continue;
>  
> -			if (vendor_list[i].vid == NULL) {
> -				driver = vendor_list[i].driver;
> -				vendor = vid;
> -				model = pid;
> -				continue;
> +			if (vendor_list[i].vid) {
> +				if (!g_str_equal(vendor_list[i].vid, vendor))
> +					continue;
>  			}
>  
> -			if (vid == NULL || pid == NULL)
> -				continue;
> -
> -			if (g_str_equal(vendor_list[i].vid, vid) == TRUE) {
> -				if (vendor_list[i].pid == NULL) {
> -					driver = vendor_list[i].driver;
> -					vendor = vid;
> -					model = pid;
> +			if (vendor_list[i].pid) {
> +				if (!g_str_equal(vendor_list[i].pid, model))
>  					continue;
> -				}
> -
> -				if (g_strcmp0(vendor_list[i].pid, pid) == 0) {
> -					driver = vendor_list[i].driver;
> -					vendor = vid;
> -					model = pid;
> -					break;
> -				}
>  			}
> +
> +			driver = vendor_list[i].driver;
>  		}
>  
>  		if (driver == NULL)
> 

  parent reply	other threads:[~2017-03-27  9:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-25 16:57 [PATCH udev 00/15] Device handling cleanup series Jonas Bonn
2017-03-25 16:57 ` [PATCH udev 01/15] udevng: simplify logic in check_usb_device Jonas Bonn
2017-03-27  1:46   ` Denis Kenzior
2017-03-27  9:00   ` Lukasz Nowak [this message]
2017-03-25 16:57 ` [PATCH udev 02/15] ofono.rules: remove 'change' action Jonas Bonn
2017-03-27  1:46   ` Denis Kenzior
2017-03-25 16:57 ` [PATCH udev 03/15] udev: remove extraneous subsystem check Jonas Bonn
2017-03-27  1:52   ` Denis Kenzior
2017-03-25 16:57 ` [PATCH udev 04/15] udev: get udev property via lib function Jonas Bonn
2017-03-27  1:53   ` Denis Kenzior
2017-03-25 16:57 ` [PATCH udev 05/15] udev: remove unused modem property Jonas Bonn
2017-03-27  1:53   ` Denis Kenzior
2017-03-25 16:57 ` [PATCH udev 06/15] udev: simplify add_modem Jonas Bonn
2017-03-27  3:09   ` Denis Kenzior
2017-03-25 16:57 ` [PATCH udev 07/15] udev: add common modem registration code Jonas Bonn
2017-03-25 16:57 ` [PATCH udev 08/15] udev: simplify ifx modem registration Jonas Bonn
2017-03-25 16:57 ` [PATCH udev 09/15] udev: simplify wavecom " Jonas Bonn
2017-03-25 16:58 ` [PATCH udev 10/15] udev: remove extraneous subsystem check Jonas Bonn
2017-03-25 16:58 ` [PATCH udev 11/15] udevng: add legacy device handling functions Jonas Bonn
2017-03-27  3:24   ` Denis Kenzior
2017-03-28 12:58     ` Jonas Bonn
2017-03-25 16:58 ` [PATCH udev 12/15] udevng: match on the hsi subsystem for legacy devices Jonas Bonn
2017-03-25 16:58 ` [PATCH udev 13/15] udevng: hook up " Jonas Bonn
2017-03-25 16:58 ` [PATCH udev 14/15] udevng: get properties from interface Jonas Bonn
2017-03-27  3:27   ` Denis Kenzior
2017-03-28 13:07     ` Jonas Bonn
2017-03-28 15:20       ` Denis Kenzior
2017-03-25 16:58 ` [PATCH udev 15/15] plugins: remove udev module Jonas Bonn

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=0dc9a746-3586-11bc-6bde-932b5e563451@gmail.com \
    --to=lnowak.tyco@gmail.com \
    --cc=ofono@ofono.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.