mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>
To: Grant Likely <grant.likely@secretlab.ca>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	<devicetree-discuss@lists.ozlabs.org>, <sfr@canb.auug.org.au>,
	<linux-kernel@vger.kernel.org>, <davem@davemloft.net>
Cc: <sparclinux@vger.kernel.org>, <linuxppc-dev@lists.ozlabs.org>
Subject: RE: [RFC PATCH 06/15] dt: xilinx_hwicap: merge platform and of_platformdriver bindings
Date: Fri, 25 Feb 2011 10:25:22 -0800	[thread overview]
Message-ID: <8da12938-78ee-4a0f-b1e4-7bfac7fa16c3@VA3EHSMHS036.ehs.local> (raw)
In-Reply-To: <20110223043405.20795.19903.stgit@localhost6.localdomain6>

Minor nit below

Acked-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>

Steve

> -----Original Message-----
> From: linuxppc-dev-bounces+stephen=neuendorffer.name@lists.ozlabs.org
[mailto:linuxppc-dev-
> bounces+stephen=neuendorffer.name@lists.ozlabs.org] On Behalf Of Grant
Likely
> Sent: Tuesday, February 22, 2011 8:34 PM
> To: Benjamin Herrenschmidt; devicetree-discuss@lists.ozlabs.org;
sfr@canb.auug.org.au; linux-
> kernel@vger.kernel.org; davem@davemloft.net
> Cc: sparclinux@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
> Subject: [RFC PATCH 06/15] dt: xilinx_hwicap: merge platform and
of_platformdriver bindings
> 
> of_platform_driver is getting removed, and a single platform_driver
> can now support both devicetree and non-devicetree use cases.  This
> patch merges the two driver registrations.
> 
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>  drivers/char/xilinx_hwicap/xilinx_hwicap.c |  129
+++++++++++-----------------
>  1 files changed, 49 insertions(+), 80 deletions(-)
> 
> diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
> index 9f2272e..a55e877 100644
> --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
> +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
> @@ -714,20 +714,29 @@ static int __devexit hwicap_remove(struct device
*dev)
>  	return 0;		/* success */
>  }
> 
> -static int __devinit hwicap_drv_probe(struct platform_device *pdev)
> +#ifdef CONFIG_OF
> +static int __devinit hwicap_of_probe(struct platform_device *op)
>  {
> -	struct resource *res;
> -	const struct config_registers *regs;
> +	struct resource res;
> +	const unsigned int *id;
>  	const char *family;
> +	int rc;
> +	const struct hwicap_driver_config *config =
op->dev.of_match->data;
> +	const struct config_registers *regs;
> 
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res)
> -		return -ENODEV;
> +
> +	rc = of_address_to_resource(op->dev.of_node, 0, &res);
> +	if (rc) {
> +		dev_err(&op->dev, "invalid address\n");
> +		return rc;
> +	}
> +
> +	id = of_get_property(op->dev.of_node, "port-number", NULL);
> 
>  	/* It's most likely that we're using V4, if the family is not
>  	   specified */
>  	regs = &v4_config_registers;
> -	family = pdev->dev.platform_data;
> +	family = of_get_property(op->dev.of_node, "xlnx,family", NULL);
> 
>  	if (family) {
>  		if (!strcmp(family, "virtex2p")) {
> @@ -738,54 +747,33 @@ static int __devinit hwicap_drv_probe(struct
platform_device *pdev)
>  			regs = &v5_config_registers;
>  		}
>  	}
> -
> -	return hwicap_setup(&pdev->dev, pdev->id, res,
> -			&buffer_icap_config, regs);
> +	return hwicap_setup(&op->dev, id ? *id : -1, &res, config,
> +			regs);
>  }
> -
> -static int __devexit hwicap_drv_remove(struct platform_device *pdev)
> +#else
> +static inline int hwicap_of_probe(struct platform_device *op)
>  {
> -	return hwicap_remove(&pdev->dev);
> +	return -EINVAL;
>  }
> +#endif /* CONFIG_OF */
> 
> -static struct platform_driver hwicap_platform_driver = {
> -	.probe = hwicap_drv_probe,
> -	.remove = hwicap_drv_remove,
> -	.driver = {
> -		.owner = THIS_MODULE,
> -		.name = DRIVER_NAME,
> -	},
> -};
> -
> -/*
---------------------------------------------------------------------
> - * OF bus binding
> - */
> -
> -#if defined(CONFIG_OF)
> -static int __devinit
> -hwicap_of_probe(struct platform_device *op, const struct of_device_id
*match)
> +static int __devinit hwicap_drv_probe(struct platform_device *pdev)
>  {
> -	struct resource res;
> -	const unsigned int *id;
> -	const char *family;
> -	int rc;
> -	const struct hwicap_driver_config *config = match->data;
> +	struct resource *res;
>  	const struct config_registers *regs;
> +	const char *family;
> 
> -	dev_dbg(&op->dev, "hwicap_of_probe(%p, %p)\n", op, match);
> -
> -	rc = of_address_to_resource(op->dev.of_node, 0, &res);
> -	if (rc) {
> -		dev_err(&op->dev, "invalid address\n");
> -		return rc;
> -	}
> +	if (pdev->dev.of_match)
> +		return hwicap_of_probe(pdev);
> 
> -	id = of_get_property(op->dev.of_node, "port-number", NULL);
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res)
> +		return -ENODEV;
> 
>  	/* It's most likely that we're using V4, if the family is not
>  	   specified */
>  	regs = &v4_config_registers;
> -	family = of_get_property(op->dev.of_node, "xlnx,family", NULL);
> +	family = pdev->dev.platform_data;
> 
>  	if (family) {
>  		if (!strcmp(family, "virtex2p")) {
> @@ -796,15 +784,17 @@ hwicap_of_probe(struct platform_device *op,
const struct of_device_id *match)
>  			regs = &v5_config_registers;
>  		}
>  	}
> -	return hwicap_setup(&op->dev, id ? *id : -1, &res, config,
> -			regs);
> +
> +	return hwicap_setup(&pdev->dev, pdev->id, res,
> +			&buffer_icap_config, regs);
>  }
> 
> -static int __devexit hwicap_of_remove(struct platform_device *op)
> +static int __devexit hwicap_drv_remove(struct platform_device *pdev)
>  {
> -	return hwicap_remove(&op->dev);
> +	return hwicap_remove(&pdev->dev);
>  }
> 
> +#ifdef CONFIG_OF
>  /* Match table for of_platform binding */

Does the comment still make sense?

>  static const struct of_device_id __devinitconst hwicap_of_match[] = {
>  	{ .compatible = "xlnx,opb-hwicap-1.00.b", .data =
&buffer_icap_config},
> @@ -812,33 +802,23 @@ static const struct of_device_id __devinitconst
hwicap_of_match[] = {
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, hwicap_of_match);
> +#else
> +#define hwicap_of_match NULL
> +#endif
> 
> -static struct of_platform_driver hwicap_of_driver = {
> -	.probe = hwicap_of_probe,
> -	.remove = __devexit_p(hwicap_of_remove),
> +static struct platform_driver hwicap_platform_driver = {
> +	.probe = hwicap_drv_probe,
> +	.remove = hwicap_drv_remove,
>  	.driver = {
> -		.name = DRIVER_NAME,
>  		.owner = THIS_MODULE,
> +		.name = DRIVER_NAME,
>  		.of_match_table = hwicap_of_match,
>  	},
>  };
> 
> -/* Registration helpers to keep the number of #ifdefs to a minimum */
> -static inline int __init hwicap_of_register(void)
> -{
> -	pr_debug("hwicap: calling of_register_platform_driver()\n");
> -	return of_register_platform_driver(&hwicap_of_driver);
> -}
> -
> -static inline void __exit hwicap_of_unregister(void)
> -{
> -	of_unregister_platform_driver(&hwicap_of_driver);
> -}
> -#else /* CONFIG_OF */
> -/* CONFIG_OF not enabled; do nothing helpers */
> -static inline int __init hwicap_of_register(void) { return 0; }
> -static inline void __exit hwicap_of_unregister(void) { }
> -#endif /* CONFIG_OF */
> +/*
---------------------------------------------------------------------
> + * OF bus binding
> + */
> 
>  static int __init hwicap_module_init(void)
>  {
> @@ -856,21 +836,12 @@ static int __init hwicap_module_init(void)
>  		return retval;
> 
>  	retval = platform_driver_register(&hwicap_platform_driver);
> -
> -	if (retval)
> -		goto failed1;
> -
> -	retval = hwicap_of_register();
> -
>  	if (retval)
> -		goto failed2;
> +		goto failed;
> 
>  	return retval;
> 
> - failed2:
> -	platform_driver_unregister(&hwicap_platform_driver);
> -
> - failed1:
> + failed:
>  	unregister_chrdev_region(devt, HWICAP_DEVICES);
> 
>  	return retval;
> @@ -884,8 +855,6 @@ static void __exit hwicap_module_cleanup(void)
> 
>  	platform_driver_unregister(&hwicap_platform_driver);
> 
> -	hwicap_of_unregister();
> -
>  	unregister_chrdev_region(devt, HWICAP_DEVICES);
>  }
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.



  reply	other threads:[~2011-02-25 18:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23  4:33 [RFC PATCH 00/15] Remove last remains of of_platform_bus_type Grant Likely
2011-02-23  4:33 ` [RFC PATCH 01/15] dt/powerpc: move of_bus_type infrastructure to ibmebus Grant Likely
2011-02-24 14:46   ` Arnd Bergmann
2011-02-25  8:53     ` Benjamin Herrenschmidt
2011-02-28  7:35     ` Grant Likely
2011-02-23  4:33 ` [RFC PATCH 02/15] dt: add a match table pointer to struct device Grant Likely
2011-02-23 18:29   ` Rob Herring
2011-02-23 18:44     ` Grant Likely
2011-02-23  4:33 ` [RFC PATCH 03/15] dt/powerpc: Eliminate users of of_platform_{, un}register_driver Grant Likely
2011-02-23  4:33 ` [RFC PATCH 04/15] dt/sparc: " Grant Likely
2011-02-23  4:34 ` [RFC PATCH 05/15] leds/leds-gpio: merge platform_driver with of_platform_driver Grant Likely
2011-02-23  4:34 ` [RFC PATCH 06/15] dt: xilinx_hwicap: merge platform and of_platform driver bindings Grant Likely
2011-02-25 18:25   ` Stephen Neuendorffer [this message]
2011-02-28  7:41     ` [RFC PATCH 06/15] dt: xilinx_hwicap: merge platform and of_platformdriver bindings Grant Likely
2011-02-23  4:34 ` [RFC PATCH 07/15] dt: uartlite: merge platform and of_platform driver bindings Grant Likely
2011-02-23  8:58   ` Peter Korsgaard
2011-02-23 18:10     ` Grant Likely
2011-02-23  4:34 ` [RFC PATCH 08/15] dt/spi: Eliminate users of of_platform_{, un}register_driver Grant Likely
2011-02-23  4:34 ` [RFC PATCH 09/15] dt/sound: " Grant Likely
2011-02-23  4:34 ` [RFC PATCH 10/15] dt/net: " Grant Likely
2011-02-23  4:34 ` [RFC PATCH 11/15] dt/video: " Grant Likely
2011-02-23  4:34 ` [RFC PATCH 12/15] dt/usb: " Grant Likely
2011-02-23  4:34 ` [RFC PATCH 13/15] dt/serial: " Grant Likely
2011-02-24 16:34   ` Arnd Bergmann
2011-02-23  4:34 ` [RFC PATCH 14/15] dt: Eliminate of_platform_{,un}register_driver Grant Likely
2011-02-23 16:56   ` Rob Herring
2011-02-23 17:22     ` Grant Likely
2011-02-23  4:34 ` [RFC PATCH 15/15] dt: eliminate of_platform_driver shim code Grant Likely

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=8da12938-78ee-4a0f-b1e4-7bfac7fa16c3@VA3EHSMHS036.ehs.local \
    --to=stephen.neuendorffer@xilinx.com \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=sfr@canb.auug.org.au \
    --cc=sparclinux@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

all inboxes | Powered by JetHome®