netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denis Joseph Barrow <D.Barow-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
To: Alan Cox <alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>,
	Filip Aben <F.Aben-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>,
	Andrew Bird
	<ajb-5+cxppFmGx6/3pe1ocb+s/XRex20P6io@public.gmane.org>,
	Paul Hardwick
	<P.Hardwick-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
Cc: Greg KH <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>,
	Linux USB kernel mailing list
	<linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux netdev Mailing list
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: small design problem with hso driver
Date: Thu, 09 Oct 2008 11:56:38 +0200	[thread overview]
Message-ID: <48EDD556.1070508@option.com> (raw)
In-Reply-To: <20081009103259.066cc94a-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>

Hi Alan,
No they are not.
Have a look at.
/drivers/char/nozomi.c
admittedly it's written by some of the same guys.
/* Called when the userspace process opens the tty, /dev/noz*.  */
static int ntty_open(struct tty_struct *tty, struct file *file)
{
	struct port *port = get_port_by_tty(tty);
	struct nozomi *dc = get_dc_by_tty(tty);
	unsigned long flags;

	if (!port || !dc || dc->state != NOZOMI_STATE_READY)
		return -ENODEV;

	if (mutex_lock_interruptible(&port->tty_sem))
		return -ERESTARTSYS;

	port->tty_open_count++;
	dc->open_ttys++;

	/* Enable interrupt downlink for channel */
	if (port->tty_open_count == 1) {
		tty->low_latency = 1;
		tty->driver_data = port;
		port->tty = tty;
		DBG1("open: %d", port->token_dl);
		spin_lock_irqsave(&dc->spin_mutex, flags);
		dc->last_ier = dc->last_ier | port->token_dl;
		writew(dc->last_ier, dc->reg_ier);
		spin_unlock_irqrestore(&dc->spin_mutex, flags);
	}

	mutex_unlock(&port->tty_sem);

	return 0;
}

/* Called when the userspace process close the tty, /dev/noz*. */
static void ntty_close(struct tty_struct *tty, struct file *file)
{
	struct nozomi *dc = get_dc_by_tty(tty);
	struct port *port = tty->driver_data;
	unsigned long flags;

	if (!dc || !port)
		return;

	if (mutex_lock_interruptible(&port->tty_sem))
		return;

	if (!port->tty_open_count)
		goto exit;

	dc->open_ttys--;
	port->tty_open_count--;

	if (port->tty_open_count == 0) {
		DBG1("close: %d", port->token_dl);
		spin_lock_irqsave(&dc->spin_mutex, flags);
		dc->last_ier &= ~(port->token_dl);
		writew(dc->last_ier, dc->reg_ier);
		spin_unlock_irqrestore(&dc->spin_mutex, flags);
	}

exit:
	mutex_unlock(&port->tty_sem);
}


Alan Cox wrote:
>> Surely if the driver returns an error code on hso_serial_open
>> hso_serial_close shouldn't be called
>> or have I a complete misunderstanding
>> of char driver semantics.
> 
> Generally yes that would be sane. The tty layer has always called the
> close method of drivers on a failed open and the drivers are all written
> assuming that.
> 
> It would be nice to change but there are far bigger fish to fry.
> 
> Alan


-- 
best regards,
D.J. Barrow
--
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

  parent reply	other threads:[~2008-10-09  9:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08 13:52 small design problem with hso driver Denis Joseph Barrow
     [not found] ` <48ECBB26.7080402-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
2008-10-08 17:45   ` Greg KH
     [not found]     ` <20081008174556.GA15387-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-10-09  9:01       ` Denis Joseph Barrow
     [not found]         ` <48EDC887.8010403-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
2008-10-09  9:32           ` Alan Cox
     [not found]             ` <20081009103259.066cc94a-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2008-10-09  9:56               ` Denis Joseph Barrow [this message]
     [not found]                 ` <48EDD556.1070508-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
2008-10-09 10:11                   ` Alan Cox

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=48EDD556.1070508@option.com \
    --to=d.barow-x9gzzrpc1qbqt0dzr+alfa@public.gmane.org \
    --cc=F.Aben-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org \
    --cc=P.Hardwick-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org \
    --cc=ajb-5+cxppFmGx6/3pe1ocb+s/XRex20P6io@public.gmane.org \
    --cc=alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org \
    --cc=greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).