LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] documentation: fix firmware_sample_firmware_class to build
@ 2008-02-19  0:22 Randy Dunlap
  2008-02-19  0:32 ` David Rientjes
  2008-02-20  6:46 ` [PATCH] documentation: fix firmware_sample_firmware_class to build Greg KH
  0 siblings, 2 replies; 12+ messages in thread
From: Randy Dunlap @ 2008-02-19  0:22 UTC (permalink / raw)
  To: lkml; +Cc: akpm

From: Randy Dunlap <randy.dunlap@oracle.com>

Fix firmware_sample_firmware_class module to build without error.
sysfs.h already has the function prototypes and has them correctly.

Documentation/firmware_class/firmware_sample_firmware_class.c:37: error: conflicting types for 'sysfs_remove_bin_file'
include/linux/sysfs.h:100: error: previous declaration of 'sysfs_remove_bin_file' was here

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 Documentation/firmware_class/firmware_sample_firmware_class.c |    3 ---
 1 file changed, 3 deletions(-)

--- linux-2625-rc2-docsrc.orig/Documentation/firmware_class/firmware_sample_firmware_class.c
+++ linux-2625-rc2-docsrc/Documentation/firmware_class/firmware_sample_firmware_class.c
@@ -33,9 +33,6 @@ struct class_device_attribute *to_class_
 	return container_of(_attr,struct class_device_attribute,attr);
 }
 
-int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-
 struct firmware_priv {
 	char fw_id[FIRMWARE_NAME_MAX];
 	s32 loading:2;

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

* Re: [PATCH] documentation: fix firmware_sample_firmware_class to build
  2008-02-19  0:22 [PATCH] documentation: fix firmware_sample_firmware_class to build Randy Dunlap
@ 2008-02-19  0:32 ` David Rientjes
  2008-02-19  0:51   ` David Rientjes
  2008-02-20  6:46 ` [PATCH] documentation: fix firmware_sample_firmware_class to build Greg KH
  1 sibling, 1 reply; 12+ messages in thread
From: David Rientjes @ 2008-02-19  0:32 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Randy Dunlap, linux-kernel

On Mon, 18 Feb 2008, Randy Dunlap wrote:

> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> Fix firmware_sample_firmware_class module to build without error.
> sysfs.h already has the function prototypes and has them correctly.
> 
> Documentation/firmware_class/firmware_sample_firmware_class.c:37: error: conflicting types for 'sysfs_remove_bin_file'
> include/linux/sysfs.h:100: error: previous declaration of 'sysfs_remove_bin_file' was here
> 
> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
> ---
>  Documentation/firmware_class/firmware_sample_firmware_class.c |    3 ---
>  1 file changed, 3 deletions(-)
> 
> --- linux-2625-rc2-docsrc.orig/Documentation/firmware_class/firmware_sample_firmware_class.c
> +++ linux-2625-rc2-docsrc/Documentation/firmware_class/firmware_sample_firmware_class.c
> @@ -33,9 +33,6 @@ struct class_device_attribute *to_class_
>  	return container_of(_attr,struct class_device_attribute,attr);
>  }
>  
> -int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
> -int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
> -
>  struct firmware_priv {
>  	char fw_id[FIRMWARE_NAME_MAX];
>  	s32 loading:2;

You'll need this as well, for the !CONFIG_SYSFS case.

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 include/linux/sysfs.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -169,8 +169,8 @@ static inline int sysfs_create_bin_file(struct kobject *kobj,
 	return 0;
 }
 
-static inline int sysfs_remove_bin_file(struct kobject *kobj,
-					struct bin_attribute *attr)
+static inline void sysfs_remove_bin_file(struct kobject *kobj,
+					 struct bin_attribute *attr)
 {
 	return 0;
 }

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

* Re: [PATCH] documentation: fix firmware_sample_firmware_class to build
  2008-02-19  0:32 ` David Rientjes
@ 2008-02-19  0:51   ` David Rientjes
  2008-02-19 22:40     ` Randy Dunlap
  0 siblings, 1 reply; 12+ messages in thread
From: David Rientjes @ 2008-02-19  0:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Randy Dunlap, linux-kernel

Change sysfs_remove_bin_file() to have a return value of void in the 
!CONFIG_SYSFS case, matching the return value of the same function with 
the opposite configuration.

Also moves unnecessary ';' in empty void functions.

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 include/linux/sysfs.h |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -93,7 +93,7 @@ int __must_check sysfs_create_file(struct kobject *kobj,
 				   const struct attribute *attr);
 int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr,
 				  mode_t mode);
-void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
+void wsysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
 
 int __must_check sysfs_create_bin_file(struct kobject *kobj,
 				       struct bin_attribute *attr);
@@ -131,7 +131,6 @@ static inline int sysfs_create_dir(struct kobject *kobj)
 
 static inline void sysfs_remove_dir(struct kobject *kobj)
 {
-	;
 }
 
 static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
@@ -160,7 +159,6 @@ static inline int sysfs_chmod_file(struct kobject *kobj,
 static inline void sysfs_remove_file(struct kobject *kobj,
 				     const struct attribute *attr)
 {
-	;
 }
 
 static inline int sysfs_create_bin_file(struct kobject *kobj,
@@ -169,10 +167,9 @@ static inline int sysfs_create_bin_file(struct kobject *kobj,
 	return 0;
 }
 
-static inline int sysfs_remove_bin_file(struct kobject *kobj,
-					struct bin_attribute *attr)
+static inline void sysfs_remove_bin_file(struct kobject *kobj,
+					 struct bin_attribute *attr)
 {
-	return 0;
 }
 
 static inline int sysfs_create_link(struct kobject *kobj,
@@ -183,7 +180,6 @@ static inline int sysfs_create_link(struct kobject *kobj,
 
 static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
 {
-	;
 }
 
 static inline int sysfs_create_group(struct kobject *kobj,
@@ -195,7 +191,6 @@ static inline int sysfs_create_group(struct kobject *kobj,
 static inline void sysfs_remove_group(struct kobject *kobj,
 				      const struct attribute_group *grp)
 {
-	;
 }
 
 static inline int sysfs_add_file_to_group(struct kobject *kobj,

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

* Re: [PATCH] documentation: fix firmware_sample_firmware_class to build
  2008-02-19  0:51   ` David Rientjes
@ 2008-02-19 22:40     ` Randy Dunlap
  2008-02-20  1:39       ` [patch] sysfs: small header file cleanup David Rientjes
  0 siblings, 1 reply; 12+ messages in thread
From: Randy Dunlap @ 2008-02-19 22:40 UTC (permalink / raw)
  To: David Rientjes; +Cc: Andrew Morton, linux-kernel

On Mon, 18 Feb 2008 16:51:31 -0800 (PST) David Rientjes wrote:

> Change sysfs_remove_bin_file() to have a return value of void in the 
> !CONFIG_SYSFS case, matching the return value of the same function with 
> the opposite configuration.
> 
> Also moves unnecessary ';' in empty void functions.
> 
> Cc: Randy Dunlap <randy.dunlap@oracle.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  include/linux/sysfs.h |   11 +++--------
>  1 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -93,7 +93,7 @@ int __must_check sysfs_create_file(struct kobject *kobj,
>  				   const struct attribute *attr);
>  int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr,
>  				  mode_t mode);
> -void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
> +void wsysfs_remove_file(struct kobject *kobj, const struct attribute *attr);

Please explain the change above.  I don't get it...

>  
>  int __must_check sysfs_create_bin_file(struct kobject *kobj,
>  				       struct bin_attribute *attr);
> @@ -131,7 +131,6 @@ static inline int sysfs_create_dir(struct kobject *kobj)
>  
>  static inline void sysfs_remove_dir(struct kobject *kobj)
>  {
> -	;
>  }
>  
>  static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
> @@ -160,7 +159,6 @@ static inline int sysfs_chmod_file(struct kobject *kobj,
>  static inline void sysfs_remove_file(struct kobject *kobj,
>  				     const struct attribute *attr)
>  {
> -	;
>  }
>  
>  static inline int sysfs_create_bin_file(struct kobject *kobj,
> @@ -169,10 +167,9 @@ static inline int sysfs_create_bin_file(struct kobject *kobj,
>  	return 0;
>  }
>  
> -static inline int sysfs_remove_bin_file(struct kobject *kobj,
> -					struct bin_attribute *attr)
> +static inline void sysfs_remove_bin_file(struct kobject *kobj,
> +					 struct bin_attribute *attr)
>  {
> -	return 0;
>  }
>  
>  static inline int sysfs_create_link(struct kobject *kobj,
> @@ -183,7 +180,6 @@ static inline int sysfs_create_link(struct kobject *kobj,
>  
>  static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
>  {
> -	;
>  }
>  
>  static inline int sysfs_create_group(struct kobject *kobj,
> @@ -195,7 +191,6 @@ static inline int sysfs_create_group(struct kobject *kobj,
>  static inline void sysfs_remove_group(struct kobject *kobj,
>  				      const struct attribute_group *grp)
>  {
> -	;
>  }
>  
>  static inline int sysfs_add_file_to_group(struct kobject *kobj,


---
~Randy

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

* [patch] sysfs: small header file cleanup
  2008-02-19 22:40     ` Randy Dunlap
@ 2008-02-20  1:39       ` David Rientjes
  2008-02-20  4:17         ` Randy Dunlap
  0 siblings, 1 reply; 12+ messages in thread
From: David Rientjes @ 2008-02-20  1:39 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Randy Dunlap, linux-kernel

Convert sysfs_remove_bin_file() to have a return type of 'void' for
!CONFIG_SYSFS configurations.  Also removes unnecessary colons from empty
void functions.

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 include/linux/sysfs.h |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -131,7 +131,6 @@ static inline int sysfs_create_dir(struct kobject *kobj)
 
 static inline void sysfs_remove_dir(struct kobject *kobj)
 {
-	;
 }
 
 static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
@@ -160,7 +159,6 @@ static inline int sysfs_chmod_file(struct kobject *kobj,
 static inline void sysfs_remove_file(struct kobject *kobj,
 				     const struct attribute *attr)
 {
-	;
 }
 
 static inline int sysfs_create_bin_file(struct kobject *kobj,
@@ -169,10 +167,9 @@ static inline int sysfs_create_bin_file(struct kobject *kobj,
 	return 0;
 }
 
-static inline int sysfs_remove_bin_file(struct kobject *kobj,
-					struct bin_attribute *attr)
+static inline void sysfs_remove_bin_file(struct kobject *kobj,
+					 struct bin_attribute *attr)
 {
-	return 0;
 }
 
 static inline int sysfs_create_link(struct kobject *kobj,
@@ -183,7 +180,6 @@ static inline int sysfs_create_link(struct kobject *kobj,
 
 static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
 {
-	;
 }
 
 static inline int sysfs_create_group(struct kobject *kobj,
@@ -195,7 +191,6 @@ static inline int sysfs_create_group(struct kobject *kobj,
 static inline void sysfs_remove_group(struct kobject *kobj,
 				      const struct attribute_group *grp)
 {
-	;
 }
 
 static inline int sysfs_add_file_to_group(struct kobject *kobj,

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

* Re: [patch] sysfs: small header file cleanup
  2008-02-20  1:39       ` [patch] sysfs: small header file cleanup David Rientjes
@ 2008-02-20  4:17         ` Randy Dunlap
  0 siblings, 0 replies; 12+ messages in thread
From: Randy Dunlap @ 2008-02-20  4:17 UTC (permalink / raw)
  To: David Rientjes; +Cc: Andrew Morton, linux-kernel

David Rientjes wrote:
> Convert sysfs_remove_bin_file() to have a return type of 'void' for
> !CONFIG_SYSFS configurations.  Also removes unnecessary colons from empty
> void functions.
> 
> Cc: Randy Dunlap <randy.dunlap@oracle.com>

Reviewed-by: Randy Dunlap <randy.dunlap@oracle.com>

Thanks, David.

> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  include/linux/sysfs.h |    9 ++-------
>  1 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -131,7 +131,6 @@ static inline int sysfs_create_dir(struct kobject *kobj)
>  
>  static inline void sysfs_remove_dir(struct kobject *kobj)
>  {
> -	;
>  }
>  
>  static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
> @@ -160,7 +159,6 @@ static inline int sysfs_chmod_file(struct kobject *kobj,
>  static inline void sysfs_remove_file(struct kobject *kobj,
>  				     const struct attribute *attr)
>  {
> -	;
>  }
>  
>  static inline int sysfs_create_bin_file(struct kobject *kobj,
> @@ -169,10 +167,9 @@ static inline int sysfs_create_bin_file(struct kobject *kobj,
>  	return 0;
>  }
>  
> -static inline int sysfs_remove_bin_file(struct kobject *kobj,
> -					struct bin_attribute *attr)
> +static inline void sysfs_remove_bin_file(struct kobject *kobj,
> +					 struct bin_attribute *attr)
>  {
> -	return 0;
>  }
>  
>  static inline int sysfs_create_link(struct kobject *kobj,
> @@ -183,7 +180,6 @@ static inline int sysfs_create_link(struct kobject *kobj,
>  
>  static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
>  {
> -	;
>  }
>  
>  static inline int sysfs_create_group(struct kobject *kobj,
> @@ -195,7 +191,6 @@ static inline int sysfs_create_group(struct kobject *kobj,
>  static inline void sysfs_remove_group(struct kobject *kobj,
>  				      const struct attribute_group *grp)
>  {
> -	;
>  }
>  
>  static inline int sysfs_add_file_to_group(struct kobject *kobj,


-- 
~Randy

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

* Re: [PATCH] documentation: fix firmware_sample_firmware_class to build
  2008-02-19  0:22 [PATCH] documentation: fix firmware_sample_firmware_class to build Randy Dunlap
  2008-02-19  0:32 ` David Rientjes
@ 2008-02-20  6:46 ` Greg KH
  2008-02-20 20:10   ` Randy Dunlap
  1 sibling, 1 reply; 12+ messages in thread
From: Greg KH @ 2008-02-20  6:46 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: lkml, akpm

On Mon, Feb 18, 2008 at 04:22:16PM -0800, Randy Dunlap wrote:
> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> Fix firmware_sample_firmware_class module to build without error.
> sysfs.h already has the function prototypes and has them correctly.
> 
> Documentation/firmware_class/firmware_sample_firmware_class.c:37: error: conflicting types for 'sysfs_remove_bin_file'
> include/linux/sysfs.h:100: error: previous declaration of 'sysfs_remove_bin_file' was here
> 
> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
> ---
>  Documentation/firmware_class/firmware_sample_firmware_class.c |    3 ---
>  1 file changed, 3 deletions(-)

Can we move this file to the samples/ directory, so the build will catch
stuff like this?

What's the final version of this patch?

thanks,

greg k-h

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

* Re: [PATCH] documentation: fix firmware_sample_firmware_class to build
  2008-02-20  6:46 ` [PATCH] documentation: fix firmware_sample_firmware_class to build Greg KH
@ 2008-02-20 20:10   ` Randy Dunlap
  2008-02-20 20:40     ` Greg KH
  0 siblings, 1 reply; 12+ messages in thread
From: Randy Dunlap @ 2008-02-20 20:10 UTC (permalink / raw)
  To: Greg KH; +Cc: lkml, akpm

Greg KH wrote:
> On Mon, Feb 18, 2008 at 04:22:16PM -0800, Randy Dunlap wrote:
>> From: Randy Dunlap <randy.dunlap@oracle.com>
>>
>> Fix firmware_sample_firmware_class module to build without error.
>> sysfs.h already has the function prototypes and has them correctly.
>>
>> Documentation/firmware_class/firmware_sample_firmware_class.c:37: error: conflicting types for 'sysfs_remove_bin_file'
>> include/linux/sysfs.h:100: error: previous declaration of 'sysfs_remove_bin_file' was here
>>
>> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
>> ---
>>  Documentation/firmware_class/firmware_sample_firmware_class.c |    3 ---
>>  1 file changed, 3 deletions(-)
> 
> Can we move this file to the samples/ directory, so the build will catch
> stuff like this?
> 
> What's the final version of this patch?

I've moved it to samples/, but it (still) has a build problem:

ERROR: "firmware_class" [samples/firmware_class/firmware_sample_firmware_class.ko] undefined!

Can you give me hint(s) about how to fix that?

-- 
~Randy

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

* Re: [PATCH] documentation: fix firmware_sample_firmware_class to build
  2008-02-20 20:10   ` Randy Dunlap
@ 2008-02-20 20:40     ` Greg KH
  2008-02-20 21:20       ` [PATCH 1/2] firmware: move firmware_class from Documentation/ to samples/ Randy Dunlap
  0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2008-02-20 20:40 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: lkml, akpm

On Wed, Feb 20, 2008 at 12:10:36PM -0800, Randy Dunlap wrote:
> Greg KH wrote:
>> On Mon, Feb 18, 2008 at 04:22:16PM -0800, Randy Dunlap wrote:
>>> From: Randy Dunlap <randy.dunlap@oracle.com>
>>>
>>> Fix firmware_sample_firmware_class module to build without error.
>>> sysfs.h already has the function prototypes and has them correctly.
>>>
>>> Documentation/firmware_class/firmware_sample_firmware_class.c:37: error: 
>>> conflicting types for 'sysfs_remove_bin_file'
>>> include/linux/sysfs.h:100: error: previous declaration of 
>>> 'sysfs_remove_bin_file' was here
>>>
>>> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
>>> ---
>>>  Documentation/firmware_class/firmware_sample_firmware_class.c |    3 ---
>>>  1 file changed, 3 deletions(-)
>> Can we move this file to the samples/ directory, so the build will catch
>> stuff like this?
>> What's the final version of this patch?
>
> I've moved it to samples/, but it (still) has a build problem:
>
> ERROR: "firmware_class" 
> [samples/firmware_class/firmware_sample_firmware_class.ko] undefined!
>
> Can you give me hint(s) about how to fix that?

Ah, yeah, that class went away a while ago.

Care to send me the patch you have, and I'll be glad to fix it up and
get it in?

thanks,

greg k-h

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

* [PATCH 1/2] firmware: move firmware_class from Documentation/ to samples/
  2008-02-20 20:40     ` Greg KH
@ 2008-02-20 21:20       ` Randy Dunlap
  2008-02-20 21:48         ` Marcel Holtmann
  2008-02-21  0:07         ` patch firmware-move-firmware_class-from-documentation-to-samples.patch added to gregkh-2.6 tree gregkh
  0 siblings, 2 replies; 12+ messages in thread
From: Randy Dunlap @ 2008-02-20 21:20 UTC (permalink / raw)
  To: Greg KH; +Cc: lkml, akpm

From: Randy Dunlap <randy.dunlap@oracle.com>

Move the firmware_class sample drivers to samples/ so that they are
buildable and can be maintained.  Add Kconfig entry for firmware_class.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 Documentation/firmware_class/firmware_sample_driver.c         |  115 -----
 Documentation/firmware_class/firmware_sample_firmware_class.c |  207 ----------
 samples/Kconfig                                               |    8 
 samples/Makefile                                              |    2 
 samples/firmware_class/Makefile                               |    1 
 samples/firmware_class/firmware_sample_driver.c               |  115 +++++
 samples/firmware_class/firmware_sample_firmware_class.c       |  207 ++++++++++
 7 files changed, 332 insertions(+), 323 deletions(-)

--- linux-2625-rc2-docsrc.orig/Documentation/firmware_class/firmware_sample_driver.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * firmware_sample_driver.c -
- *
- * Copyright (c) 2003 Manuel Estrada Sainz
- *
- * Sample code on how to use request_firmware() from drivers.
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/string.h>
-
-#include "linux/firmware.h"
-
-static struct device ghost_device = {
-	.bus_id    = "ghost0",
-};
-
-
-static void sample_firmware_load(char *firmware, int size)
-{
-	u8 buf[size+1];
-	memcpy(buf, firmware, size);
-	buf[size] = '\0';
-	printk(KERN_INFO "firmware_sample_driver: firmware: %s\n", buf);
-}
-
-static void sample_probe_default(void)
-{
-	/* uses the default method to get the firmware */
-        const struct firmware *fw_entry;
-	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
-
-        if(request_firmware(&fw_entry, "sample_driver_fw", &ghost_device)!=0)
-	{
-		printk(KERN_ERR
-		       "firmware_sample_driver: Firmware not available\n");
-		return;
-	}
-	
-	sample_firmware_load(fw_entry->data, fw_entry->size);
-
-	release_firmware(fw_entry);
-
-	/* finish setting up the device */
-}
-static void sample_probe_specific(void)
-{
-	/* Uses some specific hotplug support to get the firmware from
-	 * userspace  directly into the hardware, or via some sysfs file */
-
-	/* NOTE: This currently doesn't work */
-
-	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
-
-        if(request_firmware(NULL, "sample_driver_fw", &ghost_device)!=0)
-	{
-		printk(KERN_ERR
-		       "firmware_sample_driver: Firmware load failed\n");
-		return;
-	}
-	
-	/* request_firmware blocks until userspace finished, so at
-	 * this point the firmware should be already in the device */
-
-	/* finish setting up the device */
-}
-static void sample_probe_async_cont(const struct firmware *fw, void *context)
-{
-	if(!fw){
-		printk(KERN_ERR
-		       "firmware_sample_driver: firmware load failed\n");
-		return;
-	}
-
-	printk(KERN_INFO "firmware_sample_driver: device pointer \"%s\"\n",
-	       (char *)context);
-	sample_firmware_load(fw->data, fw->size);
-}
-static void sample_probe_async(void)
-{
-	/* Let's say that I can't sleep */
-	int error;
-	error = request_firmware_nowait (THIS_MODULE, FW_ACTION_NOHOTPLUG,
-					 "sample_driver_fw", &ghost_device,
-					 "my device pointer",
-					 sample_probe_async_cont);
-	if(error){
-		printk(KERN_ERR 
-		       "firmware_sample_driver:"
-		       " request_firmware_nowait failed\n");
-	}
-}
-
-static int sample_init(void)
-{
-	device_initialize(&ghost_device);
-	/* since there is no real hardware insertion I just call the
-	 * sample probe functions here */
-	sample_probe_specific();
-	sample_probe_default();
-	sample_probe_async();
-	return 0;
-}
-static void __exit sample_exit(void)
-{
-}
-
-module_init (sample_init);
-module_exit (sample_exit);
-
-MODULE_LICENSE("GPL");
--- linux-2625-rc2-docsrc.orig/Documentation/firmware_class/firmware_sample_firmware_class.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * firmware_sample_firmware_class.c -
- *
- * Copyright (c) 2003 Manuel Estrada Sainz
- *
- * NOTE: This is just a probe of concept, if you think that your driver would
- * be well served by this mechanism please contact me first.
- *
- * DON'T USE THIS CODE AS IS
- *
- */
-
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/firmware.h>
-
-
-MODULE_AUTHOR("Manuel Estrada Sainz");
-MODULE_DESCRIPTION("Hackish sample for using firmware class directly");
-MODULE_LICENSE("GPL");
-
-static inline struct class_device *to_class_dev(struct kobject *obj)
-{
-	return container_of(obj,struct class_device,kobj);
-}
-static inline
-struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
-{
-	return container_of(_attr,struct class_device_attribute,attr);
-}
-
-int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-
-struct firmware_priv {
-	char fw_id[FIRMWARE_NAME_MAX];
-	s32 loading:2;
-	u32 abort:1;
-};
-
-extern struct class firmware_class;
-
-static ssize_t firmware_loading_show(struct class_device *class_dev, char *buf)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-	return sprintf(buf, "%d\n", fw_priv->loading);
-}
-static ssize_t firmware_loading_store(struct class_device *class_dev,
-				      const char *buf, size_t count)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-	int prev_loading = fw_priv->loading;
-
-	fw_priv->loading = simple_strtol(buf, NULL, 10);
-	
-	switch(fw_priv->loading){
-	case -1:
-		/* abort load an panic */
-		break;
-	case 1:
-		/* setup load */
-		break;
-	case 0:
-		if(prev_loading==1){
-			/* finish load and get the device back to working
-			 * state */
-		}
-		break;
-	}
-
-	return count;
-}
-static CLASS_DEVICE_ATTR(loading, 0644,
-			 firmware_loading_show, firmware_loading_store);
-
-static ssize_t firmware_data_read(struct kobject *kobj,
-				  struct bin_attribute *bin_attr,
-				  char *buffer, loff_t offset, size_t count)
-{
-	struct class_device *class_dev = to_class_dev(kobj);
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-
-	/* read from the devices firmware memory */
-
-	return count;
-}
-static ssize_t firmware_data_write(struct kobject *kobj,
-				   struct bin_attribute *bin_attr,
-				   char *buffer, loff_t offset, size_t count)
-{
-	struct class_device *class_dev = to_class_dev(kobj);
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-
-	/* write to the devices firmware memory */
-
-	return count;
-}
-static struct bin_attribute firmware_attr_data = {
-	.attr = {.name = "data", .mode = 0644},
-	.size = 0,
-	.read = firmware_data_read,
-	.write = firmware_data_write,
-};
-static int fw_setup_class_device(struct class_device *class_dev,
-				 const char *fw_name,
-				 struct device *device)
-{
-	int retval;
-	struct firmware_priv *fw_priv;
-
-	fw_priv = kzalloc(sizeof(struct firmware_priv),	GFP_KERNEL);
-	if (!fw_priv) {
-		retval = -ENOMEM;
-		goto out;
-	}
-
-	memset(class_dev, 0, sizeof(*class_dev));
-
-	strncpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX);
-	fw_priv->fw_id[FIRMWARE_NAME_MAX-1] = '\0';
-
-	strncpy(class_dev->class_id, device->bus_id, BUS_ID_SIZE);
-	class_dev->class_id[BUS_ID_SIZE-1] = '\0';
-	class_dev->dev = device;
-
-	class_dev->class = &firmware_class,
-	class_set_devdata(class_dev, fw_priv);
-	retval = class_device_register(class_dev);
-	if (retval){
-		printk(KERN_ERR "%s: class_device_register failed\n",
-		       __FUNCTION__);
-		goto error_free_fw_priv;
-	}
-
-	retval = sysfs_create_bin_file(&class_dev->kobj, &firmware_attr_data);
-	if (retval){
-		printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
-		       __FUNCTION__);
-		goto error_unreg_class_dev;
-	}
-
-	retval = class_device_create_file(class_dev,
-					  &class_device_attr_loading);
-	if (retval){
-		printk(KERN_ERR "%s: class_device_create_file failed\n",
-		       __FUNCTION__);
-		goto error_remove_data;
-	}
-
-	goto out;
-	
-error_remove_data:
-	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
-error_unreg_class_dev:
-	class_device_unregister(class_dev);
-error_free_fw_priv:
-	kfree(fw_priv);
-out:
-	return retval;
-}
-static void fw_remove_class_device(struct class_device *class_dev)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-
-	class_device_remove_file(class_dev, &class_device_attr_loading);
-	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
-	class_device_unregister(class_dev);
-}
-
-static struct class_device *class_dev;
-
-static struct device my_device = {
-	.bus_id    = "my_dev0",
-};
-
-static int __init firmware_sample_init(void)
-{
-	int error;
-
-	device_initialize(&my_device);
-	class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
-	if(!class_dev)
-		return -ENOMEM;
-
-	error = fw_setup_class_device(class_dev, "my_firmware_image",
-				      &my_device);
-	if(error){
-		kfree(class_dev);
-		return error;
-	}
-        return 0;
-
-}
-static void __exit firmware_sample_exit(void)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-	fw_remove_class_device(class_dev);
-	kfree(fw_priv);
-	kfree(class_dev);
-}
-module_init(firmware_sample_init);
-module_exit(firmware_sample_exit);
-
--- /dev/null
+++ linux-2625-rc2-docsrc/samples/firmware_class/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_SAMPLE_FIRMWARE_CLASS) += firmware_sample_driver.o firmware_sample_firmware_class.o
--- /dev/null
+++ linux-2625-rc2-docsrc/samples/firmware_class/firmware_sample_driver.c
@@ -0,0 +1,115 @@
+/*
+ * firmware_sample_driver.c -
+ *
+ * Copyright (c) 2003 Manuel Estrada Sainz
+ *
+ * Sample code on how to use request_firmware() from drivers.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/string.h>
+
+#include "linux/firmware.h"
+
+static struct device ghost_device = {
+	.bus_id    = "ghost0",
+};
+
+
+static void sample_firmware_load(char *firmware, int size)
+{
+	u8 buf[size+1];
+	memcpy(buf, firmware, size);
+	buf[size] = '\0';
+	printk(KERN_INFO "firmware_sample_driver: firmware: %s\n", buf);
+}
+
+static void sample_probe_default(void)
+{
+	/* uses the default method to get the firmware */
+        const struct firmware *fw_entry;
+	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
+
+        if(request_firmware(&fw_entry, "sample_driver_fw", &ghost_device)!=0)
+	{
+		printk(KERN_ERR
+		       "firmware_sample_driver: Firmware not available\n");
+		return;
+	}
+
+	sample_firmware_load(fw_entry->data, fw_entry->size);
+
+	release_firmware(fw_entry);
+
+	/* finish setting up the device */
+}
+static void sample_probe_specific(void)
+{
+	/* Uses some specific hotplug support to get the firmware from
+	 * userspace  directly into the hardware, or via some sysfs file */
+
+	/* NOTE: This currently doesn't work */
+
+	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
+
+        if(request_firmware(NULL, "sample_driver_fw", &ghost_device)!=0)
+	{
+		printk(KERN_ERR
+		       "firmware_sample_driver: Firmware load failed\n");
+		return;
+	}
+
+	/* request_firmware blocks until userspace finished, so at
+	 * this point the firmware should be already in the device */
+
+	/* finish setting up the device */
+}
+static void sample_probe_async_cont(const struct firmware *fw, void *context)
+{
+	if(!fw){
+		printk(KERN_ERR
+		       "firmware_sample_driver: firmware load failed\n");
+		return;
+	}
+
+	printk(KERN_INFO "firmware_sample_driver: device pointer \"%s\"\n",
+	       (char *)context);
+	sample_firmware_load(fw->data, fw->size);
+}
+static void sample_probe_async(void)
+{
+	/* Let's say that I can't sleep */
+	int error;
+	error = request_firmware_nowait (THIS_MODULE, FW_ACTION_NOHOTPLUG,
+					 "sample_driver_fw", &ghost_device,
+					 "my device pointer",
+					 sample_probe_async_cont);
+	if(error){
+		printk(KERN_ERR
+		       "firmware_sample_driver:"
+		       " request_firmware_nowait failed\n");
+	}
+}
+
+static int sample_init(void)
+{
+	device_initialize(&ghost_device);
+	/* since there is no real hardware insertion I just call the
+	 * sample probe functions here */
+	sample_probe_specific();
+	sample_probe_default();
+	sample_probe_async();
+	return 0;
+}
+static void __exit sample_exit(void)
+{
+}
+
+module_init (sample_init);
+module_exit (sample_exit);
+
+MODULE_LICENSE("GPL");
--- /dev/null
+++ linux-2625-rc2-docsrc/samples/firmware_class/firmware_sample_firmware_class.c
@@ -0,0 +1,207 @@
+/*
+ * firmware_sample_firmware_class.c -
+ *
+ * Copyright (c) 2003 Manuel Estrada Sainz
+ *
+ * NOTE: This is just a probe of concept, if you think that your driver would
+ * be well served by this mechanism please contact me first.
+ *
+ * DON'T USE THIS CODE AS IS
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/timer.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/firmware.h>
+
+
+MODULE_AUTHOR("Manuel Estrada Sainz");
+MODULE_DESCRIPTION("Hackish sample for using firmware class directly");
+MODULE_LICENSE("GPL");
+
+static inline struct class_device *to_class_dev(struct kobject *obj)
+{
+	return container_of(obj,struct class_device,kobj);
+}
+static inline
+struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
+{
+	return container_of(_attr,struct class_device_attribute,attr);
+}
+
+int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
+int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
+
+struct firmware_priv {
+	char fw_id[FIRMWARE_NAME_MAX];
+	s32 loading:2;
+	u32 abort:1;
+};
+
+extern struct class firmware_class;
+
+static ssize_t firmware_loading_show(struct class_device *class_dev, char *buf)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	return sprintf(buf, "%d\n", fw_priv->loading);
+}
+static ssize_t firmware_loading_store(struct class_device *class_dev,
+				      const char *buf, size_t count)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	int prev_loading = fw_priv->loading;
+
+	fw_priv->loading = simple_strtol(buf, NULL, 10);
+
+	switch(fw_priv->loading){
+	case -1:
+		/* abort load an panic */
+		break;
+	case 1:
+		/* setup load */
+		break;
+	case 0:
+		if(prev_loading==1){
+			/* finish load and get the device back to working
+			 * state */
+		}
+		break;
+	}
+
+	return count;
+}
+static CLASS_DEVICE_ATTR(loading, 0644,
+			 firmware_loading_show, firmware_loading_store);
+
+static ssize_t firmware_data_read(struct kobject *kobj,
+				  struct bin_attribute *bin_attr,
+				  char *buffer, loff_t offset, size_t count)
+{
+	struct class_device *class_dev = to_class_dev(kobj);
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+
+	/* read from the devices firmware memory */
+
+	return count;
+}
+static ssize_t firmware_data_write(struct kobject *kobj,
+				   struct bin_attribute *bin_attr,
+				   char *buffer, loff_t offset, size_t count)
+{
+	struct class_device *class_dev = to_class_dev(kobj);
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+
+	/* write to the devices firmware memory */
+
+	return count;
+}
+static struct bin_attribute firmware_attr_data = {
+	.attr = {.name = "data", .mode = 0644},
+	.size = 0,
+	.read = firmware_data_read,
+	.write = firmware_data_write,
+};
+static int fw_setup_class_device(struct class_device *class_dev,
+				 const char *fw_name,
+				 struct device *device)
+{
+	int retval;
+	struct firmware_priv *fw_priv;
+
+	fw_priv = kzalloc(sizeof(struct firmware_priv),	GFP_KERNEL);
+	if (!fw_priv) {
+		retval = -ENOMEM;
+		goto out;
+	}
+
+	memset(class_dev, 0, sizeof(*class_dev));
+
+	strncpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX);
+	fw_priv->fw_id[FIRMWARE_NAME_MAX-1] = '\0';
+
+	strncpy(class_dev->class_id, device->bus_id, BUS_ID_SIZE);
+	class_dev->class_id[BUS_ID_SIZE-1] = '\0';
+	class_dev->dev = device;
+
+	class_dev->class = &firmware_class,
+	class_set_devdata(class_dev, fw_priv);
+	retval = class_device_register(class_dev);
+	if (retval){
+		printk(KERN_ERR "%s: class_device_register failed\n",
+		       __FUNCTION__);
+		goto error_free_fw_priv;
+	}
+
+	retval = sysfs_create_bin_file(&class_dev->kobj, &firmware_attr_data);
+	if (retval){
+		printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
+		       __FUNCTION__);
+		goto error_unreg_class_dev;
+	}
+
+	retval = class_device_create_file(class_dev,
+					  &class_device_attr_loading);
+	if (retval){
+		printk(KERN_ERR "%s: class_device_create_file failed\n",
+		       __FUNCTION__);
+		goto error_remove_data;
+	}
+
+	goto out;
+
+error_remove_data:
+	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
+error_unreg_class_dev:
+	class_device_unregister(class_dev);
+error_free_fw_priv:
+	kfree(fw_priv);
+out:
+	return retval;
+}
+static void fw_remove_class_device(struct class_device *class_dev)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+
+	class_device_remove_file(class_dev, &class_device_attr_loading);
+	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
+	class_device_unregister(class_dev);
+}
+
+static struct class_device *class_dev;
+
+static struct device my_device = {
+	.bus_id    = "my_dev0",
+};
+
+static int __init firmware_sample_init(void)
+{
+	int error;
+
+	device_initialize(&my_device);
+	class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
+	if(!class_dev)
+		return -ENOMEM;
+
+	error = fw_setup_class_device(class_dev, "my_firmware_image",
+				      &my_device);
+	if(error){
+		kfree(class_dev);
+		return error;
+	}
+        return 0;
+
+}
+static void __exit firmware_sample_exit(void)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	fw_remove_class_device(class_dev);
+	kfree(fw_priv);
+	kfree(class_dev);
+}
+
+module_init(firmware_sample_init);
+module_exit(firmware_sample_exit);
--- linux-2625-rc2-docsrc.orig/samples/Makefile
+++ linux-2625-rc2-docsrc/samples/Makefile
@@ -1,3 +1,3 @@
 # Makefile for Linux samples code
 
-obj-$(CONFIG_SAMPLES)	+= markers/ kobject/
+obj-$(CONFIG_SAMPLES)	+= markers/ kobject/ firmware_class/
--- linux-2625-rc2-docsrc.orig/samples/Kconfig
+++ linux-2625-rc2-docsrc/samples/Kconfig
@@ -22,5 +22,13 @@ config SAMPLE_KOBJECT
 
 	  If in doubt, say "N" here.
 
+config SAMPLE_FIRMWARE_CLASS
+	tristate "Build firmware_class examples -- loadable modules only"
+	depends on FW_LOADER && m
+	help
+	  This build firmware_class example modules.
+
+	  If in doubt, say "N" here.
+
 endif # SAMPLES
 

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

* Re: [PATCH 1/2] firmware: move firmware_class from Documentation/ to samples/
  2008-02-20 21:20       ` [PATCH 1/2] firmware: move firmware_class from Documentation/ to samples/ Randy Dunlap
@ 2008-02-20 21:48         ` Marcel Holtmann
  2008-02-21  0:07         ` patch firmware-move-firmware_class-from-documentation-to-samples.patch added to gregkh-2.6 tree gregkh
  1 sibling, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2008-02-20 21:48 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: Greg KH, lkml, akpm

Hi Randy,

> Move the firmware_class sample drivers to samples/ so that they are
> buildable and can be maintained.  Add Kconfig entry for  
> firmware_class.
>
> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>

this is a good idea.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


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

* patch firmware-move-firmware_class-from-documentation-to-samples.patch added to gregkh-2.6 tree
  2008-02-20 21:20       ` [PATCH 1/2] firmware: move firmware_class from Documentation/ to samples/ Randy Dunlap
  2008-02-20 21:48         ` Marcel Holtmann
@ 2008-02-21  0:07         ` gregkh
  1 sibling, 0 replies; 12+ messages in thread
From: gregkh @ 2008-02-21  0:07 UTC (permalink / raw)
  To: randy.dunlap, akpm, greg, gregkh, linux-kernel, marcel


This is a note to let you know that I've just added the patch titled

     Subject: firmware: move firmware_class from Documentation/ to samples/

to my gregkh-2.6 tree.  Its filename is

     firmware-move-firmware_class-from-documentation-to-samples.patch

This tree can be found at 
    http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From randy.dunlap@oracle.com  Wed Feb 20 14:33:28 2008
From: Randy Dunlap <randy.dunlap@oracle.com>
Date: Wed, 20 Feb 2008 13:20:50 -0800
Subject: firmware: move firmware_class from Documentation/ to samples/
To: Greg KH <greg@kroah.com>
Cc: lkml <linux-kernel@vger.kernel.org>, akpm <akpm@linux-foundation.org>
Message-ID: <20080220132050.8f1dac05.randy.dunlap@oracle.com>


From: Randy Dunlap <randy.dunlap@oracle.com>

Move the firmware_class sample drivers to samples/ so that they are
buildable and can be maintained.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 Documentation/firmware_class/firmware_sample_driver.c         |  115 -----
 Documentation/firmware_class/firmware_sample_firmware_class.c |  207 ----------
 samples/firmware_class/firmware_sample_driver.c               |  115 +++++
 samples/firmware_class/firmware_sample_firmware_class.c       |  207 ++++++++++
 4 files changed, 322 insertions(+), 322 deletions(-)

--- a/Documentation/firmware_class/firmware_sample_driver.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * firmware_sample_driver.c -
- *
- * Copyright (c) 2003 Manuel Estrada Sainz
- *
- * Sample code on how to use request_firmware() from drivers.
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/string.h>
-
-#include "linux/firmware.h"
-
-static struct device ghost_device = {
-	.bus_id    = "ghost0",
-};
-
-
-static void sample_firmware_load(char *firmware, int size)
-{
-	u8 buf[size+1];
-	memcpy(buf, firmware, size);
-	buf[size] = '\0';
-	printk(KERN_INFO "firmware_sample_driver: firmware: %s\n", buf);
-}
-
-static void sample_probe_default(void)
-{
-	/* uses the default method to get the firmware */
-        const struct firmware *fw_entry;
-	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
-
-        if(request_firmware(&fw_entry, "sample_driver_fw", &ghost_device)!=0)
-	{
-		printk(KERN_ERR
-		       "firmware_sample_driver: Firmware not available\n");
-		return;
-	}
-	
-	sample_firmware_load(fw_entry->data, fw_entry->size);
-
-	release_firmware(fw_entry);
-
-	/* finish setting up the device */
-}
-static void sample_probe_specific(void)
-{
-	/* Uses some specific hotplug support to get the firmware from
-	 * userspace  directly into the hardware, or via some sysfs file */
-
-	/* NOTE: This currently doesn't work */
-
-	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
-
-        if(request_firmware(NULL, "sample_driver_fw", &ghost_device)!=0)
-	{
-		printk(KERN_ERR
-		       "firmware_sample_driver: Firmware load failed\n");
-		return;
-	}
-	
-	/* request_firmware blocks until userspace finished, so at
-	 * this point the firmware should be already in the device */
-
-	/* finish setting up the device */
-}
-static void sample_probe_async_cont(const struct firmware *fw, void *context)
-{
-	if(!fw){
-		printk(KERN_ERR
-		       "firmware_sample_driver: firmware load failed\n");
-		return;
-	}
-
-	printk(KERN_INFO "firmware_sample_driver: device pointer \"%s\"\n",
-	       (char *)context);
-	sample_firmware_load(fw->data, fw->size);
-}
-static void sample_probe_async(void)
-{
-	/* Let's say that I can't sleep */
-	int error;
-	error = request_firmware_nowait (THIS_MODULE, FW_ACTION_NOHOTPLUG,
-					 "sample_driver_fw", &ghost_device,
-					 "my device pointer",
-					 sample_probe_async_cont);
-	if(error){
-		printk(KERN_ERR 
-		       "firmware_sample_driver:"
-		       " request_firmware_nowait failed\n");
-	}
-}
-
-static int sample_init(void)
-{
-	device_initialize(&ghost_device);
-	/* since there is no real hardware insertion I just call the
-	 * sample probe functions here */
-	sample_probe_specific();
-	sample_probe_default();
-	sample_probe_async();
-	return 0;
-}
-static void __exit sample_exit(void)
-{
-}
-
-module_init (sample_init);
-module_exit (sample_exit);
-
-MODULE_LICENSE("GPL");
--- a/Documentation/firmware_class/firmware_sample_firmware_class.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * firmware_sample_firmware_class.c -
- *
- * Copyright (c) 2003 Manuel Estrada Sainz
- *
- * NOTE: This is just a probe of concept, if you think that your driver would
- * be well served by this mechanism please contact me first.
- *
- * DON'T USE THIS CODE AS IS
- *
- */
-
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/firmware.h>
-
-
-MODULE_AUTHOR("Manuel Estrada Sainz");
-MODULE_DESCRIPTION("Hackish sample for using firmware class directly");
-MODULE_LICENSE("GPL");
-
-static inline struct class_device *to_class_dev(struct kobject *obj)
-{
-	return container_of(obj,struct class_device,kobj);
-}
-static inline
-struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
-{
-	return container_of(_attr,struct class_device_attribute,attr);
-}
-
-int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-
-struct firmware_priv {
-	char fw_id[FIRMWARE_NAME_MAX];
-	s32 loading:2;
-	u32 abort:1;
-};
-
-extern struct class firmware_class;
-
-static ssize_t firmware_loading_show(struct class_device *class_dev, char *buf)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-	return sprintf(buf, "%d\n", fw_priv->loading);
-}
-static ssize_t firmware_loading_store(struct class_device *class_dev,
-				      const char *buf, size_t count)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-	int prev_loading = fw_priv->loading;
-
-	fw_priv->loading = simple_strtol(buf, NULL, 10);
-	
-	switch(fw_priv->loading){
-	case -1:
-		/* abort load an panic */
-		break;
-	case 1:
-		/* setup load */
-		break;
-	case 0:
-		if(prev_loading==1){
-			/* finish load and get the device back to working
-			 * state */
-		}
-		break;
-	}
-
-	return count;
-}
-static CLASS_DEVICE_ATTR(loading, 0644,
-			 firmware_loading_show, firmware_loading_store);
-
-static ssize_t firmware_data_read(struct kobject *kobj,
-				  struct bin_attribute *bin_attr,
-				  char *buffer, loff_t offset, size_t count)
-{
-	struct class_device *class_dev = to_class_dev(kobj);
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-
-	/* read from the devices firmware memory */
-
-	return count;
-}
-static ssize_t firmware_data_write(struct kobject *kobj,
-				   struct bin_attribute *bin_attr,
-				   char *buffer, loff_t offset, size_t count)
-{
-	struct class_device *class_dev = to_class_dev(kobj);
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-
-	/* write to the devices firmware memory */
-
-	return count;
-}
-static struct bin_attribute firmware_attr_data = {
-	.attr = {.name = "data", .mode = 0644},
-	.size = 0,
-	.read = firmware_data_read,
-	.write = firmware_data_write,
-};
-static int fw_setup_class_device(struct class_device *class_dev,
-				 const char *fw_name,
-				 struct device *device)
-{
-	int retval;
-	struct firmware_priv *fw_priv;
-
-	fw_priv = kzalloc(sizeof(struct firmware_priv),	GFP_KERNEL);
-	if (!fw_priv) {
-		retval = -ENOMEM;
-		goto out;
-	}
-
-	memset(class_dev, 0, sizeof(*class_dev));
-
-	strncpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX);
-	fw_priv->fw_id[FIRMWARE_NAME_MAX-1] = '\0';
-
-	strncpy(class_dev->class_id, device->bus_id, BUS_ID_SIZE);
-	class_dev->class_id[BUS_ID_SIZE-1] = '\0';
-	class_dev->dev = device;
-
-	class_dev->class = &firmware_class,
-	class_set_devdata(class_dev, fw_priv);
-	retval = class_device_register(class_dev);
-	if (retval){
-		printk(KERN_ERR "%s: class_device_register failed\n",
-		       __FUNCTION__);
-		goto error_free_fw_priv;
-	}
-
-	retval = sysfs_create_bin_file(&class_dev->kobj, &firmware_attr_data);
-	if (retval){
-		printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
-		       __FUNCTION__);
-		goto error_unreg_class_dev;
-	}
-
-	retval = class_device_create_file(class_dev,
-					  &class_device_attr_loading);
-	if (retval){
-		printk(KERN_ERR "%s: class_device_create_file failed\n",
-		       __FUNCTION__);
-		goto error_remove_data;
-	}
-
-	goto out;
-	
-error_remove_data:
-	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
-error_unreg_class_dev:
-	class_device_unregister(class_dev);
-error_free_fw_priv:
-	kfree(fw_priv);
-out:
-	return retval;
-}
-static void fw_remove_class_device(struct class_device *class_dev)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-
-	class_device_remove_file(class_dev, &class_device_attr_loading);
-	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
-	class_device_unregister(class_dev);
-}
-
-static struct class_device *class_dev;
-
-static struct device my_device = {
-	.bus_id    = "my_dev0",
-};
-
-static int __init firmware_sample_init(void)
-{
-	int error;
-
-	device_initialize(&my_device);
-	class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
-	if(!class_dev)
-		return -ENOMEM;
-
-	error = fw_setup_class_device(class_dev, "my_firmware_image",
-				      &my_device);
-	if(error){
-		kfree(class_dev);
-		return error;
-	}
-        return 0;
-
-}
-static void __exit firmware_sample_exit(void)
-{
-	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
-	fw_remove_class_device(class_dev);
-	kfree(fw_priv);
-	kfree(class_dev);
-}
-module_init(firmware_sample_init);
-module_exit(firmware_sample_exit);
-
--- /dev/null
+++ b/samples/firmware_class/firmware_sample_driver.c
@@ -0,0 +1,115 @@
+/*
+ * firmware_sample_driver.c -
+ *
+ * Copyright (c) 2003 Manuel Estrada Sainz
+ *
+ * Sample code on how to use request_firmware() from drivers.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/string.h>
+
+#include "linux/firmware.h"
+
+static struct device ghost_device = {
+	.bus_id    = "ghost0",
+};
+
+
+static void sample_firmware_load(char *firmware, int size)
+{
+	u8 buf[size+1];
+	memcpy(buf, firmware, size);
+	buf[size] = '\0';
+	printk(KERN_INFO "firmware_sample_driver: firmware: %s\n", buf);
+}
+
+static void sample_probe_default(void)
+{
+	/* uses the default method to get the firmware */
+        const struct firmware *fw_entry;
+	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
+
+        if(request_firmware(&fw_entry, "sample_driver_fw", &ghost_device)!=0)
+	{
+		printk(KERN_ERR
+		       "firmware_sample_driver: Firmware not available\n");
+		return;
+	}
+
+	sample_firmware_load(fw_entry->data, fw_entry->size);
+
+	release_firmware(fw_entry);
+
+	/* finish setting up the device */
+}
+static void sample_probe_specific(void)
+{
+	/* Uses some specific hotplug support to get the firmware from
+	 * userspace  directly into the hardware, or via some sysfs file */
+
+	/* NOTE: This currently doesn't work */
+
+	printk(KERN_INFO "firmware_sample_driver: a ghost device got inserted :)\n");
+
+        if(request_firmware(NULL, "sample_driver_fw", &ghost_device)!=0)
+	{
+		printk(KERN_ERR
+		       "firmware_sample_driver: Firmware load failed\n");
+		return;
+	}
+
+	/* request_firmware blocks until userspace finished, so at
+	 * this point the firmware should be already in the device */
+
+	/* finish setting up the device */
+}
+static void sample_probe_async_cont(const struct firmware *fw, void *context)
+{
+	if(!fw){
+		printk(KERN_ERR
+		       "firmware_sample_driver: firmware load failed\n");
+		return;
+	}
+
+	printk(KERN_INFO "firmware_sample_driver: device pointer \"%s\"\n",
+	       (char *)context);
+	sample_firmware_load(fw->data, fw->size);
+}
+static void sample_probe_async(void)
+{
+	/* Let's say that I can't sleep */
+	int error;
+	error = request_firmware_nowait (THIS_MODULE, FW_ACTION_NOHOTPLUG,
+					 "sample_driver_fw", &ghost_device,
+					 "my device pointer",
+					 sample_probe_async_cont);
+	if(error){
+		printk(KERN_ERR
+		       "firmware_sample_driver:"
+		       " request_firmware_nowait failed\n");
+	}
+}
+
+static int sample_init(void)
+{
+	device_initialize(&ghost_device);
+	/* since there is no real hardware insertion I just call the
+	 * sample probe functions here */
+	sample_probe_specific();
+	sample_probe_default();
+	sample_probe_async();
+	return 0;
+}
+static void __exit sample_exit(void)
+{
+}
+
+module_init (sample_init);
+module_exit (sample_exit);
+
+MODULE_LICENSE("GPL");
--- /dev/null
+++ b/samples/firmware_class/firmware_sample_firmware_class.c
@@ -0,0 +1,207 @@
+/*
+ * firmware_sample_firmware_class.c -
+ *
+ * Copyright (c) 2003 Manuel Estrada Sainz
+ *
+ * NOTE: This is just a probe of concept, if you think that your driver would
+ * be well served by this mechanism please contact me first.
+ *
+ * DON'T USE THIS CODE AS IS
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/timer.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/firmware.h>
+
+
+MODULE_AUTHOR("Manuel Estrada Sainz");
+MODULE_DESCRIPTION("Hackish sample for using firmware class directly");
+MODULE_LICENSE("GPL");
+
+static inline struct class_device *to_class_dev(struct kobject *obj)
+{
+	return container_of(obj,struct class_device,kobj);
+}
+static inline
+struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
+{
+	return container_of(_attr,struct class_device_attribute,attr);
+}
+
+int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
+int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
+
+struct firmware_priv {
+	char fw_id[FIRMWARE_NAME_MAX];
+	s32 loading:2;
+	u32 abort:1;
+};
+
+extern struct class firmware_class;
+
+static ssize_t firmware_loading_show(struct class_device *class_dev, char *buf)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	return sprintf(buf, "%d\n", fw_priv->loading);
+}
+static ssize_t firmware_loading_store(struct class_device *class_dev,
+				      const char *buf, size_t count)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	int prev_loading = fw_priv->loading;
+
+	fw_priv->loading = simple_strtol(buf, NULL, 10);
+
+	switch(fw_priv->loading){
+	case -1:
+		/* abort load an panic */
+		break;
+	case 1:
+		/* setup load */
+		break;
+	case 0:
+		if(prev_loading==1){
+			/* finish load and get the device back to working
+			 * state */
+		}
+		break;
+	}
+
+	return count;
+}
+static CLASS_DEVICE_ATTR(loading, 0644,
+			 firmware_loading_show, firmware_loading_store);
+
+static ssize_t firmware_data_read(struct kobject *kobj,
+				  struct bin_attribute *bin_attr,
+				  char *buffer, loff_t offset, size_t count)
+{
+	struct class_device *class_dev = to_class_dev(kobj);
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+
+	/* read from the devices firmware memory */
+
+	return count;
+}
+static ssize_t firmware_data_write(struct kobject *kobj,
+				   struct bin_attribute *bin_attr,
+				   char *buffer, loff_t offset, size_t count)
+{
+	struct class_device *class_dev = to_class_dev(kobj);
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+
+	/* write to the devices firmware memory */
+
+	return count;
+}
+static struct bin_attribute firmware_attr_data = {
+	.attr = {.name = "data", .mode = 0644},
+	.size = 0,
+	.read = firmware_data_read,
+	.write = firmware_data_write,
+};
+static int fw_setup_class_device(struct class_device *class_dev,
+				 const char *fw_name,
+				 struct device *device)
+{
+	int retval;
+	struct firmware_priv *fw_priv;
+
+	fw_priv = kzalloc(sizeof(struct firmware_priv),	GFP_KERNEL);
+	if (!fw_priv) {
+		retval = -ENOMEM;
+		goto out;
+	}
+
+	memset(class_dev, 0, sizeof(*class_dev));
+
+	strncpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX);
+	fw_priv->fw_id[FIRMWARE_NAME_MAX-1] = '\0';
+
+	strncpy(class_dev->class_id, device->bus_id, BUS_ID_SIZE);
+	class_dev->class_id[BUS_ID_SIZE-1] = '\0';
+	class_dev->dev = device;
+
+	class_dev->class = &firmware_class,
+	class_set_devdata(class_dev, fw_priv);
+	retval = class_device_register(class_dev);
+	if (retval){
+		printk(KERN_ERR "%s: class_device_register failed\n",
+		       __FUNCTION__);
+		goto error_free_fw_priv;
+	}
+
+	retval = sysfs_create_bin_file(&class_dev->kobj, &firmware_attr_data);
+	if (retval){
+		printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
+		       __FUNCTION__);
+		goto error_unreg_class_dev;
+	}
+
+	retval = class_device_create_file(class_dev,
+					  &class_device_attr_loading);
+	if (retval){
+		printk(KERN_ERR "%s: class_device_create_file failed\n",
+		       __FUNCTION__);
+		goto error_remove_data;
+	}
+
+	goto out;
+
+error_remove_data:
+	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
+error_unreg_class_dev:
+	class_device_unregister(class_dev);
+error_free_fw_priv:
+	kfree(fw_priv);
+out:
+	return retval;
+}
+static void fw_remove_class_device(struct class_device *class_dev)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+
+	class_device_remove_file(class_dev, &class_device_attr_loading);
+	sysfs_remove_bin_file(&class_dev->kobj, &firmware_attr_data);
+	class_device_unregister(class_dev);
+}
+
+static struct class_device *class_dev;
+
+static struct device my_device = {
+	.bus_id    = "my_dev0",
+};
+
+static int __init firmware_sample_init(void)
+{
+	int error;
+
+	device_initialize(&my_device);
+	class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
+	if(!class_dev)
+		return -ENOMEM;
+
+	error = fw_setup_class_device(class_dev, "my_firmware_image",
+				      &my_device);
+	if(error){
+		kfree(class_dev);
+		return error;
+	}
+        return 0;
+
+}
+static void __exit firmware_sample_exit(void)
+{
+	struct firmware_priv *fw_priv = class_get_devdata(class_dev);
+	fw_remove_class_device(class_dev);
+	kfree(fw_priv);
+	kfree(class_dev);
+}
+
+module_init(firmware_sample_init);
+module_exit(firmware_sample_exit);


Patches currently in gregkh-2.6 which might be from randy.dunlap@oracle.com are

driver/driver-core-fix-kernel-doc-function-parameters.patch
driver/sysfs-small-header-file-cleanup-for-sysfs-n.patch
driver/firmware-move-firmware_class-from-documentation-to-samples.patch
pci/pci-kernel-doc-fix-pci-acpi-warning.patch
usb/usb-convert-usb.h-struct-usb_device-to-kernel-doc.patch
firmware-add-kconfig-and-makefile-to-build-the-firmware-samples.patch

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

end of thread, other threads:[~2008-02-21  0:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-19  0:22 [PATCH] documentation: fix firmware_sample_firmware_class to build Randy Dunlap
2008-02-19  0:32 ` David Rientjes
2008-02-19  0:51   ` David Rientjes
2008-02-19 22:40     ` Randy Dunlap
2008-02-20  1:39       ` [patch] sysfs: small header file cleanup David Rientjes
2008-02-20  4:17         ` Randy Dunlap
2008-02-20  6:46 ` [PATCH] documentation: fix firmware_sample_firmware_class to build Greg KH
2008-02-20 20:10   ` Randy Dunlap
2008-02-20 20:40     ` Greg KH
2008-02-20 21:20       ` [PATCH 1/2] firmware: move firmware_class from Documentation/ to samples/ Randy Dunlap
2008-02-20 21:48         ` Marcel Holtmann
2008-02-21  0:07         ` patch firmware-move-firmware_class-from-documentation-to-samples.patch added to gregkh-2.6 tree gregkh

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).