Patchwork [v4,2/3] ahci_platform: switch to module device table matching

login
register
mail settings
Submitter Lin Mac
Date Jan. 9, 2011, 1:49 a.m.
Message ID <1294537775-21714-3-git-send-email-mkl0301@gmail.com>
Download mbox | patch
Permalink /patch/78000/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Lin Mac - Jan. 9, 2011, 1:49 a.m.
From: Mac Lin <mkl0301@gmail.com>

Switch the driver to use module device table matching mechanism to add SoC-specific parts to the generic driver.

Signed-off-by: Mac Lin <mkl0301@gmail.com>
---
 drivers/ata/ahci_platform.c  |   14 +++++++++++++-
 drivers/ata/ahci_platforms.h |   16 ++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)
 create mode 100644 drivers/ata/ahci_platforms.h
Anton Vorontsov - Jan. 9, 2011, 2:56 a.m.
On Sun, Jan 09, 2011 at 09:49:34AM +0800, mkl0301@gmail.com wrote:
> From: Mac Lin <mkl0301@gmail.com>
> 
> Switch the driver to use module device table matching mechanism to add SoC-specific parts to the generic driver.
> 
> Signed-off-by: Mac Lin <mkl0301@gmail.com>
> ---
>  drivers/ata/ahci_platform.c  |   14 +++++++++++++-
>  drivers/ata/ahci_platforms.h |   16 ++++++++++++++++

I think header and .c file names should match. I.e. just
ahci_platform.h.

>  2 files changed, 29 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/ata/ahci_platforms.h
> 
> diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
> index 6fef1fa..190db2c 100644
> --- a/drivers/ata/ahci_platform.c
> +++ b/drivers/ata/ahci_platform.c
> @@ -19,9 +19,11 @@
>  #include <linux/interrupt.h>
>  #include <linux/device.h>
>  #include <linux/platform_device.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/libata.h>
>  #include <linux/ahci_platform.h>
>  #include "ahci.h"
> +#include "ahci_platforms.h"
>  
>  static struct scsi_host_template ahci_platform_sht = {
>  	AHCI_SHT("ahci_platform"),
> @@ -29,6 +31,7 @@ static struct scsi_host_template ahci_platform_sht = {
>  
>  static int __init ahci_probe(struct platform_device *pdev)
>  {
> +	const struct platform_device_id *platid = platform_get_device_id(pdev);
>  	struct device *dev = &pdev->dev;
>  	struct ahci_platform_data *pdata = dev->platform_data;
>  	struct ata_port_info pi = {
> @@ -46,6 +49,9 @@ static int __init ahci_probe(struct platform_device *pdev)
>  	int i;
>  	int rc;
>  
> +	if (!pdata && platid && platid->driver_data)
> +		pdata = (void *)platid->driver_data;
> +
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!mem) {
>  		dev_err(dev, "no mmio space\n");
> @@ -171,12 +177,19 @@ static int __devexit ahci_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static const struct platform_device_id ahci_pltfm_ids[] = {

s/pltfm/platform/ to match the rest of the driver.

On the next resend, feel free to add my

Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

Thanks!

Patch

diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 6fef1fa..190db2c 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -19,9 +19,11 @@ 
 #include <linux/interrupt.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/libata.h>
 #include <linux/ahci_platform.h>
 #include "ahci.h"
+#include "ahci_platforms.h"
 
 static struct scsi_host_template ahci_platform_sht = {
 	AHCI_SHT("ahci_platform"),
@@ -29,6 +31,7 @@  static struct scsi_host_template ahci_platform_sht = {
 
 static int __init ahci_probe(struct platform_device *pdev)
 {
+	const struct platform_device_id *platid = platform_get_device_id(pdev);
 	struct device *dev = &pdev->dev;
 	struct ahci_platform_data *pdata = dev->platform_data;
 	struct ata_port_info pi = {
@@ -46,6 +49,9 @@  static int __init ahci_probe(struct platform_device *pdev)
 	int i;
 	int rc;
 
+	if (!pdata && platid && platid->driver_data)
+		pdata = (void *)platid->driver_data;
+
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!mem) {
 		dev_err(dev, "no mmio space\n");
@@ -171,12 +177,19 @@  static int __devexit ahci_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct platform_device_id ahci_pltfm_ids[] = {
+	{ "ahci", },
+	{ },
+};
+MODULE_DEVICE_TABLE(platform, ahci_pltfm_ids);
+
 static struct platform_driver ahci_driver = {
 	.remove = __devexit_p(ahci_remove),
 	.driver = {
 		.name = "ahci",
 		.owner = THIS_MODULE,
 	},
+	.id_table	= ahci_pltfm_ids,
 };
 
 static int __init ahci_init(void)
@@ -194,4 +207,3 @@  module_exit(ahci_exit);
 MODULE_DESCRIPTION("AHCI SATA platform driver");
 MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:ahci");
diff --git a/drivers/ata/ahci_platforms.h b/drivers/ata/ahci_platforms.h
new file mode 100644
index 0000000..cf16e6f
--- /dev/null
+++ b/drivers/ata/ahci_platforms.h
@@ -0,0 +1,16 @@ 
+/*
+ * Copyright 2010 MontaVista Software, LLC.
+ * Copyright 2010 Cavium Networks
+ *
+ * Authors: Anton Vorontsov <avorontsov@mvista.com>
+ *	    Mac Lin <mkl0301@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _DRIVERS_SATA_AHCI_PLATFORMS_H
+#define _DRIVERS_SATA_AHCI_PLATFORMS_H
+
+#endif /*_DRIVERS_SATA_AHCI_PLATFORMS_H*/