Date: Mon, 16 Jan 2012 00:26:53 +0200 From: Mykhaylo Yehorov <yehorov@gmail.com> To: Hans Petter Selasky <hselasky@c2i.net> Cc: freebsd-gnats-submit@freebsd.org, freebsd-usb@freebsd.org Subject: Re: usb/164090: [umodem] [patch] Add sysctl with ucom unit number Message-ID: <CAH=XtiSOKLnsFzHbOYENyQqgc%2BRMJfoHwxNyoQKP-TNWShd1vQ@mail.gmail.com> In-Reply-To: <201201141145.05813.hselasky@c2i.net> References: <201201131705.q0DH5Tko030020@red.freebsd.org> <201201132154.01815.hselasky@c2i.net> <CAH=XtiS%2B%2BMncwZoMgtj3aXB4tV%2BSgPQe=gRkX%2Bev6FQgRKHt=w@mail.gmail.com> <201201141145.05813.hselasky@c2i.net>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Sat, Jan 14, 2012 at 12:45, Hans Petter Selasky <hselasky@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 <hselasky@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
[-- Attachment #2 --]
--- sys/dev/usb/serial/usb_serial.h.orig 2011-11-11 06:20:22.000000000 +0200
+++ sys/dev/usb/serial/usb_serial.h 2012-01-14 22:59:23.000000000 +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 */
#define UCOM_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.orig 2011-11-11 06:20:22.000000000 +0200
+++ sys/dev/usb/serial/usb_serial.c 2012-01-14 23:01:15.000000000 +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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAH=XtiSOKLnsFzHbOYENyQqgc%2BRMJfoHwxNyoQKP-TNWShd1vQ>
