Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-02-29 Thread remko
Synopsis: [umodem] [patch] Add sysctl with ucom unit number

Responsible-Changed-From-To: freebsd-usb-remko
Responsible-Changed-By: remko
Responsible-Changed-When: Wed Feb 29 21:45:38 UTC 2012
Responsible-Changed-Why: 
I'll see whether I can do additional merges

http://www.freebsd.org/cgi/query-pr.cgi?pr=164090
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-01-15 Thread Mykhaylo Yehorov
On Sat, Jan 14, 2012 at 12:45, Hans Petter Selasky hsela...@c2i.net wrote:
 On Saturday 14 January 2012 10:51:07 Mykhaylo Yehorov wrote:
 On Fri, Jan 13, 2012 at 22:54, Hans Petter Selasky hsela...@c2i.net wrote:
  Hi,
 
  Could you patch ucom_set_pnpinfo_usb() instead, so that such a sysctl is
  created for all ucom devices, not only umodem?

 I guess it will be necessary to remove a sysctl oid from a parent
 sysctl tree before destroying ucom structures.
 It's would be better to do in ucom_detach() but now there is no a
 pointer to a parent device structure from there.

 Now all drivers that use ucom pass a pointer to parent softc structure
 to ucom_attach().
 Is there any reason for this?
 May be it's would be more useful to pass a pointer to a parent device
 structure.

  Can you explain a bit more how you use this information in your scripts?

 I've got a gps receiver and a mobile phone that supported by the umodem
 driver. I can attach its in any order.
 So I use sysctl to generate gpsd and ppp configs with appropriate
 values of serial port.

 Ok, I see.

 And you cannot use the information passed through devd by
 ucom_set_pnpinfo_usb()?ucom_detach

You are right. It's possible to use ucom_set_pnpinfo_usb().

In the attached patch an ucom sysctl oid will be added to a parent sysctl tree
in ucom_set_pnpinfo_usb() and will be removed in ucom_detach().

-- 
Mykhaylo Yehorov
--- sys/dev/usb/serial/usb_serial.h.orig2011-11-11 06:20:22.0 
+0200
+++ sys/dev/usb/serial/usb_serial.h 2012-01-14 22:59:23.0 +0200
@@ -70,6 +70,7 @@
 #include sys/tty.h
 #include sys/serial.h
 #include sys/fcntl.h
+#include sys/sysctl.h
 
 /* Module interface related macros */
 #defineUCOM_MODVER 1
@@ -134,6 +135,7 @@
struct usb_process sc_tq;
uint32_t sc_unit;
uint32_t sc_subunits;
+   struct sysctl_oid *sc_sysctl_dev_ucom;
 };
 
 struct ucom_softc {
--- sys/dev/usb/serial/usb_serial.c.orig2011-11-11 06:20:22.0 
+0200
+++ sys/dev/usb/serial/usb_serial.c 2012-01-14 23:01:15.0 +0200
@@ -274,6 +274,8 @@
sc[subunit].sc_flag |= UCOM_FLAG_ATTACHED;
}
 
+   ssc-sc_sysctl_dev_ucom = NULL;
+
DPRINTF(tp = %p, unit = %d, subunits = %d\n,
sc-sc_tty, ssc-sc_unit, ssc-sc_subunits);
 
@@ -292,6 +294,8 @@
if (ssc-sc_subunits == 0)
return; /* not initialized */
 
+   sysctl_remove_oid(ssc-sc_sysctl_dev_ucom, 1, 0);
+
usb_proc_drain(ssc-sc_tq);
 
for (subunit = 0; subunit  ssc-sc_subunits; subunit++) {
@@ -433,6 +437,12 @@
 
 if (usbd_set_pnpinfo(uaa-device, iface_index, buf) != 0)
device_printf(dev, Could not set PNP info\n);
+
+   if (ssc-sc_sysctl_dev_ucom == NULL)
+   ssc-sc_sysctl_dev_ucom = SYSCTL_ADD_INT(NULL,
+   SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+   OID_AUTO, ucom, CTLFLAG_RD,
+   ssc-sc_unit, -1, Attached ucom unit number);
 }
 
 static void
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-01-15 Thread Mykhaylo Yehorov
The following reply was made to PR usb/164090; it has been noted by GNATS.

From: Mykhaylo Yehorov yeho...@gmail.com
To: Hans Petter Selasky hsela...@c2i.net
Cc: freebsd-usb@freebsd.org, freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number
Date: Mon, 16 Jan 2012 00:26:53 +0200

 --002354470e84513e6804b69898ff
 Content-Type: text/plain; charset=UTF-8
 
 On Sat, Jan 14, 2012 at 12:45, Hans Petter Selasky hsela...@c2i.net wrote:
  On Saturday 14 January 2012 10:51:07 Mykhaylo Yehorov wrote:
  On Fri, Jan 13, 2012 at 22:54, Hans Petter Selasky hsela...@c2i.net wrote:
   Hi,
  
   Could you patch ucom_set_pnpinfo_usb() instead, so that such a sysctl is
   created for all ucom devices, not only umodem?
 
  I guess it will be necessary to remove a sysctl oid from a parent
  sysctl tree before destroying ucom structures.
  It's would be better to do in ucom_detach() but now there is no a
  pointer to a parent device structure from there.
 
  Now all drivers that use ucom pass a pointer to parent softc structure
  to ucom_attach().
  Is there any reason for this?
  May be it's would be more useful to pass a pointer to a parent device
  structure.
 
   Can you explain a bit more how you use this information in your scripts?
 
  I've got a gps receiver and a mobile phone that supported by the umodem
  driver. I can attach its in any order.
  So I use sysctl to generate gpsd and ppp configs with appropriate
  values of serial port.
 
  Ok, I see.
 
  And you cannot use the information passed through devd by
  ucom_set_pnpinfo_usb()?ucom_detach
 
 You are right. It's possible to use ucom_set_pnpinfo_usb().
 
 In the attached patch an ucom sysctl oid will be added to a parent sysctl tree
 in ucom_set_pnpinfo_usb() and will be removed in ucom_detach().
 
 -- 
 Mykhaylo Yehorov
 
 --002354470e84513e6804b69898ff
 Content-Type: text/plain; charset=US-ASCII; name=ucom-sysctl.diff.txt
 Content-Disposition: attachment; filename=ucom-sysctl.diff.txt
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_gxgmbdqz0
 
 LS0tIHN5cy9kZXYvdXNiL3NlcmlhbC91c2Jfc2VyaWFsLmgub3JpZwkyMDExLTExLTExIDA2OjIw
 OjIyLjAwMDAwMDAwMCArMDIwMAorKysgc3lzL2Rldi91c2Ivc2VyaWFsL3VzYl9zZXJ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YnVuaXRzID09IDApCiAJCXJldHVybjsJCS8qIG5vdCBp
 bml0aWFsaXplZCAqLwogCisJc3lzY3RsX3JlbW92ZV9vaWQoc3NjLT5zY19zeXNjdGxfZGV2X3Vj
 b20sIDEsIDApOworCiAJdXNiX3Byb2NfZHJhaW4oJnNzYy0+c2NfdHEpOwogCiAJZm9yIChzdWJ1
 bml0ID0gMDsgc3VidW5pdCA8IHNzYy0+c2Nfc3VidW5pdHM7IHN1YnVuaXQrKykgewpAQCAtNDMz
 LDYgKzQzNywxMiBAQAogICAgIAogICAgIGlmICh1c2JkX3NldF9wbnBpbmZvKHVhYS0+ZGV2aWNl
 LCBpZmFjZV9pbmRleCwgYnVmKSAhPSAwKQogCWRldmljZV9wcmludGYoZGV2LCAiQ291bGQgbm90
 IHNldCBQTlAgaW5mb1xuIik7CisKKwlpZiAoc3NjLT5zY19zeXNjdGxfZGV2X3Vjb20gPT0gTlVM
 TCkKKwkJc3NjLT5zY19zeXNjdGxfZGV2X3Vjb20gPSBTWVNDVExfQUREX0lOVChOVUxMLAorCQkg
 ICAgU1lTQ1RMX0NISUxEUkVOKGRldmljZV9nZXRfc3lzY3RsX3RyZWUoZGV2KSksCisJCSAgICBP
 SURfQVVUTywgInVjb20iLCBDVExGTEFHX1JELAorCQkgICAgJnNzYy0+c2NfdW5pdCwgLTEsICJB
 dHRhY2hlZCB1Y29tIHVuaXQgbnVtYmVyIik7CiB9CiAKIHN0YXRpYyB2b2lkCg==
 --002354470e84513e6804b69898ff--
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-01-14 Thread Mykhaylo Yehorov
On Fri, Jan 13, 2012 at 22:54, Hans Petter Selasky hsela...@c2i.net wrote:

 Hi,

 Could you patch ucom_set_pnpinfo_usb() instead, so that such a sysctl is
 created for all ucom devices, not only umodem?

I guess it will be necessary to remove a sysctl oid from a parent
sysctl tree before destroying ucom structures.
It's would be better to do in ucom_detach() but now there is no a
pointer to a parent device structure from there.

Now all drivers that use ucom pass a pointer to parent softc structure
to ucom_attach().
Is there any reason for this?
May be it's would be more useful to pass a pointer to a parent device structure.

 Can you explain a bit more how you use this information in your scripts?

I've got a gps receiver and a mobile phone that supported by the umodem driver.
I can attach its in any order.
So I use sysctl to generate gpsd and ppp configs with appropriate
values of serial port.

-- 
Mykhaylo Yehorov
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-01-14 Thread Mykhaylo Yehorov
The following reply was made to PR usb/164090; it has been noted by GNATS.

From: Mykhaylo Yehorov yeho...@gmail.com
To: Hans Petter Selasky hsela...@c2i.net
Cc: freebsd-usb@freebsd.org, freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number
Date: Sat, 14 Jan 2012 11:51:07 +0200

 On Fri, Jan 13, 2012 at 22:54, Hans Petter Selasky hsela...@c2i.net wrote:
 
  Hi,
 
  Could you patch ucom_set_pnpinfo_usb() instead, so that such a sysctl is
  created for all ucom devices, not only umodem?
 
 I guess it will be necessary to remove a sysctl oid from a parent
 sysctl tree before destroying ucom structures.
 It's would be better to do in ucom_detach() but now there is no a
 pointer to a parent device structure from there.
 
 Now all drivers that use ucom pass a pointer to parent softc structure
 to ucom_attach().
 Is there any reason for this?
 May be it's would be more useful to pass a pointer to a parent device 
structure.
 
  Can you explain a bit more how you use this information in your scripts?
 
 I've got a gps receiver and a mobile phone that supported by the umodem driver.
 I can attach its in any order.
 So I use sysctl to generate gpsd and ppp configs with appropriate
 values of serial port.
 
 -- 
 Mykhaylo Yehorov
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-01-14 Thread Hans Petter Selasky
On Saturday 14 January 2012 10:51:07 Mykhaylo Yehorov wrote:
 On Fri, Jan 13, 2012 at 22:54, Hans Petter Selasky hsela...@c2i.net wrote:
  Hi,
  
  Could you patch ucom_set_pnpinfo_usb() instead, so that such a sysctl is
  created for all ucom devices, not only umodem?
 
 I guess it will be necessary to remove a sysctl oid from a parent
 sysctl tree before destroying ucom structures.
 It's would be better to do in ucom_detach() but now there is no a
 pointer to a parent device structure from there.
 
 Now all drivers that use ucom pass a pointer to parent softc structure
 to ucom_attach().
 Is there any reason for this?
 May be it's would be more useful to pass a pointer to a parent device
 structure.
 
  Can you explain a bit more how you use this information in your scripts?
 
 I've got a gps receiver and a mobile phone that supported by the umodem
 driver. I can attach its in any order.
 So I use sysctl to generate gpsd and ppp configs with appropriate
 values of serial port.

Ok, I see.

And you cannot use the information passed through devd by 
ucom_set_pnpinfo_usb()?

--HPS
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-01-14 Thread Hans Petter Selasky
The following reply was made to PR usb/164090; it has been noted by GNATS.

From: Hans Petter Selasky hsela...@c2i.net
To: Mykhaylo Yehorov yeho...@gmail.com
Cc: freebsd-usb@freebsd.org,
 freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number
Date: Sat, 14 Jan 2012 11:45:05 +0100

 On Saturday 14 January 2012 10:51:07 Mykhaylo Yehorov wrote:
  On Fri, Jan 13, 2012 at 22:54, Hans Petter Selasky hsela...@c2i.net wrote:
   Hi,
   
   Could you patch ucom_set_pnpinfo_usb() instead, so that such a sysctl is
   created for all ucom devices, not only umodem?
  
  I guess it will be necessary to remove a sysctl oid from a parent
  sysctl tree before destroying ucom structures.
  It's would be better to do in ucom_detach() but now there is no a
  pointer to a parent device structure from there.
  
  Now all drivers that use ucom pass a pointer to parent softc structure
  to ucom_attach().
  Is there any reason for this?
  May be it's would be more useful to pass a pointer to a parent device
  structure.
  
   Can you explain a bit more how you use this information in your scripts?
  
  I've got a gps receiver and a mobile phone that supported by the umodem
  driver. I can attach its in any order.
  So I use sysctl to generate gpsd and ppp configs with appropriate
  values of serial port.
 
 Ok, I see.
 
 And you cannot use the information passed through devd by 
 ucom_set_pnpinfo_usb()?
 
 --HPS
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number

2012-01-13 Thread Hans Petter Selasky
The following reply was made to PR usb/164090; it has been noted by GNATS.

From: Hans Petter Selasky hsela...@c2i.net
To: freebsd-usb@freebsd.org
Cc: Mykhaylo Yehorov yeho...@gmail.com,
 freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number
Date: Fri, 13 Jan 2012 21:54:01 +0100

 On Friday 13 January 2012 18:05:29 Mykhaylo Yehorov wrote:
  Number: 164090
  Category:   usb
  Synopsis:   [umodem] [patch] Add sysctl with ucom unit number
  Confidential:   no
  Severity:   non-critical
  Priority:   low
  Responsible:freebsd-usb
  State:  open
  Quarter:
  Keywords:
  Date-Required:
  Class:  change-request
  Submitter-Id:   current-users
  Arrival-Date:   Fri Jan 13 17:10:08 UTC 2012
  Closed-Date:
  Last-Modified:
  Originator: Mykhaylo Yehorov
  Release:FreeBSD 9.0-RELEASE
  Organization:
  
  Environment:
  FreeBSD atom.lan29.local 9.0-RELEASE FreeBSD 9.0-RELEASE #7: Fri Jan 13
  15:18:21 EET 2012
  mika@atom.lan29.local:/usr/obj/usr/src/sys/MINI_KVA384  i386
  
  Description:
  Now there is no easy way to determine which tty device file is used by an
  umodem device. With the following patch the umodem driver will create
  sysctl node dev.umodem.X.ucom. This sysctl will be helpful in devd
  scripts.
  
  How-To-Repeat:
  
  Fix:
  Patch attached with submission follows:
  
  --- orig/sys/dev/usb/serial/umodem.c 2011-11-11 06:20:22.0 +0200
  +++ sys/dev/usb/serial/umodem.c  2012-01-03 13:06:14.371630639 +0200
  @@ -169,6 +169,8 @@
   uint8_t sc_cm_over_data;
   uint8_t sc_cm_cap;  /* CM capabilities */
   uint8_t sc_acm_cap; /* ACM capabilities */
  +
  +int ucom_unit;
   };
  
   static device_probe_t umodem_probe;
  @@ -412,6 +414,13 @@
   }
   ucom_set_pnpinfo_usb(sc-sc_super_ucom, dev);
  
  +sc-ucom_unit = sc-sc_super_ucom.sc_unit;
  +
  +SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
  +SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
  +OID_AUTO, ucom, CTLFLAG_RD,
  +sc-ucom_unit, -1, Attached ucom unit number);
  +
   return (0);
  
 
 Hi,
 
 Could you patch ucom_set_pnpinfo_usb() instead, so that such a sysctl is 
 created for all ucom devices, not only umodem?
 
 Can you explain a bit more how you use this information in your scripts?
 
 --HPS
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org