From: H Hartley Sweeten <hartleys@visionengravers.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: <devel@driverdev.osuosl.org>, <abbotti@mev.co.uk>,
<gregkh@linuxfoundation.org>
Subject: [PATCH 15/35] staging: comedi: cb_pcimdda: remove thisboard and devpriv macros
Date: Thu, 16 Aug 2012 19:47:51 -0700 [thread overview]
Message-ID: <201208161947.51371.hartleys@visionengravers.com> (raw)
These macros rely on a local variable having a specific name.
Remove them and use the comedi_board() helper to get the thisboard
pointer.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/staging/comedi/drivers/cb_pcimdda.c | 33 ++++++++++++-----------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c
index 04a9d5b..04b9995 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdda.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdda.c
@@ -131,11 +131,6 @@ static const struct board_struct boards[] = {
};
/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct board_struct *)dev->board_ptr)
-
-/*
* this structure is for data unique to this hardware driver. If
* several hardware drivers keep similar information in this structure,
* feel free to suggest moving the variable to the struct comedi_device
@@ -154,12 +149,6 @@ struct board_private_struct {
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct board_private_struct *)dev->private)
-
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -203,17 +192,15 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it);
*/
static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct board_struct *thisboard;
+ struct board_private_struct *devpriv;
struct comedi_subdevice *s;
int err;
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- * if this function fails (returns negative) then the private area is
- * kfree'd by comedi
- */
- if (alloc_private(dev, sizeof(struct board_private_struct)) < 0)
- return -ENOMEM;
+ err = alloc_private(dev, sizeof(*devpriv));
+ if (err)
+ return err;
+ devpriv = dev->private;
/*
* If you can probe the device to determine what device in a series
@@ -223,6 +210,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
err = probe(dev, it);
if (err)
return err;
+ thisboard = comedi_board(dev);
/* Output some info */
printk("comedi%d: %s: ", dev->minor, thisboard->name);
@@ -281,6 +269,8 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
static void detach(struct comedi_device *dev)
{
+ struct board_private_struct *devpriv = dev->private;
+
if (devpriv) {
if (dev->subdevices && devpriv->attached_to_8255) {
subdev_8255_cleanup(dev, dev->subdevices + 2);
@@ -297,6 +287,7 @@ static void detach(struct comedi_device *dev)
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct board_private_struct *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
unsigned long offset = devpriv->registers + chan * 2;
@@ -336,6 +327,7 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct board_private_struct *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -372,6 +364,8 @@ static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
*/
static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
{
+ const struct board_struct *thisboard;
+ struct board_private_struct *devpriv = dev->private;
struct pci_dev *pcidev = NULL;
int index;
unsigned long registers;
@@ -396,6 +390,7 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
devpriv->pci_dev = pcidev;
dev->board_ptr = boards + index;
+ thisboard = comedi_board(dev);
if (comedi_pci_enable(pcidev, thisboard->name)) {
printk
("cb_pcimdda: Failed to enable PCI device and request regions\n");
--
1.7.11
reply other threads:[~2012-08-17 2:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201208161947.51371.hartleys@visionengravers.com \
--to=hartleys@visionengravers.com \
--cc=abbotti@mev.co.uk \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@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
Powered by JetHome