From: Enrico Mioso <mrkiko.rs@gmail.com>
To: netdev@vger.kernel.org
Cc: "Bjørn Mork" <bjorn@mork.no>
Subject: [PATCH 0/3] make cdc_ncm_tx_fixup and cdc_ncm_rx_fixup non-static functions
Date: Tue, 2 Jul 2013 22:06:18 +0200 (CEST) [thread overview]
Message-ID: <alpine.LNX.2.02.1307022202570.26010@eeeadesso> (raw)
In-Reply-To: <alpine.LNX.2.02.1307021855270.19053@eeeadesso>
Let cdc_ncm_tx_fixup and cdc_ncm_rx_fixup be non-static
This patchs makes those functions non-static, so that they could be exported
for use by other drivers.
Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 43afde8..493277e 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -858,7 +858,7 @@ static void cdc_ncm_txpath_bh(unsigned long param)
}
}
-static struct sk_buff *
+struct sk_buff *
cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{
struct sk_buff *skb_out;
@@ -965,7 +965,7 @@ error:
}
EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_ndp16);
-static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
+int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
{
struct sk_buff *skb;
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
On Tue, 2 Jul 2013, Enrico Mioso wrote:
==Date: Tue, 2 Jul 2013 19:04:05 +0200 (CEST)
==From: Enrico Mioso <mrkiko.rs@gmail.com>
==To: Bj?rn Mork <bjorn@mork.no>
==Cc: netdev@vger.kernel.org
==Subject: [RFC] huawei_cdc_ncm driver - status
==
==Hi all guys!
==I'm writing this mail to inform you about the progresso f the "new" driver -
==huawei_cdc_ncm.c, which should handle generally devices wich resembles the
==cdc_ncm standard, but embed another protocol on it (AT or something).
==This driver has been developed starting from a Bjorn idea, and is based on the
==cdc_mbim.c driver.
==
==Now - i need some help and corrections, review.
==the driver currently loads and doesn't cause panics, and that's already a very
==good result for a first-time kernel programmer! :)
==Even the driver name may be inappropriate, any ideas and suggestions are
==welcome!
==
==Here is the driver .c file: in addition:
==- I managed to export cdc_ncm {rx,tx}_fixup functions, modfying the needed .h
==file and adding symbol exporting.
==- I removed from the cdc_ncm driver entries that made it bind t my dongle
==- I added product and vendor id for my dongle, but probably doing something
==wrong...
==- updated the build infrastructure in accordance (Kconfig, Makefile ...) and
==that works.
==
==
==And here it is - please help me if you can.
==
==/* copyrights and other things are importand but will be added later */
==#include <linux/module.h>
==#include <linux/netdevice.h>
==#include <linux/ethtool.h>
==#include <linux/if_vlan.h>
==#include <linux/ip.h>
==#include <linux/mii.h>
==#include <linux/usb.h>
==#include <linux/usb/cdc.h>
==#include <linux/usb/usbnet.h>
==#include <linux/usb/cdc-wdm.h>
==#include <linux/usb/cdc_ncm.h>
==
==/* Specific driver data */
==struct huawei_cdc_ncm_state {
== struct cdc_ncm_ctx *ctx;
== atomic_t pmcount;
== struct usb_driver *subdriver;
== struct usb_interface *control;
== struct usb_interface *data;
==};
==
==static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on)
=={
== struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
== int rv = 0;
==
== if ((on && atomic_add_return(1, &drvstate->pmcount) == 1) || (!on && atomic_dec_and_test(&drvstate->pmcount))) {
== rv = usb_autopm_get_interface(usbnet_dev->intf);
== if (rv < 0)
== goto err;
== usbnet_dev->intf->needs_remote_wakeup = on;
== usb_autopm_put_interface(usbnet_dev->intf);
== }
==err:
== return rv;
==}
==
==static int huawei_cdc_ncm_wdm_manage_power(struct usb_interface *intf, int status)
=={
== struct usbnet *usbnet_dev = usb_get_intfdata(intf);
==
== /* can be called while disconnecting */
== if (!usbnet_dev)
== return 0;
==
== return huawei_cdc_ncm_manage_power(usbnet_dev, status);
==}
==
==
==/* Bind our driver to needed interfaces. Heavily inspired by cdc_mbim.c one! */
==static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev, struct usb_interface *intf) {
==
== /* Some general use variables */
== struct cdc_ncm_ctx *ctx;
== struct usb_driver *subdriver = ERR_PTR(-ENODEV);
== int ret = -ENODEV;
== struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
==
== /* Actually binds us to the device: use standard ncm function */
== ret = cdc_ncm_bind_common(usbnet_dev, intf, 1); /* altsetting should be 1 */
==
== /* Did the ncm bind function fail? */
== if (ret)
== goto err;
==
== /* Let cdc data ctx pointer point to our state structure */
== ctx = drvstate->ctx;
==
== if (usbnet_dev->status)
== subdriver = usb_cdc_wdm_register(ctx->control, &usbnet_dev->status->desc, 4096, huawei_cdc_ncm_wdm_manage_power); /* a smarter way to calculate that constant? */
== if (IS_ERR(subdriver)) {
== ret = PTR_ERR(subdriver);
== cdc_ncm_unbind(usbnet_dev, intf);
== goto err;
== }
==
== /* Prevent usbnet from using the status descriptor */
== usbnet_dev->status = NULL;
==
== drvstate->subdriver = subdriver;
==
== /* FIXME: should we handle the vlan header in some way? */
== /* FIXME2: in my opinion we also could not do ARP, hoping somebody can help... */
==err:
== return ret; /* ret = -ENODEV if not changed in the meanwhile */
==}
==
==static void huawei_cdc_ncm_unbind(struct usbnet *usbnet_dev, struct usb_interface *intf) {
== struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
== struct cdc_ncm_ctx *ctx = drvstate->ctx;
==
== /* Bye cdc-wdm! And see you soon! :) */
== if (drvstate->subdriver && drvstate->subdriver->disconnect)
== drvstate->subdriver->disconnect(ctx->control);
== drvstate->subdriver = NULL;
==
== /* Unbind from both control and data interface */
== cdc_ncm_unbind(usbnet_dev, intf);
==}
==
==/* Suspend function - the logic has been taken from cdc_mbim.c directly. */
==static int huawei_cdc_ncm_suspend(struct usb_interface *intf, pm_message_t message)
=={
== int ret = 0;
== struct usbnet *usbnet_dev = usb_get_intfdata(intf);
== struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
== struct cdc_ncm_ctx *ctx = drvstate->ctx;
==
== if (ctx == NULL) {
== ret = -1;
== goto error;
== }
==
== /*
== * Both usbnet_suspend() and subdriver->suspend() MUST return 0
== * in system sleep context, otherwise, the resume callback has
== * to recover device from previous suspend failure.
== */
== ret = usbnet_suspend(intf, message);
== if (ret < 0)
== goto error;
==
== if (intf == ctx->control && drvstate->subdriver && drvstate->subdriver->suspend)
== ret = drvstate->subdriver->suspend(intf, message);
== if (ret < 0)
== usbnet_resume(intf);
==
==error:
== return ret;
==}
==
==/* Resume function - logic took completely from huawei_cdc.c */
==static int huawei_cdc_ncm_resume(struct usb_interface *intf)
=={
== int ret = 0;
== struct usbnet *usbnet_dev = usb_get_intfdata(intf);
== struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
== struct cdc_ncm_ctx *ctx = drvstate->ctx;
== bool callsub = (intf == ctx->control && drvstate->subdriver && drvstate->subdriver->resume); /* should we call subdriver's resume? ? */
==
== if (callsub)
== ret = drvstate->subdriver->resume(intf);
== if (ret < 0)
== goto err;
== ret = usbnet_resume(intf);
== if (ret < 0 && callsub && drvstate->subdriver->suspend)
== drvstate->subdriver->suspend(intf, PMSG_SUSPEND);
==err:
== return ret;
==}
==
==
==/* General driver informations, exposed partly to modutils */
==static const struct driver_info huawei_cdc_info = {
== .description = "Huawei-style CDC NCM",
== .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
== .bind = huawei_cdc_ncm_bind,
== .unbind = huawei_cdc_ncm_unbind,
== .manage_power = huawei_cdc_ncm_manage_power,
== /* NCM RX and TX fixup functions work properly on these devices */
== .rx_fixup = cdc_ncm_rx_fixup,
== .tx_fixup = cdc_ncm_tx_fixup,
==};
==
==static const struct usb_device_id huawei_cdc_ncm_devs[] = {
== /* The correct NCM handling will be implemented. For now, only my dongle
== will be handled.
== */
== { USB_DEVICE(0x12d1, 0x1506) },
== {
== /* Terminating entry */
== },
==};
==/* Expose table in module info */
==MODULE_DEVICE_TABLE(usb, huawei_cdc_ncm_devs);
==
==
==/* USB driver struct - used by USB stack */
==static struct usb_driver huawei_cdc_ncm_driver = {
== .name = "huawei_cdc_ncm",
== .id_table = huawei_cdc_ncm_devs,
== .probe = usbnet_probe,
== .disconnect = usbnet_disconnect,
== .suspend = huawei_cdc_ncm_suspend,
== .resume = huawei_cdc_ncm_resume,
== .reset_resume = huawei_cdc_ncm_resume,
== .supports_autosuspend = 1,
== .disable_hub_initiated_lpm = 1,
==};
==module_usb_driver(huawei_cdc_ncm_driver);
==MODULE_AUTHOR("Enrico Mioso <mrkiko.rs@gmail.com>");
==MODULE_DESCRIPTION("USB CDC NCM host driver with encapsulated protocol support");
==MODULE_LICENSE("GPL");
==
next prev parent reply other threads:[~2013-07-02 20:05 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 10:43 [PATCH RFC] cdc_ncm.c: make rx and tx functions exportable Enrico Mioso
2013-07-02 12:01 ` Bjørn Mork
2013-07-02 12:05 ` Enrico Mioso
2013-07-02 17:04 ` [RFC] huawei_cdc_ncm driver - status Enrico Mioso
2013-07-02 19:06 ` Enrico Mioso
2013-07-02 20:06 ` Enrico Mioso [this message]
2013-07-02 20:10 ` [PATCH 1/3] Export cdc_ncm_{tx,rx}_fixup functions Enrico Mioso
2013-07-02 20:13 ` [PATCH RFC 2/3] Introduce huawei_cdc_ncm driver Enrico Mioso
2013-07-02 20:15 ` [PATCH RFC 3/3] huawei_cdc_ncm base skeleton Enrico Mioso
2013-07-03 6:40 ` Huaei E3131 - connected! Enrico Mioso
2013-07-03 7:11 ` Huaei E3131 - status Enrico Mioso
2013-07-03 8:15 ` Bjørn Mork
2013-07-03 12:55 ` [PATCH V2 1/3] usbnet: cdc_ncm: let cdc_ncm_tx_fixup and cdc_ncm_rx_fixup be non-static Enrico Mioso
2013-07-03 13:00 ` [PATCH V2 2/3] usbnet: cdc_ncm: export cdc_ncm_tx_fixup and cdc_ncm_rx_fixup Enrico Mioso
2013-07-03 13:19 ` Sergei Shtylyov
2013-07-03 13:22 ` Enrico Mioso
2013-07-03 13:33 ` [PATCH V3 1/2] Export cdc_ncm_{tx,rx]_fixup functions Enrico Mioso
2013-07-03 13:38 ` [PATCH V3 2/2] Introduce huawei_cdc_ncm driver Enrico Mioso
2013-07-03 16:18 ` Ben Hutchings
2013-07-03 18:11 ` [PATCH V3 2/2 RESEND] " Enrico Mioso
2013-07-04 13:19 ` Bjørn Mork
2013-07-04 17:03 ` Enrico Mioso
2013-07-03 18:11 ` [PATCH V3 2/2] " Enrico Mioso
2013-07-03 13:05 ` [PATCH V2 3/3] usbnet: introduce " Enrico Mioso
2013-07-03 13:13 ` [PATCH] usbnet: cdc_ncm: remove huawei devices handled by cdc_ncm_huawei.c Enrico Mioso
2013-07-03 7:13 ` Huaei E3131 - connected! Bjørn Mork
2013-07-03 7:38 ` [PATCH RFC 3/3] huawei_cdc_ncm base skeleton Bjørn Mork
2013-07-03 10:16 ` Enrico Mioso
2013-07-03 7:40 ` [PATCH RFC 2/3] Introduce huawei_cdc_ncm driver Bjørn Mork
2013-07-03 7:43 ` [PATCH 1/3] Export cdc_ncm_{tx,rx}_fixup functions Bjørn Mork
2013-07-03 10:19 ` Enrico Mioso
2013-07-03 7:45 ` [PATCH 0/3] make cdc_ncm_tx_fixup and cdc_ncm_rx_fixup non-static functions Bjørn Mork
2013-07-10 12:27 ` [PATCH 1/3] net: cdc_ncm: Export cdc_ncm_{tx,rx}_fixup functions for re-use Enrico Mioso
[not found] ` <0cbf7c81-182e-493c-9c28-5b78160a08f1@email.android.com>
[not found] ` <alpine.LNX.2.02.1307170457450.1161@eeeadesso>
[not found] ` <87bo4xx3ef.fsf@nemi.mork.no>
[not found] ` <87bo4xx3ef.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2013-08-16 13:39 ` [PATCH] " Enrico Mioso
2013-08-16 13:49 ` Greg Kroah-Hartman
2013-08-16 13:51 ` Enrico Mioso
2013-08-16 13:52 ` Greg Kroah-Hartman
2013-08-16 13:44 ` [PATCH] net: huawei_cdc_ncm: Introduce new huawei_cdc_ncm driver Enrico Mioso
2013-07-10 12:28 ` [PATCH 2/3] net: huawei_cdc_ncm: Introduce the " Enrico Mioso
2013-07-10 12:30 ` [PATCH 3/3] net: cdc_ncm: remove Huawei non-standard NCM device IDs Enrico Mioso
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=alpine.LNX.2.02.1307022202570.26010@eeeadesso \
--to=mrkiko.rs@gmail.com \
--cc=bjorn@mork.no \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).