linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq
@ 2004-12-08 23:16 Kumar Gala
  2004-12-08 23:26 ` [PATCH] Add prototypes for " Kumar Gala
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kumar Gala @ 2004-12-08 23:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, rmk, greg

Adds the ability to find a resource or irq on a platform device by its 
resource name.  This patch also tweaks how resource names get set.  
Before, resources names were set to pdev->dev.bus_id, now that only 
happens if the resource name has not been previous set.

All of this allows us to find a resource without assuming what order the 
resources are in.

Signed-off-by; Kumar Gala <kumar.gala@freescale.com>

-- 

diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c	2004-12-08 16:59:52 -06:00
+++ b/drivers/base/platform.c	2004-12-08 16:59:52 -06:00
@@ -58,6 +58,42 @@
 }
 
 /**
+ *	platform_get_resource_byname - get a resource for a device by name
+ *	@dev: platform device
+ *	@type: resource type
+ *	@name: resource name
+ */
+struct resource *
+platform_get_resource_byname(struct platform_device *dev, unsigned int type,
+		      char * name)
+{
+	int i;
+
+	for (i = 0; i < dev->num_resources; i++) {
+		struct resource *r = &dev->resource[i];
+
+		if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM|
+				 IORESOURCE_IRQ|IORESOURCE_DMA))
+		    == type)
+			if (!strcmp(r->name, name))
+				return r;
+	}
+	return NULL;
+}
+
+/**
+ *	platform_get_irq - get an IRQ for a device
+ *	@dev: platform device
+ *	@name: IRQ name
+ */
+int platform_get_irq_byname(struct platform_device *dev, char * name)
+{
+	struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name);
+
+	return r ? r->start : 0;
+}
+
+/**
  *	platform_add_devices - add a numbers of platform devices
  *	@devs: array of platform devices to add
  *	@num: number of platform devices in array
@@ -103,7 +139,8 @@
 	for (i = 0; i < pdev->num_resources; i++) {
 		struct resource *p, *r = &pdev->resource[i];
 
-		r->name = pdev->dev.bus_id;
+		if (r->name == NULL)
+			r->name = pdev->dev.bus_id;
 
 		p = NULL;
 		if (r->flags & IORESOURCE_MEM)
@@ -308,3 +345,5 @@
 EXPORT_SYMBOL_GPL(platform_device_unregister);
 EXPORT_SYMBOL_GPL(platform_get_irq);
 EXPORT_SYMBOL_GPL(platform_get_resource);
+EXPORT_SYMBOL_GPL(platform_get_irq_byname);
+EXPORT_SYMBOL_GPL(platform_get_resource_byname);
diff -Nru a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/include/linux/fsl_devices.h	2004-12-08 16:59:52 -06:00
@@ -0,0 +1,49 @@
+/*
+ * include/linux/fsl_devices.h
+ *
+ * Definitions for any platform device related flags or structures for 
+ * Freescale processor devices
+ *
+ * Maintainer: Kumar Gala (kumar.gala@freescale.com)
+ *
+ * Copyright 2004 Freescale Semiconductor, Inc
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#ifdef __KERNEL__
+#ifndef _FSL_DEVICE_H_
+#define _FSL_DEVICE_H_
+
+/* A table of information for supporting the Gianfar Ethernet Controller
+ * This helps identify which enet controller we are dealing with,
+ * and what type of enet controller it is
+ */
+struct gianfar_platform_data {
+	u32 flags;
+	u32 phyid;
+	uint interruptPHY;
+	uint phyregidx;
+	char * phydevice;
+	unsigned char mac_addr[6];
+};
+
+/* Flags related to gianfar device features */
+#define GIANFAR_HAS_GIGABIT		0x00000001
+#define GIANFAR_HAS_COALESCE		0x00000002
+#define GIANFAR_HAS_RMON		0x00000004
+#define GIANFAR_HAS_MULTI_INTR		0x00000008
+
+/* Flags in gianfar_platform_data */
+#define GIANFAR_PDATA_FIRM_SET_MACADDR	0x00000001
+#define GIANFAR_PDATA_HAS_PHY_INTR	0x00000002	/* if not set use a timer */
+
+/* Flags related to I2C device features */
+#define FSL_I2C_SEPARATE_DFSRR		0x00000001
+#define FSL_I2C_CLOCK_5200		0x00000002
+
+#endif	/* _FSL_DEVICE_H_ */
+#endif	/* __KERNEL__ */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Add prototypes for platform_get_resource_byname & platform_get_resource_byirq
  2004-12-08 23:16 [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq Kumar Gala
@ 2004-12-08 23:26 ` Kumar Gala
  2004-12-09  0:03 ` [RFC][PATCH] Add " Kumar Gala
  2004-12-17 22:11 ` Greg KH
  2 siblings, 0 replies; 6+ messages in thread
From: Kumar Gala @ 2004-12-08 23:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, rmk, greg

Adds the prototypes forgotten in the initial patch for 
platform_get_resource_byname & platform_get_resource_byirq.

Signed-off-by: Kumar Gala <kumar.gala@freescale.com>

--

diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h	2004-12-08 17:22:36 -06:00
+++ b/include/linux/device.h	2004-12-08 17:22:36 -06:00
@@ -382,6 +382,8 @@
 
 extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int);
 extern int platform_get_irq(struct platform_device *, unsigned int);
+extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, char *);
+extern int platform_get_irq_byname(struct platform_device *, char *);
 extern int platform_add_devices(struct platform_device **, int);
 
 extern struct platform_device *platform_device_register_simple(char *, unsigned int, struct resource *, unsigned int);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq
  2004-12-08 23:16 [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq Kumar Gala
  2004-12-08 23:26 ` [PATCH] Add prototypes for " Kumar Gala
@ 2004-12-09  0:03 ` Kumar Gala
  2004-12-17 22:11 ` Greg KH
  2 siblings, 0 replies; 6+ messages in thread
From: Kumar Gala @ 2004-12-09  0:03 UTC (permalink / raw)
  To: Linux Kernel Development; +Cc: Andrew Morton, Greg KH, Russell King

Clearly, I'm smoking crack this afternoon and can't create patches out 
of bk.  Ignore the fsl_device.h bits of the patch.

- kumar

On Dec 8, 2004, at 5:16 PM, Kumar Gala wrote:

> Adds the ability to find a resource or irq on a platform device by its
> resource name.  This patch also tweaks how resource names get set. 
> Before, resources names were set to pdev->dev.bus_id, now that only
> happens if the resource name has not been previous set.
>
> All of this allows us to find a resource without assuming what order 
> the
> resources are in.
>
> Signed-off-by; Kumar Gala <kumar.gala@freescale.com>
>
> -- 
>
>  diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
> --- a/drivers/base/platform.c   2004-12-08 16:59:52 -06:00
>  +++ b/drivers/base/platform.c   2004-12-08 16:59:52 -06:00
>  @@ -58,6 +58,42 @@
>   }
>   
>   /**
>  + *     platform_get_resource_byname - get a resource for a device by 
> name
>  + *     @dev: platform device
> + *     @type: resource type
>  + *     @name: resource name
> + */
>  +struct resource *
>  +platform_get_resource_byname(struct platform_device *dev, unsigned 
> int type,
>  +                     char * name)
>  +{
>  +       int i;
>  +
>  +       for (i = 0; i < dev->num_resources; i++) {
>  +               struct resource *r = &dev->resource[i];
>  +
>  +               if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM|
> +                                IORESOURCE_IRQ|IORESOURCE_DMA))
> +                   == type)
>  +                       if (!strcmp(r->name, name))
> +                               return r;
>  +       }
>  +       return NULL;
>  +}
>  +
>  +/**
>  + *     platform_get_irq - get an IRQ for a device
>  + *     @dev: platform device
> + *     @name: IRQ name
>  + */
>  +int platform_get_irq_byname(struct platform_device *dev, char * name)
>  +{
>  +       struct resource *r = platform_get_resource_byname(dev, 
> IORESOURCE_IRQ, name);
>  +
>  +       return r ? r->start : 0;
>  +}
>  +
>  +/**
>    *     platform_add_devices - add a numbers of platform devices
>    *     @devs: array of platform devices to add
>   *     @num: number of platform devices in array
>  @@ -103,7 +139,8 @@
>          for (i = 0; i < pdev->num_resources; i++) {
>                  struct resource *p, *r = &pdev->resource[i];
>   
>  -               r->name = pdev->dev.bus_id;
>  +               if (r->name == NULL)
>  +                       r->name = pdev->dev.bus_id;
>   
>                  p = NULL;
>                  if (r->flags & IORESOURCE_MEM)
> @@ -308,3 +345,5 @@
>   EXPORT_SYMBOL_GPL(platform_device_unregister);
>  EXPORT_SYMBOL_GPL(platform_get_irq);
>  EXPORT_SYMBOL_GPL(platform_get_resource);
> +EXPORT_SYMBOL_GPL(platform_get_irq_byname);
> +EXPORT_SYMBOL_GPL(platform_get_resource_byname);
> diff -Nru a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
> --- /dev/null   Wed Dec 31 16:00:00 196900
>  +++ b/include/linux/fsl_devices.h       2004-12-08 16:59:52 -06:00
>  @@ -0,0 +1,49 @@
>  +/*
>  + * include/linux/fsl_devices.h
> + *
>  + * Definitions for any platform device related flags or structures 
> for
> + * Freescale processor devices
>  + *
>  + * Maintainer: Kumar Gala (kumar.gala@freescale.com)
> + *
>  + * Copyright 2004 Freescale Semiconductor, Inc
>  + *
>  + * This program is free software; you can redistribute  it and/or 
> modify it
>  + * under  the terms of  the GNU General  Public License as published 
> by the
>  + * Free Software Foundation;  either version 2 of the  License, or 
> (at your
>  + * option) any later version.
>  + */
>  +
>  +#ifdef __KERNEL__
>  +#ifndef _FSL_DEVICE_H_
> +#define _FSL_DEVICE_H_
> +
>  +/* A table of information for supporting the Gianfar Ethernet 
> Controller
>  + * This helps identify which enet controller we are dealing with,
>  + * and what type of enet controller it is
>  + */
>  +struct gianfar_platform_data {
>  +       u32 flags;
>  +       u32 phyid;
>  +       uint interruptPHY;
>  +       uint phyregidx;
>  +       char * phydevice;
>  +       unsigned char mac_addr[6];
>  +};
>  +
>  +/* Flags related to gianfar device features */
>  +#define GIANFAR_HAS_GIGABIT            0x00000001
>  +#define GIANFAR_HAS_COALESCE           0x00000002
>  +#define GIANFAR_HAS_RMON               0x00000004
>  +#define GIANFAR_HAS_MULTI_INTR         0x00000008
>  +
>  +/* Flags in gianfar_platform_data */
>  +#define GIANFAR_PDATA_FIRM_SET_MACADDR 0x00000001
>  +#define GIANFAR_PDATA_HAS_PHY_INTR     0x00000002      /* if not set 
> use a timer */
>  +
>  +/* Flags related to I2C device features */
>  +#define FSL_I2C_SEPARATE_DFSRR         0x00000001
>  +#define FSL_I2C_CLOCK_5200             0x00000002
>  +
>  +#endif /* _FSL_DEVICE_H_ */
>  +#endif /* __KERNEL__ */
>  -
>  To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>  Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq
  2004-12-08 23:16 [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq Kumar Gala
  2004-12-08 23:26 ` [PATCH] Add prototypes for " Kumar Gala
  2004-12-09  0:03 ` [RFC][PATCH] Add " Kumar Gala
@ 2004-12-17 22:11 ` Greg KH
  2005-01-04 15:53   ` Kumar Gala
  2 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2004-12-17 22:11 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linux-kernel, akpm, rmk

On Wed, Dec 08, 2004 at 05:16:16PM -0600, Kumar Gala wrote:
> Adds the ability to find a resource or irq on a platform device by its 
> resource name.  This patch also tweaks how resource names get set.  
> Before, resources names were set to pdev->dev.bus_id, now that only 
> happens if the resource name has not been previous set.
> 
> All of this allows us to find a resource without assuming what order the 
> resources are in.
> 
> Signed-off-by; Kumar Gala <kumar.gala@freescale.com>

Thanks, I've applied this (minus the bogus .h file, and plus the proper
.h file change.)

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq
  2004-12-17 22:11 ` Greg KH
@ 2005-01-04 15:53   ` Kumar Gala
  2005-01-11  1:19     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Kumar Gala @ 2005-01-04 15:53 UTC (permalink / raw)
  To: Greg KH; +Cc: Kumar Gala, linux-kernel, rmk, akpm

Greg,

Any update on when these patches will go to linus or akpm.

thanks

- kumar

On Dec 17, 2004, at 4:11 PM, Greg KH wrote:

> On Wed, Dec 08, 2004 at 05:16:16PM -0600, Kumar Gala wrote:
>  > Adds the ability to find a resource or irq on a platform device by 
> its
> > resource name.  This patch also tweaks how resource names get set. 
> > Before, resources names were set to pdev->dev.bus_id, now that only
> > happens if the resource name has not been previous set.
>  >
> > All of this allows us to find a resource without assuming what order 
> the
> > resources are in.
>  >
> > Signed-off-by; Kumar Gala <kumar.gala@freescale.com>
>
> Thanks, I've applied this (minus the bogus .h file, and plus the proper
>  .h file change.)
>
> greg k-h
>  -
>  To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>  Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq
  2005-01-04 15:53   ` Kumar Gala
@ 2005-01-11  1:19     ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2005-01-11  1:19 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Kumar Gala, linux-kernel, rmk, akpm

On Tue, Jan 04, 2005 at 09:53:35AM -0600, Kumar Gala wrote:
> Greg,
> 
> Any update on when these patches will go to linus or akpm.

Due to a messup on my part, they never made it into the -mm tree, but
are now in Linus's bk tree.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-01-11  1:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-08 23:16 [RFC][PATCH] Add platform_get_resource_byname & platform_get_resource_byirq Kumar Gala
2004-12-08 23:26 ` [PATCH] Add prototypes for " Kumar Gala
2004-12-09  0:03 ` [RFC][PATCH] Add " Kumar Gala
2004-12-17 22:11 ` Greg KH
2005-01-04 15:53   ` Kumar Gala
2005-01-11  1:19     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).