From: Andrew Morton <akpm@linux-foundation.org>
To: Michael Buesch <mb@bu3sch.de>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>,
bcm43xx-dev@lists.berlios.de, netdev@vger.kernel.org,
linux-wireless@vger.kernel.org,
Gary Zambrano <zambrano@broadcom.com>
Subject: Re: [PATCH] Merge the Sonics Silicon Backplane subsystem
Date: Fri, 27 Jul 2007 12:38:53 -0700 [thread overview]
Message-ID: <20070727123853.d16e875c.akpm@linux-foundation.org> (raw)
In-Reply-To: <200707272130.48973.mb@bu3sch.de>
On Fri, 27 Jul 2007 21:30:48 +0200
Michael Buesch <mb@bu3sch.de> wrote:
> > ERROR: "foo * bar" should be "foo *bar"
> > #4156: FILE: drivers/ssb/ssb_private.h:119:
> > +extern struct ssb_bus * ssb_pci_dev_to_bus(struct pci_dev *pdev);
> >
> > are worth addressing.
>
> Well, I intentionally wrote that this way, as in my opinion
> it it easier to read. I only use this additional space for
> functions returning a pointer.
>
> struct foo * function(int a, int b);
>
> vs:
>
> struct foo *function(int a, int b);
>
> But I can change that, if that's really an issue and a
> style violation.
It's a microissue but yeah, no-space is more conventional.
> > > +static ssize_t ssb_pci_attr_sprom_show(struct device *pcidev,
> > > + struct device_attribute *attr,
> > > + char *buf)
> > > +{
> > > + struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev);
> > > + struct ssb_bus *bus;
> > > + u16 *sprom;
> > > + int err = -ENODEV;
> > > + ssize_t count = 0;
> > > +
> > > + bus = ssb_pci_dev_to_bus(pdev);
> > > + if (!bus)
> > > + goto out;
> > > + err = -ENOMEM;
> > > + sprom = kcalloc(SSB_SPROMSIZE_WORDS, sizeof(u16), GFP_KERNEL);
> > > + if (!sprom)
> > > + goto out;
> > > +
> > > + err = -ERESTARTSYS;
> > > + if (mutex_lock_interruptible(&bus->pci_sprom_mutex))
> > > + goto out_kfree;
> > > + sprom_do_read(bus, sprom);
> > > + mutex_unlock(&bus->pci_sprom_mutex);
> > > +
> > > + count = sprom2hex(sprom, buf, PAGE_SIZE);
> > > + err = 0;
> > > +
> > > +out_kfree:
> > > + kfree(sprom);
> > > +out:
> > > + return err ? err : count;
> > > +}
> >
> > The mutex_lock_interruptible() looks fishy. Some commented explanation of
> > what it's doing would be good here. It's quite unobvious to this reader.
> > Cheesy deadlock avoidance? Hope not.
>
> No, it's simply to avoid writing the SPROM concurrently.
> SPROM writing is hairy and we must make sure here that
> we are the only one accessing the whole bus. We do that
> by suspending all devices and taking a lock to protect
> the SPROM from write concurrency.
Sure, but why is the locking interruptible rather than plain old
mutex_lock()?
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
To: Michael Buesch <mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
Cc: "linux-kernel"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
bcm43xx-dev-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Gary Zambrano <zambrano-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH] Merge the Sonics Silicon Backplane subsystem
Date: Fri, 27 Jul 2007 12:38:53 -0700 [thread overview]
Message-ID: <20070727123853.d16e875c.akpm@linux-foundation.org> (raw)
In-Reply-To: <200707272130.48973.mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
On Fri, 27 Jul 2007 21:30:48 +0200
Michael Buesch <mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org> wrote:
> > ERROR: "foo * bar" should be "foo *bar"
> > #4156: FILE: drivers/ssb/ssb_private.h:119:
> > +extern struct ssb_bus * ssb_pci_dev_to_bus(struct pci_dev *pdev);
> >
> > are worth addressing.
>
> Well, I intentionally wrote that this way, as in my opinion
> it it easier to read. I only use this additional space for
> functions returning a pointer.
>
> struct foo * function(int a, int b);
>
> vs:
>
> struct foo *function(int a, int b);
>
> But I can change that, if that's really an issue and a
> style violation.
It's a microissue but yeah, no-space is more conventional.
> > > +static ssize_t ssb_pci_attr_sprom_show(struct device *pcidev,
> > > + struct device_attribute *attr,
> > > + char *buf)
> > > +{
> > > + struct pci_dev *pdev = container_of(pcidev, struct pci_dev, dev);
> > > + struct ssb_bus *bus;
> > > + u16 *sprom;
> > > + int err = -ENODEV;
> > > + ssize_t count = 0;
> > > +
> > > + bus = ssb_pci_dev_to_bus(pdev);
> > > + if (!bus)
> > > + goto out;
> > > + err = -ENOMEM;
> > > + sprom = kcalloc(SSB_SPROMSIZE_WORDS, sizeof(u16), GFP_KERNEL);
> > > + if (!sprom)
> > > + goto out;
> > > +
> > > + err = -ERESTARTSYS;
> > > + if (mutex_lock_interruptible(&bus->pci_sprom_mutex))
> > > + goto out_kfree;
> > > + sprom_do_read(bus, sprom);
> > > + mutex_unlock(&bus->pci_sprom_mutex);
> > > +
> > > + count = sprom2hex(sprom, buf, PAGE_SIZE);
> > > + err = 0;
> > > +
> > > +out_kfree:
> > > + kfree(sprom);
> > > +out:
> > > + return err ? err : count;
> > > +}
> >
> > The mutex_lock_interruptible() looks fishy. Some commented explanation of
> > what it's doing would be good here. It's quite unobvious to this reader.
> > Cheesy deadlock avoidance? Hope not.
>
> No, it's simply to avoid writing the SPROM concurrently.
> SPROM writing is hairy and we must make sure here that
> we are the only one accessing the whole bus. We do that
> by suspending all devices and taking a lock to protect
> the SPROM from write concurrency.
Sure, but why is the locking interruptible rather than plain old
mutex_lock()?
next prev parent reply other threads:[~2007-07-27 19:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-27 16:57 [PATCH] Merge the Sonics Silicon Backplane subsystem Michael Buesch
2007-07-27 16:57 ` Michael Buesch
2007-07-27 19:03 ` Andrew Morton
2007-07-27 19:03 ` Andrew Morton
2007-07-27 19:30 ` Michael Buesch
2007-07-27 19:30 ` Michael Buesch
2007-07-27 19:38 ` Andrew Morton [this message]
2007-07-27 19:38 ` Andrew Morton
2007-07-27 19:43 ` Michael Buesch
2007-07-27 19:43 ` Michael Buesch
2007-07-27 20:12 ` Andrew Morton
2007-07-27 20:12 ` Andrew Morton
2007-07-27 20:28 ` Michael Buesch
2007-07-27 20:28 ` Michael Buesch
2007-07-29 4:45 ` Dmitry Torokhov
2007-07-27 19:21 ` John W. Linville
2007-07-27 19:21 ` John W. Linville
2007-07-27 19:39 ` Michael Buesch
2007-08-02 13:58 ` Geert Uytterhoeven
2007-08-02 14:24 ` Michael Buesch
2007-08-02 14:24 ` Michael Buesch
2007-08-02 16:12 ` Geert Uytterhoeven
2007-08-02 16:18 ` Michael Buesch
2007-08-02 16:18 ` Michael Buesch
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=20070727123853.d16e875c.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mb@bu3sch.de \
--cc=netdev@vger.kernel.org \
--cc=zambrano@broadcom.com \
/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.