All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	Marcel Holtmann <marcel@holtmann.org>
Subject: [PATCH 13/36] firmware: clean up samples for coding style issues
Date: Sun, 20 Apr 2008 03:45:43 -0700	[thread overview]
Message-ID: <1208688366-9252-13-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080420104516.GA9225@suse.de>

This fixes up a number of coding style issues in the firmware sample files.

Yeah, it still doesn't build properly yet, that's next...


Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 samples/firmware_class/firmware_sample_driver.c    |   45 +++++++++++---------
 .../firmware_sample_firmware_class.c               |   33 +++++++--------
 2 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/samples/firmware_class/firmware_sample_driver.c b/samples/firmware_class/firmware_sample_driver.c
index ff0f2f2..165cff9 100644
--- a/samples/firmware_class/firmware_sample_driver.c
+++ b/samples/firmware_class/firmware_sample_driver.c
@@ -12,8 +12,7 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/string.h>
-
-#include "linux/firmware.h"
+#include <linux/firmware.h>
 
 static struct device ghost_device = {
 	.bus_id    = "ghost0",
@@ -31,11 +30,14 @@ static void sample_firmware_load(char *firmware, int size)
 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");
+	const struct firmware *fw_entry;
+	int retval;
+
+	printk(KERN_INFO "firmware_sample_driver: "
+		"a ghost device got inserted :)\n");
 
-        if(request_firmware(&fw_entry, "sample_driver_fw", &ghost_device)!=0)
-	{
+	retval = request_firmware(&fw_entry, "sample_driver_fw", &ghost_device);
+	if (retval) {
 		printk(KERN_ERR
 		       "firmware_sample_driver: Firmware not available\n");
 		return;
@@ -47,17 +49,20 @@ static void sample_probe_default(void)
 
 	/* finish setting up the device */
 }
+
 static void sample_probe_specific(void)
 {
+	int retval;
 	/* 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");
+	printk(KERN_INFO "firmware_sample_driver: "
+		"a ghost device got inserted :)\n");
 
-        if(request_firmware(NULL, "sample_driver_fw", &ghost_device)!=0)
-	{
+	retval = request_firmware(NULL, "sample_driver_fw", &ghost_device);
+	if (retval) {
 		printk(KERN_ERR
 		       "firmware_sample_driver: Firmware load failed\n");
 		return;
@@ -70,7 +75,7 @@ static void sample_probe_specific(void)
 }
 static void sample_probe_async_cont(const struct firmware *fw, void *context)
 {
-	if(!fw){
+	if (!fw) {
 		printk(KERN_ERR
 		       "firmware_sample_driver: firmware load failed\n");
 		return;
@@ -80,19 +85,18 @@ static void sample_probe_async_cont(const struct firmware *fw, void *context)
 	       (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:"
+	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)
@@ -105,11 +109,12 @@ static int sample_init(void)
 	sample_probe_async();
 	return 0;
 }
+
 static void __exit sample_exit(void)
 {
 }
 
-module_init (sample_init);
-module_exit (sample_exit);
+module_init(sample_init);
+module_exit(sample_exit);
 
 MODULE_LICENSE("GPL");
diff --git a/samples/firmware_class/firmware_sample_firmware_class.c b/samples/firmware_class/firmware_sample_firmware_class.c
index 2799c47..9392116 100644
--- a/samples/firmware_class/firmware_sample_firmware_class.c
+++ b/samples/firmware_class/firmware_sample_firmware_class.c
@@ -25,30 +25,27 @@ MODULE_LICENSE("GPL");
 
 static inline struct class_device *to_class_dev(struct kobject *obj)
 {
-	return container_of(obj,struct class_device,kobj);
+	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);
+	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)
 {
@@ -57,7 +54,7 @@ static ssize_t firmware_loading_store(struct class_device *class_dev,
 
 	fw_priv->loading = simple_strtol(buf, NULL, 10);
 
-	switch(fw_priv->loading){
+	switch (fw_priv->loading) {
 	case -1:
 		/* abort load an panic */
 		break;
@@ -65,7 +62,7 @@ static ssize_t firmware_loading_store(struct class_device *class_dev,
 		/* setup load */
 		break;
 	case 0:
-		if(prev_loading==1){
+		if (prev_loading == 1) {
 			/* finish load and get the device back to working
 			 * state */
 		}
@@ -130,24 +127,24 @@ static int fw_setup_class_device(struct class_device *class_dev,
 	class_dev->class = &firmware_class,
 	class_set_devdata(class_dev, fw_priv);
 	retval = class_device_register(class_dev);
-	if (retval){
+	if (retval) {
 		printk(KERN_ERR "%s: class_device_register failed\n",
-		       __FUNCTION__);
+		       __func__);
 		goto error_free_fw_priv;
 	}
 
 	retval = sysfs_create_bin_file(&class_dev->kobj, &firmware_attr_data);
-	if (retval){
+	if (retval) {
 		printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
-		       __FUNCTION__);
+		       __func__);
 		goto error_unreg_class_dev;
 	}
 
 	retval = class_device_create_file(class_dev,
 					  &class_device_attr_loading);
-	if (retval){
+	if (retval) {
 		printk(KERN_ERR "%s: class_device_create_file failed\n",
-		       __FUNCTION__);
+		       __func__);
 		goto error_remove_data;
 	}
 
@@ -183,16 +180,16 @@ static int __init firmware_sample_init(void)
 
 	device_initialize(&my_device);
 	class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
-	if(!class_dev)
+	if (!class_dev)
 		return -ENOMEM;
 
 	error = fw_setup_class_device(class_dev, "my_firmware_image",
 				      &my_device);
-	if(error){
+	if (error) {
 		kfree(class_dev);
 		return error;
 	}
-        return 0;
+	return 0;
 
 }
 static void __exit firmware_sample_exit(void)
-- 
1.5.4.5


  parent reply	other threads:[~2008-04-20 10:44 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-20 10:45 [GIT PATCH] driver core changes against 2.6.25-git Greg KH
2008-04-20 10:45 ` [PATCH 01/36] kobject: catch kobjects that are not initialized Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 02/36] uio: Kconfig improvements Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 03/36] uio: mark pci_device_id hilscher_pci_ids[] __devinitdata Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 04/36] UIO: arch/arm/Kconfig: Make UIO available on ARM architecture Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 05/36] UIO: Remove needless PCI_DEVICE_ID definition from uio_cif.c Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 06/36] UIO: Implement a UIO interface for the SMX Cryptengine Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 07/36] UIO: hold a reference to the device's owner while the device is open Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 08/36] driver core: memory: semaphore to mutex Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 09/36] driver core: register_memory/unregister_memory clean ups and bugfix Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 10/36] driver core: Convert debug functions declared inline __attribute__((format (printf,x,y) to statement expression macros Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 11/36] sysfs: small header file cleanup for SYSFS=n Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 12/36] firmware: move firmware_class from Documentation/ to samples/ Greg Kroah-Hartman
2008-04-20 10:45 ` Greg Kroah-Hartman [this message]
2008-04-20 10:45 ` [PATCH 14/36] PNP: add all PNP card device id's as individual aliases Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 15/36] power_state: remove it from driver core Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 16/36] driver core: cpu: fix section mismatch in cpu.c:store_online Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 17/36] sysdev: detect multiple driver registrations Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 18/36] block: send disk "change" event for rescan_partitions() Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 19/36] PM: Handle device registrations during suspend/resume Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 20/36] Driver core: Call device_pm_add() after bus_add_device() in device_add() Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 21/36] PM: Fix misuse of wakeup flag accessors in serial core Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 22/36] PM: Make wakeup flags available whenever CONFIG_PM is set Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 23/36] PM: Convert wakeup flag accessors to inline functions Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 24/36] Driver core: make device_is_registered() work for class devices Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 25/36] SYSFS: Explicitly include required header file slab.h Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 26/36] Kobject: Replace list_for_each() with list_for_each_entry() Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 27/36] PM: Remove legacy PM (fix) Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 28/36] Firmware: add iSCSI iBFT Support Greg Kroah-Hartman
2008-04-20 10:45 ` [PATCH 29/36] PM: Remove destroy_suspended_device() Greg Kroah-Hartman
2008-04-20 10:46 ` [PATCH 30/36] sysfs: refill attribute buffer when reading from offset 0 Greg Kroah-Hartman
2008-04-20 10:46 ` [PATCH 31/36] driver core: replace remaining __FUNCTION__ occurrences Greg Kroah-Hartman
2008-04-20 10:46 ` [PATCH 32/36] memstick: convert struct class_device to struct device Greg Kroah-Hartman
2008-04-20 10:46 ` [PATCH 33/36] IB: " Greg Kroah-Hartman
2008-04-20 17:23   ` Roland Dreier
2008-04-20 10:46 ` [PATCH 34/36] IB: rename "dev" to "srp_dev" in srp_host structure Greg Kroah-Hartman
2008-04-20 10:46 ` [PATCH 35/36] DRM: remove unused dev_class Greg Kroah-Hartman
2008-04-20 10:46 ` [PATCH 36/36] SCSI: convert struct class_device to struct device Greg Kroah-Hartman

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=1208688366-9252-13-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=randy.dunlap@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.