From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-wireless@vger.kernel.org, slapin@ossfans.org,
maxim.osipov@siemens.com, dmitry.baryshkov@siemens.com,
oliver.fendt@siemens.com,
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Subject: Re: [PATCH 09/10] ieee802154: add serial dongle driver
Date: Mon, 1 Jun 2009 16:27:32 +0100 [thread overview]
Message-ID: <20090601162732.4a070c43@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <1243868091-5315-10-git-send-email-dbaryshkov@gmail.com>
> + zbdev->pending_data = kzalloc(zbdev->pending_size, GFP_KERNEL);
> + if (!zbdev->pending_data) {
> + printk(KERN_ERR "%s(): unable to allocate memory\n", __func__);
> + zbdev->pending_id = 0;
> + zbdev->pending_size = 0;
> + return -ENOMEM;
> + }
> + memcpy(zbdev->pending_data, buf, len);
> +
> + return _send_pending_data(zbdev);
Where do you check that the tty has enough space ?
> + case STATE_WAIT_COMMAND:
> + if (is_command(c)) {
> + zbdev->id = c;
> + zbdev->state = STATE_WAIT_PARAM1;
> + } else {
> + cleanup(zbdev);
> + printk(KERN_ERR "%s, unexpected command id: %x\n", __func__, c);
In all these ERR cases what stops a remote device from having fun spewing
garbage at you and filling the log ?
>
> + * channels 0-10 are not valid for us */
> + BUG_ON(channel < 11 || channel > 26);
> + /* ... but our crappy firmware numbers channels from 1 to 16
> + * which is a mystery. We suould enforce that using PIB API
> + * but additional checking here won't kill, and gcc will
> + * optimize this stuff anyway. */
> + BUG_ON((channel - 10) < 1 && (channel - 10) > 16);
Shouldn't be driver specific hacks in the ldisc surely - or is the ldisc
only applicable to a specific single bit of hardware ?
> + minor = tty->index + tty->driver->minor_start;
> + zbdev->dev->parent = class_find_device(tty_class, NULL, &minor, dev_minor_match);
> +
That sort of thing shouldn't be buried in the depths of a driver. I'm not
entirely averse to that sort of thing but it belongs in a helper in the
tty layer.
> + zbdev->tty = tty;
Refcounting ?
> + cleanup(zbdev);
> +
> + tty->disc_data = zbdev;
> + tty->receive_room = MAX_DATA_SIZE;
> + tty->low_latency = 1;
You can't go around mashing driver internal values - many drivers don't
support low_latency mode and this will make them crash.
> +
> + /* FIXME: why is this needed. Note don't use ldisc_ref here as the
> + open path is before the ldisc is referencable */
> +
[Because otherwise after a SET_LDISC there may be bits from the old stuff
left over - this one will go away as I finish the ldisc switching
rewrite that is in the ttydev tree]
> +/*
> + * Called when the tty is put into another line discipline or it hangs up. We
> + * have to wait for any cpu currently executing in any of the other zb_tty_*
> + * routines to finish before we can call zb_tty_close and free the
> + * zb_serial_dev struct. This routine must be called from process context, not
> + * interrupt or softirq context.
> + */
> +static void
> +ieee802154_tty_close(struct tty_struct *tty)
> +{
> + struct zb_device *zbdev;
> +
> + zbdev = tty->disc_data;
> + if (NULL == zbdev) {
> + printk(KERN_WARNING "%s: match is not found\n", __func__);
> + return;
> + }
> +
> + tty->disc_data = NULL;
> + zbdev->tty = NULL;
Again you want a refcount on these I suspect. You may actually be safe
anyway but it would be cleaner to take/drop refs.
> +static int
> +ieee802154_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
> +{
> + struct zb_device *zbdev;
> + struct ifreq ifr;
> + int err;
> + void __user *argp = (void __user *) arg;
> +
> + pr_debug("cmd = 0x%x\n", cmd);
> + memset(&ifr, 0, sizeof(ifr));
> +
> + zbdev = tty->disc_data;
> + if (NULL == zbdev) {
> + pr_debug("match is not found\n");
> + return -EINVAL;
> + }
If that is NULL it's a serious bug so WARN on it I think
> + default:
> + pr_debug("Unknown ioctl cmd: %u\n", cmd);
> + return -EINVAL;
This will break default ioctl processing. You probably want to call into
some of the generic handlers at this point depending upon your hardware.
Either way -EINVAL is wrong.
> + }
> + return 0;
Unreachable
> +static void
> +ieee802154_tty_receive(struct tty_struct *tty, const unsigned char *buf, char *cflags, int count)
> +{
> + struct zb_device *zbdev;
> + int i;
> +
> + /* Debug info */
> + printk(KERN_INFO "%lu %s, received %d bytes:", jiffies, __func__, count);
> + for (i = 0; i < count; ++i)
> + printk(KERN_CONT " 0x%02X", buf[i]);
> + printk(KERN_CONT "\n");
I don't think the above is meant to be there....
next prev parent reply other threads:[~2009-06-01 15:26 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-01 14:54 [RFC][WIP] IEEE 802.15.4 implementation for Linux v1 Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 01/10] crc-itu-t: add bit-reversed calculation Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 02/10] Add constants for the ieee 802.15.4/ZigBee stack Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 03/10] net: add IEEE 802.15.4 socket family implementation Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 04/10] net: add NL802154 interface for configuration of 802.15.4 devices Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 05/10] ieee802154: add simple HardMAC driver sample Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 06/10] mac802154: add a software MAC 802.15.4 implementation Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 07/10] ieee802154: add virtual loopback driver Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 08/10] tty_io: export tty_class Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 09/10] ieee802154: add serial dongle driver Dmitry Eremin-Solenikov
2009-06-01 14:54 ` [PATCH 10/10] ieee802154: add at86rf230/rf231 spi driver Dmitry Eremin-Solenikov
2009-06-01 16:21 ` Gábor Stefanik
2009-06-01 20:33 ` Dmitry Eremin-Solenikov
2009-06-02 8:10 ` Holger Schurig
2009-06-02 8:21 ` Marcel Holtmann
2009-06-02 8:29 ` Ответ: " Dmitry Eremin-Solenikov
2009-06-02 8:36 ` Marcel Holtmann
2009-06-02 8:46 ` Florian Fainelli
2009-06-02 8:49 ` Maxim Osipov
2009-06-02 9:15 ` Holger Schurig
2009-06-02 9:29 ` ?????: " Jonathan Cameron
2009-06-02 11:42 ` Dmitry Eremin-Solenikov
2009-06-02 8:52 ` Ответ: " Sergey Lapin
2009-06-01 15:27 ` Alan Cox [this message]
2009-06-01 20:29 ` [PATCH 09/10] ieee802154: add serial dongle driver Dmitry Eremin-Solenikov
2009-06-01 21:52 ` Alan Cox
2009-06-02 14:43 ` Sergey Lapin
2009-06-01 15:07 ` [PATCH 08/10] tty_io: export tty_class Alan Cox
2009-06-01 15:10 ` Dmitry Eremin-Solenikov
2009-06-01 15:34 ` Alan Cox
2009-06-02 14:22 ` Dmitry Eremin-Solenikov
2009-06-02 14:35 ` Alan Cox
2009-06-05 12:24 ` [PATCH 06/10] mac802154: add a software MAC 802.15.4 implementation Pavel Machek
2009-06-04 0:32 ` [PATCH 03/10] net: add IEEE 802.15.4 socket family implementation Andrew Morton
2009-06-04 11:16 ` Dmitry Eremin-Solenikov
2009-06-04 13:46 ` John W. Linville
2009-06-04 14:10 ` Dmitry Eremin-Solenikov
2009-06-04 14:15 ` Johannes Berg
2009-06-04 0:05 ` [PATCH 01/10] crc-itu-t: add bit-reversed calculation Andrew Morton
2009-06-05 4:03 ` [RFC][WIP] IEEE 802.15.4 implementation for Linux v1 Jon Smirl
2009-06-05 4:49 ` Dmitry Eremin-Solenikov
2009-06-05 12:58 ` Jon Smirl
2009-06-13 3:21 ` Jon Smirl
2009-06-13 5:37 ` Maxim Osipov
2009-06-13 12:39 ` Jon Smirl
2009-06-21 6:40 ` Pavel Machek
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=20090601162732.4a070c43@lxorguk.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=dbaryshkov@gmail.com \
--cc=dmitry.baryshkov@siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=maxim.osipov@siemens.com \
--cc=netdev@vger.kernel.org \
--cc=oliver.fendt@siemens.com \
--cc=slapin@ossfans.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
all inboxes | Powered by JetHome®