public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: Anil Ravindranath <anil_ravindranath@pmc-sierra.com>
Cc: linux-scsi@vger.kernel.org,
	James.Bottomley@hansenpartnership.com, gregkh@suse.de
Subject: Re: PATCH: PMC-Sierra MaxRAID driver to support 6Gb/s SAS RAID controller
Date: Thu, 11 Jun 2009 13:47:49 +0200	[thread overview]
Message-ID: <200906111348.02029.eike-kernel@sf-tec.de> (raw)
In-Reply-To: <alpine.LNX.1.10.0906101259500.24722@rslab159.pmc-sierra.bc.ca>

[-- Attachment #1: Type: text/plain, Size: 5172 bytes --]

Anil Ravindranath wrote:
> Hi,
>
> This patch adds a driver to support PMC-Sierra 6Gb/s SAS RAID controller.
> This patch is created against scsi-misc-2.6.git.

> +module_param_named(debug, pmcraid_debug, uint, (S_IRUGO | S_IWUSR));
> +MODULE_PARM_DESC(debug,
> +		 "Enable driver verbose message logging. Set 1  to enable."
> +		 "(default: 0)");

I would say that "1" would enable this is rather obvious. And since this is 
only 0 or 1 better use bool instead of uint.


> +static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
> +{
> +	struct pmcraid_resource_entry *temp, *res = NULL;
> +	struct pmcraid_instance *pinstance;
> +	u8 target, bus, lun;
> +	unsigned long lock_flags;
> +	int rc = -ENXIO;
> +
> +	pinstance = (struct pmcraid_instance *)scsi_dev->host->hostdata;

hostdata is void* AFAIR so there is no need to cast. It's C, there is no need 
to cast to or from void* anywhere if the other thing is a pointer.

> +static int pmcraid_slave_configure(struct scsi_device *sdev)
> +{
> +	struct pmcraid_resource_entry *res = NULL;
> +
> +	res = sdev->hostdata;

No need to initialize res to NULL.

> +static u32 pmcraid_read_interrupts(struct pmcraid_instance *pinstance)
> +{
> +
> +	return ioread32(pinstance->int_regs.ioa_host_interrupt_reg);
> +}

Extra newline.

> +/**
> + * pmcraid_disable_interrupts - Masks and clears all specified interrupts
> + *
> + * @pinstance: pointer to per adapter instance structure
> + * @intr: interrupts to disable
> + *
> + * Return Value
> + *	 None
> + */

Well, that's rather obvious if it's a void function, isn't it? ;)


> +static int __devinit pmcraid_probe(
> +	struct pci_dev *pdev,
> +	const struct pci_device_id *dev_id
> +)
> +{
> +	struct pmcraid_instance *pinstance;
> +	struct Scsi_Host *host;
> +	void __iomem *mapped_pci_addr;
> +	int rc = PCIBIOS_SUCCESSFUL;
> +
> +	if (pmcraid_adapter_count >= PMCRAID_MAX_ADAPTERS) {
> +		pmcraid_err
> +			("maximum number(%d) of supported adapters reached\n",
> +			 pmcraid_adapter_count);
> +		return -ENOMEM;
> +	}
> +
> +	pmcraid_adapter_count++;

This counter may need a lock, else you might get into trouble.

> +	rc = pci_enable_device(pdev);

Well, I ask it every time, but nevertheless: why not use devres for your 
driver? It will make error handling in _probe as well as the _release stuff 
much easier.

> +	if (rc) {
> +		dev_err(&pdev->dev, "Cannot enable adapter\n");
> +		pmcraid_adapter_count--;
> +		goto out;
> +	}

Just "return rc" here. This goto into the middle of the function just for a 
return is IMHO hard to read.

> +	dev_info(&pdev->dev,
> +		"Found IOA(%x:%x) on PCI bus %d slot %d with IRQ: %d\n",
> +		 pdev->vendor, pdev->device, pdev->bus->number,
> +		 PCI_SLOT(pdev->bus->number), pdev->irq);

The IRQ and stuff is printed by request_irq() or such anyway. If you have 
enabled MSI the IRQ is a different one anyway.

> +	/* zero out entire instance structure */
> +	pinstance = (struct pmcraid_instance *)host->hostdata;
> +	memset(pinstance, 0, sizeof(struct pmcraid_instance));

memset(pinstance, 0, sizeof(*pinstance));

> +	/* Schedule worker thread to handle CCN and take care of adding and
> +	 * removing devices to OS
> +	 */
> +	schedule_work(&pinstance->worker_q);
> +
> +out:
> +	return rc;
> +
> +out_remove_host:
> +	scsi_remove_host(host);
> +
> +out_release_bufs:
> +	pmcraid_release_buffers(pinstance);
> +
> +out_unregister_isr:
> +	pmcraid_kill_tasklets(pinstance);
> +	pmcraid_unregister_interrupt_handler(pinstance);
> +
> +out_scsi_host_put:
> +	scsi_host_put(host);
> +
> +cleanup_nomem:
> +	iounmap(mapped_pci_addr);
> +
> +out_release_regions:
> +	pci_release_regions(pdev);
> +
> +out_disable_device:
> +	pmcraid_adapter_count--;
> +	pci_set_drvdata(pdev, NULL);
> +	pci_disable_device(pdev);
> +	rc = -ENODEV;
> +	goto out;
> +}

Just "return rc" here. And maybe it's a good idea to just keep the previous rc 
so you will see it was ENOMEM or whatever.

> +/* PMC PCI vendor ID and device ID values */
> +#define PCI_VENDOR_ID_PMC			0x11F8
> +#define PCI_DEVICE_ID_PMC_MAXRAID		0x5220
> +#define PCI_DEVICE_ID_PMC_0x8010		0x8010

You could just use the 0x8010 directly at the only place this constant is 
referenced.

> +#define IOARCB_LENGTH_CODE(n)         (((n)-3)/8 + (((n)-3)%8 > 0))

Oh, wow. I needed to throw this into a for loop to understand what you are 
doing here. Try DIV_ROUND_CLOSEST(n, 8) from include/kernel.h which does right 
the same.

> +/* macros to help in debugging */
> +#define pmcraid_err(...)  \
> +	printk(KERN_ERR "MaxRAID: "__VA_ARGS__)
> +
> +#define pmcraid_info(...) \
> +	if (pmcraid_debug) \
> +		printk(KERN_INFO "MaxRAID: "__VA_ARGS__)

Those should probably be rewritten to use pr_err() and pr_debug(). Or better 
use dev_dbg() and dev_info() directly.

> +/*
> + * pmcraid_adapter_id - structure defining the adapter id used by LLD
> + */
> +union pmcraid_adapter_id {
> +	struct {
> +		u32 slot_no:8;

Why not use u8?

> +		u32 bus_number:24;
> +	} y;

Greetings,

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  parent reply	other threads:[~2009-06-11 11:48 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-10 20:07 PATCH: PMC-Sierra MaxRAID driver to support 6Gb/s SAS RAID controller Anil Ravindranath
2009-06-11  1:23 ` Greg KH
2009-06-11  5:54   ` Anil Ravindranath
2009-06-13  7:04     ` Anil Ravindranath
2009-06-11  3:14 ` Grant Grundler
2009-06-11 13:11   ` Anil Ravindranath
2009-06-13  7:18   ` Anil Ravindranath
2009-06-11 11:47 ` Rolf Eike Beer [this message]
2009-06-11 13:25   ` Anil Ravindranath
2009-06-11 14:08   ` James Bottomley
2009-06-13  8:50   ` Anil Ravindranath
2009-06-11 16:32 ` Brian King
2009-06-12  6:06   ` Anil Ravindranath
2009-06-12 15:08   ` Grant Grundler
2009-06-12 15:23     ` Brian King
2009-06-12 16:17       ` Brian King
2009-06-12 16:20       ` Grant Grundler
2009-06-12 16:43         ` James Bottomley
2009-06-12 15:24     ` James Bottomley
2009-06-16 14:10   ` Anil Ravindranath
2009-06-16 17:08     ` Greg KH
2009-06-17 15:09     ` Brian King
2009-06-18 18:08       ` Anil Ravindranath
  -- strict thread matches above, loose matches on Subject: below --
2009-06-16 17:37 Anil Ravindranath
2009-06-16 18:48 ` Randy Dunlap
2009-06-17 11:04 ` Anil Ravindranath
2009-08-07  0:16 Anil Ravindranath
2009-08-18 21:44 ` Anil Ravindranath
2009-08-19  2:02 ` James Bottomley
2009-08-24 17:24   ` Anil Ravindranath
2009-08-26  0:35 Anil Ravindranath

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=200906111348.02029.eike-kernel@sf-tec.de \
    --to=eike-kernel@sf-tec.de \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=anil_ravindranath@pmc-sierra.com \
    --cc=gregkh@suse.de \
    --cc=linux-scsi@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