From: Marcel Holtmann <marcel@holtmann.org>
To: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: HSO: add option hso driver
Date: Wed, 14 May 2008 19:36:00 +0200 [thread overview]
Message-ID: <1210786560.7025.0.camel@violet.holtmann.net> (raw)
In-Reply-To: <482AF058.3020505@teltonika.lt>
Hi Paulius,
> > +/* called once for each interface upon device insertion */
> > +static int hso_probe(struct usb_interface *interface,
> > + const struct usb_device_id *id)
> > +{
> > + int mux, i, if_num, port_spec;
> > + unsigned char port_mask;
> > + struct hso_device *hso_dev = NULL;
> > + struct hso_shared_int *shared_int;
> > + struct hso_device *tmp_dev = NULL;
> > +
> > + if_num = interface->altsetting->desc.bInterfaceNumber;
> > +
> > + /* Get the interface/port specification from either driver_info or from
> > + * the device itself */
> > + if (id->driver_info)
> > + port_spec = ((u32 *)(id->driver_info))[if_num];
> > + else
> > + port_spec = hso_get_config_data(interface);
> > +
> > + if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) {
> > + dev_err(&interface->dev, "Not our interface\n");
> > + return -ENODEV;
> > + }
> > + /* Check if we need to switch to alt interfaces prior to port
> > + * configuration */
> > + if (interface->num_altsetting > 1)
> > + usb_set_interface(interface_to_usbdev(interface), if_num, 1);
> > + interface->needs_remote_wakeup = 1;
> > +
> > + /* Allocate new hso device(s) */
> > + switch (port_spec & HSO_INTF_MASK) {
> > + case HSO_INTF_MUX:
> > + if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) {
> > + /* Create the network device */
> > + if (!disable_net) {
> > + hso_dev = hso_create_net_device(interface);
> > + if (!hso_dev)
> > + goto exit;
> > + tmp_dev = hso_dev;
> > + }
> > + }
> > +
> > + if (hso_get_mux_ports(interface, &port_mask))
> > + /* TODO: de-allocate everything */
> > + goto exit;
> > +
> > + shared_int = hso_create_shared_int(interface);
> > + if (!shared_int)
> > + goto exit;
> > +
> > + for (i = 1, mux = 0; i < 0x100; i = i << 1, mux++) {
> > + if (port_mask & i) {
> > + hso_dev = hso_create_mux_serial_device(
> > + interface, i, shared_int);
> > + if (!hso_dev)
> > + goto exit;
> > + }
> > + }
> > +
> > + if (tmp_dev)
> > + hso_dev = tmp_dev;
> > + break;
> > +
> > + case HSO_INTF_BULK:
> > + /* It's a regular bulk interface */
> > + if (((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK)
> > + && !disable_net)
> > + hso_dev = hso_create_net_device(interface);
> > + else
> > + hso_dev =
> > + hso_create_bulk_serial_device(interface, port_spec);
> > + if (!hso_dev)
> > + goto exit;
> > + break;
> > + default:
> > + goto exit;
> > + }
> > +
> > + usb_driver_claim_interface(&hso_driver, interface, hso_dev);
>
> Is usb_driver_claim_interface really needed?
no it is not. That can be removed.
Regards
Marcel
WARNING: multiple messages have this Message-ID (diff)
From: Marcel Holtmann <marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
To: Paulius Zaleckas
<paulius.zaleckas-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: HSO: add option hso driver
Date: Wed, 14 May 2008 19:36:00 +0200 [thread overview]
Message-ID: <1210786560.7025.0.camel@violet.holtmann.net> (raw)
In-Reply-To: <482AF058.3020505-Ft0m5Q12RQ9xBelEqimL3w@public.gmane.org>
Hi Paulius,
> > +/* called once for each interface upon device insertion */
> > +static int hso_probe(struct usb_interface *interface,
> > + const struct usb_device_id *id)
> > +{
> > + int mux, i, if_num, port_spec;
> > + unsigned char port_mask;
> > + struct hso_device *hso_dev = NULL;
> > + struct hso_shared_int *shared_int;
> > + struct hso_device *tmp_dev = NULL;
> > +
> > + if_num = interface->altsetting->desc.bInterfaceNumber;
> > +
> > + /* Get the interface/port specification from either driver_info or from
> > + * the device itself */
> > + if (id->driver_info)
> > + port_spec = ((u32 *)(id->driver_info))[if_num];
> > + else
> > + port_spec = hso_get_config_data(interface);
> > +
> > + if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) {
> > + dev_err(&interface->dev, "Not our interface\n");
> > + return -ENODEV;
> > + }
> > + /* Check if we need to switch to alt interfaces prior to port
> > + * configuration */
> > + if (interface->num_altsetting > 1)
> > + usb_set_interface(interface_to_usbdev(interface), if_num, 1);
> > + interface->needs_remote_wakeup = 1;
> > +
> > + /* Allocate new hso device(s) */
> > + switch (port_spec & HSO_INTF_MASK) {
> > + case HSO_INTF_MUX:
> > + if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) {
> > + /* Create the network device */
> > + if (!disable_net) {
> > + hso_dev = hso_create_net_device(interface);
> > + if (!hso_dev)
> > + goto exit;
> > + tmp_dev = hso_dev;
> > + }
> > + }
> > +
> > + if (hso_get_mux_ports(interface, &port_mask))
> > + /* TODO: de-allocate everything */
> > + goto exit;
> > +
> > + shared_int = hso_create_shared_int(interface);
> > + if (!shared_int)
> > + goto exit;
> > +
> > + for (i = 1, mux = 0; i < 0x100; i = i << 1, mux++) {
> > + if (port_mask & i) {
> > + hso_dev = hso_create_mux_serial_device(
> > + interface, i, shared_int);
> > + if (!hso_dev)
> > + goto exit;
> > + }
> > + }
> > +
> > + if (tmp_dev)
> > + hso_dev = tmp_dev;
> > + break;
> > +
> > + case HSO_INTF_BULK:
> > + /* It's a regular bulk interface */
> > + if (((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK)
> > + && !disable_net)
> > + hso_dev = hso_create_net_device(interface);
> > + else
> > + hso_dev =
> > + hso_create_bulk_serial_device(interface, port_spec);
> > + if (!hso_dev)
> > + goto exit;
> > + break;
> > + default:
> > + goto exit;
> > + }
> > +
> > + usb_driver_claim_interface(&hso_driver, interface, hso_dev);
>
> Is usb_driver_claim_interface really needed?
no it is not. That can be removed.
Regards
Marcel
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-05-14 17:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-13 21:51 [PATCH] HSO: add option hso driver Greg KH
2008-05-13 21:51 ` Greg KH
2008-05-13 22:27 ` Alan Cox
2008-05-13 22:27 ` Alan Cox
2008-05-13 23:26 ` Jeff Garzik
2008-05-14 1:58 ` Greg KH
2008-05-14 4:57 ` Greg Kroah-Hartman
2008-05-14 4:57 ` Greg Kroah-Hartman
2008-05-14 13:59 ` Paulius Zaleckas
2008-05-14 13:59 ` Paulius Zaleckas
2008-05-14 15:12 ` Filip Aben
2008-05-14 17:36 ` Marcel Holtmann [this message]
2008-05-14 17:36 ` Marcel Holtmann
2008-06-12 2:51 ` Jeff Garzik
2008-05-14 4:52 ` [PATCH] " Greg KH
2008-05-14 4:52 ` Greg KH
2008-05-14 15:58 ` Jan Engelhardt
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=1210786560.7025.0.camel@violet.holtmann.net \
--to=marcel@holtmann.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulius.zaleckas@teltonika.lt \
/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.