Skip to contentSkip to conversation

driver core changes against 2.6.25-git

PATCH New Greg KH 2 participants 38 messages Apr 20, 2008

Subsystems (41)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 driver core changes against 2.6.25-git

Here are a bunch of driver core related changes against your current 2.6.25-git tree.

They touch other subsystems (IB and SCSI specifically) with the class_device changes, but those are acked by the respective maintainers to go through my tree to minimize the merge mess.

They contain:
- class_device removal (I think we are finished, the final patch will come after 2.6.26-rc1 is out to verify that nothing was missed.)
- firmware documentation moving
- ibft came in through here as no one else wanted to take it and it was under driver/firmware/
- UIO changes and a new driver.
- lots of other things, the shortlog below describes them best.

All of these have been in the -mm and linux-next tree for quite a while.

Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/

Patches will be sent as a follow-on to this message to lkml for people to see.

thanks,

greg k-h

------------

 Documentation/ABI/testing/sysfs-ibft                          |   23 
 Documentation/DocBook/kernel-api.tmpl                         |    5 
 Documentation/filesystems/sysfs.txt                           |    9 
 Documentation/firmware_class/firmware_sample_driver.c         |  115 -
 Documentation/firmware_class/firmware_sample_firmware_class.c |  207 --
 Documentation/power/devices.txt                               |    5 
 MAINTAINERS                                                   |    5 
 arch/arm/Kconfig                                              |    2 
 arch/x86/kernel/cpuid.c                                       |    4 
 arch/x86/kernel/msr.c                                         |    4 
 arch/x86/kernel/setup_32.c                                    |    3 
 arch/x86/kernel/setup_64.c                                    |    4 
 block/bsg.c                                                   |   11 
 drivers/ata/ahci.c                                            |    4 
 drivers/ata/libata-scsi.c                                     |   15 
 drivers/base/attribute_container.c                            |   77 
 drivers/base/bus.c                                            |   17 
 drivers/base/class.c                                          |    8 
 drivers/base/core.c                                           |   58 
 drivers/base/cpu.c                                            |    4 
 drivers/base/dd.c                                             |   14 
 drivers/base/firmware_class.c                                 |   18 
 drivers/base/memory.c                                         |   33 
 drivers/base/power/main.c                                     |  106 -
 drivers/base/power/power.h                                    |   23 
 drivers/base/power/sysfs.c                                    |    2 
 drivers/base/sys.c                                            |   18 
 drivers/base/transport_class.c                                |   14 
 drivers/char/drm/drmP.h                                       |    1 
 drivers/char/hw_random/core.c                                 |   10 
 drivers/char/misc.c                                           |   13 
 drivers/firmware/Kconfig                                      |   20 
 drivers/firmware/Makefile                                     |    2 
 drivers/firmware/iscsi_ibft.c                                 |  982 ++++++++++
 drivers/firmware/iscsi_ibft_find.c                            |   84 
 drivers/infiniband/core/sysfs.c                               |   76 
 drivers/infiniband/core/ucm.c                                 |   62 
 drivers/infiniband/core/user_mad.c                            |  109 -
 drivers/infiniband/core/uverbs.h                              |    4 
 drivers/infiniband/core/uverbs_main.c                         |   51 
 drivers/infiniband/hw/amso1100/c2_provider.c                  |   48 
 drivers/infiniband/hw/cxgb3/iwch_provider.c                   |   75 
 drivers/infiniband/hw/ipath/ipath_diag.c                      |   10 
 drivers/infiniband/hw/ipath/ipath_file_ops.c                  |   44 
 drivers/infiniband/hw/ipath/ipath_kernel.h                    |    8 
 drivers/infiniband/hw/ipath/ipath_verbs.c                     |   37 
 drivers/infiniband/hw/mlx4/main.c                             |   49 
 drivers/infiniband/hw/mthca/mthca_provider.c                  |   48 
 drivers/infiniband/hw/nes/nes_verbs.c                         |   48 
 drivers/infiniband/ulp/srp/ib_srp.c                           |  181 -
 drivers/infiniband/ulp/srp/ib_srp.h                           |    4 
 drivers/leds/led-class.c                                      |   11 
 drivers/memstick/core/memstick.c                              |   33 
 drivers/memstick/core/mspro_block.c                           |    4 
 drivers/memstick/host/jmb38x_ms.c                             |   16 
 drivers/message/fusion/mptscsih.c                             |  122 -
 drivers/message/fusion/mptscsih.h                             |    2 
 drivers/misc/enclosure.c                                      |  118 -
 drivers/net/wireless/b43/leds.c                               |    5 
 drivers/net/wireless/b43/main.c                               |    8 
 drivers/scsi/3w-9xxx.c                                        |    9 
 drivers/scsi/3w-xxxx.c                                        |    9 
 drivers/scsi/aacraid/aachba.c                                 |    2 
 drivers/scsi/aacraid/aacraid.h                                |    4 
 drivers/scsi/aacraid/linit.c                                  |   93 
 drivers/scsi/arcmsr/arcmsr.h                                  |    4 
 drivers/scsi/arcmsr/arcmsr_attr.c                             |  163 -
 drivers/scsi/ch.c                                             |   13 
 drivers/scsi/hosts.c                                          |   34 
 drivers/scsi/hptiop.c                                         |   14 
 drivers/scsi/ibmvscsi/ibmvscsi.c                              |   44 
 drivers/scsi/ibmvscsi/ibmvstgt.c                              |   25 
 drivers/scsi/ipr.c                                            |  140 -
 drivers/scsi/lpfc/lpfc_attr.c                                 |  484 ++--
 drivers/scsi/lpfc/lpfc_crtn.h                                 |    4 
 drivers/scsi/megaraid/megaraid_mbox.c                         |   13 
 drivers/scsi/ncr53c8xx.c                                      |    7 
 drivers/scsi/osst.c                                           |   76 
 drivers/scsi/pcmcia/sym53c500_cs.c                            |   14 
 drivers/scsi/qla2xxx/qla_attr.c                               |  177 -
 drivers/scsi/qla2xxx/qla_gbl.h                                |    4 
 drivers/scsi/raid_class.c                                     |   73 
 drivers/scsi/scsi_sas_internal.h                              |   24 
 drivers/scsi/scsi_sysfs.c                                     |  150 -
 drivers/scsi/scsi_transport_fc.c                              |  385 ++-
 drivers/scsi/scsi_transport_iscsi.c                           |  107 -
 drivers/scsi/scsi_transport_sas.c                             |  157 -
 drivers/scsi/scsi_transport_spi.c                             |  185 -
 drivers/scsi/scsi_transport_srp.c                             |   26 
 drivers/scsi/sd.c                                             |   78 
 drivers/scsi/ses.c                                            |   28 
 drivers/scsi/sg.c                                             |   36 
 drivers/scsi/st.c                                             |   82 
 drivers/serial/serial_core.c                                  |    2 
 drivers/uio/Kconfig                                           |   23 
 drivers/uio/Makefile                                          |    1 
 drivers/uio/uio.c                                             |   36 
 drivers/uio/uio_cif.c                                         |    6 
 drivers/uio/uio_smx.c                                         |  140 +
 fs/partitions/check.c                                         |    4 
 fs/sysfs/dir.c                                                |    1 
 fs/sysfs/file.c                                               |    6 
 include/linux/attribute_container.h                           |   28 
 include/linux/bsg.h                                           |    2 
 include/linux/device.h                                        |   35 
 include/linux/enclosure.h                                     |   11 
 include/linux/hw_random.h                                     |   10 
 include/linux/iscsi_ibft.h                                    |   50 
 include/linux/kernel.h                                        |    6 
 include/linux/leds.h                                          |   10 
 include/linux/libata.h                                        |    2 
 include/linux/memory.h                                        |    5 
 include/linux/memstick.h                                      |    2 
 include/linux/miscdevice.h                                    |   10 
 include/linux/pm.h                                            |   43 
 include/linux/pm_wakeup.h                                     |   90 
 include/linux/raid_class.h                                    |   12 
 include/linux/sysfs.h                                         |    9 
 include/linux/transport_class.h                               |    6 
 include/rdma/ib_verbs.h                                       |    2 
 include/scsi/scsi_device.h                                    |   10 
 include/scsi/scsi_host.h                                      |    7 
 include/scsi/scsi_transport.h                                 |    2 
 include/scsi/scsi_transport_fc.h                              |   14 
 include/scsi/scsi_transport_sas.h                             |   12 
 include/scsi/sd.h                                             |    4 
 lib/kobject.c                                                 |   19 
 mm/memory_hotplug.c                                           |    2 
 samples/firmware_class/firmware_sample_driver.c               |  120 +
 samples/firmware_class/firmware_sample_firmware_class.c       |  204 ++
 scripts/mod/file2alias.c                                      |   57 
 131 files changed, 4158 insertions(+), 2602 deletions(-)

---------------

Alan Stern (3):
PM: Fix misuse of wakeup flag accessors in serial core
PM: Make wakeup flags available whenever CONFIG_PM is set
PM: Convert wakeup flag accessors to inline functions

Badari Pulavarty (1):
driver core: register_memory/unregister_memory clean ups and bugfix

Ben Dooks (1):
sysdev: detect multiple driver registrations

Ben Nizette (1):
UIO: Implement a UIO interface for the SMX Cryptengine

Dan Williams (1):
sysfs: refill attribute buffer when reading from offset 0

Daniel Walker (1):
driver core: memory: semaphore to mutex

David Rientjes (1):
sysfs: small header file cleanup for SYSFS=n

Denis Cheng (2):
uio: Kconfig improvements
uio: mark pci_device_id hilscher_pci_ids[] __devinitdata

Greg Kroah-Hartman (6):
kobject: catch kobjects that are not initialized
firmware: clean up samples for coding style issues Driver core: make device_is_registered() work for class devices
memstick: convert struct class_device to struct device
IB: rename "dev" to "srp_dev" in srp_host structure
DRM: remove unused dev_class

Hans-Jürgen Koch (2):
UIO: arch/arm/Kconfig: Make UIO available on ARM architecture
UIO: Remove needless PCI_DEVICE_ID definition from uio_cif.c

Harvey Harrison (1):
driver core: replace remaining __FUNCTION__ occurrences

Joe Perches (1):
driver core: Convert debug functions declared inline __attribute__((format (printf,x,y) to statement expression macros

Kay Sievers (2):
PNP: add all PNP card device id's as individual aliases
block: send disk "change" event for rescan_partitions()

Konrad Rzeszutek (1):
Firmware: add iSCSI iBFT Support

Pavel Machek (1):
power_state: remove it from driver core

Rafael J. Wysocki (3):
PM: Handle device registrations during suspend/resume Driver core: Call device_pm_add() after bus_add_device() in device_add()
PM: Remove destroy_suspended_device()

Randy Dunlap (2):
firmware: move firmware_class from Documentation/ to samples/
PM: Remove legacy PM (fix)

Robert P. J. Day (2):
SYSFS: Explicitly include required header file slab.h.
Kobject: Replace list_for_each() with list_for_each_entry().

Sam Ravnborg (1):
driver core: cpu: fix section mismatch in cpu.c:store_online

Tony Jones (2):
IB: convert struct class_device to struct device
SCSI: convert struct class_device to struct device

Uwe Kleine-König (1):
UIO: hold a reference to the device's owner while the device is open

#1 lore raw

PATCH 1/36 kobject: catch kobjects that are not initialized

Add warnings to kobject_put() to catch kobjects that are cleaned up but were never initialized to begin with.

Cc Kay Sievers <[email protected]>
Cc Hannes Reinecke <[email protected]>
---
 lib/kobject.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
lib/kobject.c +8 -1
index 0d03252..60ae9e8 100644
@@ -592,8 +592,15 @@ static void kobject_release(struct kref *kref)
  */
 void kobject_put(struct kobject *kobj)
 {
-	if (kobj)
+	if (kobj) {
+		if (!kobj->state_initialized) {
+			printk(KERN_WARNING "kobject: '%s' (%p): is not "
+			       "initialized, yet kobject_put() is being "
+			       "called.\n", kobject_name(kobj), kobj);
+			WARN_ON(1);
+		}
 		kref_put(&kobj->kref, kobject_release);
+	}
 }
 
 static void dynamic_kobj_release(struct kobject *kobj)
Signature · 1 line
1.5.4.5
#2 lore raw

PATCH 2/36 uio: Kconfig improvements

In reply to Greg KH

From: Denis Cheng <[email protected]>

---
 drivers/uio/Kconfig |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/uio/Kconfig +5 -5
index b778ed7..d8ab7e6 100644
@@ -1,8 +1,6 @@
-menu "Userspace I/O"
-	depends on !S390
-
-config UIO
+menuconfig UIO
 	tristate "Userspace I/O drivers"
+	depends on !S390
 	default n
 	help
 	  Enable this to allow the userspace driver core code to be
@@ -13,6 +11,8 @@ config UIO
 
 	  If you don't know what to do here, say N.
 
+if UIO
+
 config UIO_CIF
 	tristate "generic Hilscher CIF Card driver"
 	depends on UIO && PCI
@@ -26,4 +26,4 @@ config UIO_CIF
 	  To compile this driver as a module, choose M here: the module
 	  will be called uio_cif.
 
-endmenu
+endif
Signature · 1 line
1.5.4.5
#3 lore raw

PATCH 3/36 uio: mark pci_device_id hilscher_pci_ids[] __devinitdata

In reply to Greg KH

From: Denis Cheng <[email protected]>

---
 drivers/uio/uio_cif.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/uio/uio_cif.c +1 -1
index 838bae4..4a5a97e 100644
@@ -116,7 +116,7 @@ static void hilscher_pci_remove(struct pci_dev *dev)
 	kfree (info);
 }
 
-static struct pci_device_id hilscher_pci_ids[] = {
+static struct pci_device_id hilscher_pci_ids[] __devinitdata = {
 	{
 		.vendor =	PCI_VENDOR_ID_PLX,
 		.device =	PCI_DEVICE_ID_PLX_9030,
Signature · 1 line
1.5.4.5
#4 lore raw

PATCH 4/36 UIO: arch/arm/Kconfig: Make UIO available on ARM architecture

In reply to Greg KH

From: Hans-Jürgen Koch <[email protected]>

Source drivers/uio/Kconfig to make UIO available in menuconfig if ARCH=arm.

---
 arch/arm/Kconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/Kconfig +2 -0
index 4039a13..1165a8f 100644
@@ -1174,6 +1174,8 @@ source "drivers/dma/Kconfig"
 
 source "drivers/dca/Kconfig"
 
+source "drivers/uio/Kconfig"
+
 endmenu
 
 source "fs/Kconfig"
Signature · 1 line
1.5.4.5
#5 lore raw

PATCH 5/36 UIO: Remove needless PCI_DEVICE_ID definition from uio_cif.c

In reply to Greg KH

From: Hans-Jürgen Koch <[email protected]>

Meanwhile, PCI_DEVICE_ID_PLX_9030 is defined in pci_ids.h, no need to define it again in the driver.

---
 drivers/uio/uio_cif.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/uio/uio_cif.c +0 -4
index 4a5a97e..5737606 100644
@@ -15,10 +15,6 @@
 
 #include <asm/io.h>
 
-#ifndef PCI_DEVICE_ID_PLX_9030
-#define PCI_DEVICE_ID_PLX_9030	0x9030
-#endif
-
 #define PLX9030_INTCSR		0x4C
 #define INTSCR_INT1_ENABLE	0x01
 #define INTSCR_INT1_STATUS	0x04
Signature · 1 line
1.5.4.5
#6 lore raw

PATCH 6/36 UIO: Implement a UIO interface for the SMX Cryptengine

In reply to Greg KH

From: Ben Nizette <[email protected]>

This patch implements a UIO interface for the SMX Cryptengine.

The Cryptengine found on the Nias Digital SMX board is best suited for a UIO interface. It is not wired in to the cryptographic API as the engine handles it's own keys, algorithms, everything. All that we know about is that if there's room in the buffer, you can write data to it and when there's data ready, you read it out again.

There isn't necessarily even any direct correlation between data going in and data coming out again, the engine may consume or generate data all on its own.

This driver is for proprietary hardware but we're always told to submit the drivers anyway; here you are. :-)

This is version 4 of this patch and addresses all issues raised by Hans-Jürgen Koch and Paul Mundt in their reviews. Slightly altered is Paul's suggestion to use DRV_NAME and DRV_VERSION as the UIO version and name. While at the moment they are the same, there is no reason for them to stay that way. Nevertheless we now at least provide a MODULE_VERSION macro to keep modinfo happy.

---
 MAINTAINERS           |    5 ++
 drivers/uio/Kconfig   |   13 +++++
 drivers/uio/Makefile  |    1 +
 drivers/uio/uio_smx.c |  140 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 159 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_smx.c
MAINTAINERS +5 -0
index 45b86ab..897e5eb 100644
@@ -3604,6 +3604,11 @@ M:	[email protected]
 L:	[email protected]
 S:	Maintained
 
+SMX UIO Interface
+P:	Ben Nizette
+M:	[email protected]
+S:	Maintained
+
 SOFTWARE RAID (Multiple Disks) SUPPORT
 P:	Ingo Molnar
 M:	[email protected]
drivers/uio/Kconfig +13 -0
index d8ab7e6..a4aaab9 100644
@@ -26,4 +26,17 @@ config UIO_CIF
 	  To compile this driver as a module, choose M here: the module
 	  will be called uio_cif.
 
+config UIO_SMX
+	tristate "SMX cryptengine UIO interface"
+	depends on UIO
+	default n
+	help
+	  Userspace IO interface to the Cryptography engine found on the
+	  Nias Digital SMX boards.  These will be available from Q4 2008
+	  from http://www.niasdigital.com.  The userspace part of this
+	  driver will be released under the GPL at the same time as the
+	  hardware and will be able to be downloaded from the same site.
+
+	  If you compile this as a module, it will be called uio_smx.
+
 endif
drivers/uio/Makefile +1 -0
index 7fecfb4..18c4566 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_UIO)	+= uio.o
 obj-$(CONFIG_UIO_CIF)	+= uio_cif.o
+obj-$(CONFIG_UIO_SMX)	+= uio_smx.o
drivers/uio/uio_smx.c new file +140 -0

140 lines not on this page · raw message

Signature · 1 line
1.5.4.5
#7 lore raw

PATCH 7/36 UIO: hold a reference to the device's owner while the device is open

In reply to Greg KH

From: Uwe Kleine-König <[email protected]>

Otherwise the device might just disappear while /dev/uioX is being used which results in an Oops.

---
 drivers/uio/uio.c |   36 +++++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 15 deletions(-)
drivers/uio/uio.c +21 -15
index 1175908..55cc7b8 100644
@@ -301,23 +301,33 @@ static int uio_open(struct inode *inode, struct file *filep)
 	if (!idev)
 		return -ENODEV;
 
+	if (!try_module_get(idev->owner))
+		return -ENODEV;
+
 	listener = kmalloc(sizeof(*listener), GFP_KERNEL);
-	if (!listener)
-		return -ENOMEM;
+	if (!listener) {
+		ret = -ENOMEM;
+		goto err_alloc_listener;
+	}
 
 	listener->dev = idev;
 	listener->event_count = atomic_read(&idev->event);
 	filep->private_data = listener;
 
 	if (idev->info->open) {
-		if (!try_module_get(idev->owner))
-			return -ENODEV;
 		ret = idev->info->open(idev->info, inode);
-		module_put(idev->owner);
+		if (ret)
+			goto err_infoopen;
 	}
 
-	if (ret)
-		kfree(listener);
+	return 0;
+
+err_infoopen:
+
+	kfree(listener);
+err_alloc_listener:
+
+	module_put(idev->owner);
 
 	return ret;
 }
@@ -336,12 +346,11 @@ static int uio_release(struct inode *inode, struct file *filep)
 	struct uio_listener *listener = filep->private_data;
 	struct uio_device *idev = listener->dev;
 
-	if (idev->info->release) {
-		if (!try_module_get(idev->owner))
-			return -ENODEV;
+	if (idev->info->release)
 		ret = idev->info->release(idev->info, inode);
-		module_put(idev->owner);
-	}
+
+	module_put(idev->owner);
+
 	if (filep->f_flags & FASYNC)
 		ret = uio_fasync(-1, filep, 0);
 	kfree(listener);
@@ -510,10 +519,7 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
 		return -EINVAL;
 
 	if (idev->info->mmap) {
-		if (!try_module_get(idev->owner))
-			return -ENODEV;
 		ret = idev->info->mmap(idev->info, vma);
-		module_put(idev->owner);
 		return ret;
 	}
 
Signature · 1 line
1.5.4.5
#8 lore raw

PATCH 8/36 driver core: memory: semaphore to mutex

In reply to Greg KH

From: Daniel Walker <[email protected]>

---
 drivers/base/memory.c  |    7 ++++---
 include/linux/memory.h |    5 ++---
 mm/memory_hotplug.c    |    2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/base/memory.c +4 -3
index 7ae413f..1f3801a 100644
@@ -20,6 +20,7 @@
 #include <linux/kobject.h>
 #include <linux/memory_hotplug.h>
 #include <linux/mm.h>
+#include <linux/mutex.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 
@@ -205,7 +206,7 @@ static int memory_block_change_state(struct memory_block *mem,
 		unsigned long to_state, unsigned long from_state_req)
 {
 	int ret = 0;
-	down(&mem->state_sem);
+	mutex_lock(&mem->state_mutex);
 
 	if (mem->state != from_state_req) {
 		ret = -EINVAL;
@@ -217,7 +218,7 @@ static int memory_block_change_state(struct memory_block *mem,
 		mem->state = to_state;
 
 out:
-	up(&mem->state_sem);
+	mutex_unlock(&mem->state_mutex);
 	return ret;
 }
 
@@ -341,7 +342,7 @@ static int add_memory_block(unsigned long node_id, struct mem_section *section,
 
 	mem->phys_index = __section_nr(section);
 	mem->state = state;
-	init_MUTEX(&mem->state_sem);
+	mutex_init(&mem->state_mutex);
 	mem->phys_device = phys_device;
 
 	ret = register_memory(mem, section, NULL);
include/linux/memory.h +2 -3
index 33f0ff0..f80e0e3 100644
@@ -18,8 +18,7 @@
 #include <linux/sysdev.h>
 #include <linux/node.h>
 #include <linux/compiler.h>
-
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 struct memory_block {
 	unsigned long phys_index;
@@ -30,7 +29,7 @@ struct memory_block {
 	 * created long after the critical areas during
 	 * initialization.
 	 */
-	struct semaphore state_sem;
+	struct mutex state_mutex;
 	int phys_device;		/* to which fru does this belong? */
 	void *hw;			/* optional pointer to fw/hw data */
 	int (*phys_callback)(struct memory_block *);
mm/memory_hotplug.c +1 -1
index 7469c50..0fb3302 100644
@@ -208,7 +208,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
 	/*
 	 * This doesn't need a lock to do pfn_to_page().
 	 * The section can't be removed here because of the
-	 * memory_block->state_sem.
+	 * memory_block->state_mutex.
 	 */
 	zone = page_zone(pfn_to_page(pfn));
 	pgdat_resize_lock(zone->zone_pgdat, &flags);
Signature · 1 line
1.5.4.5
#9 lore raw

PATCH 9/36 driver core: register_memory/unregister_memory clean ups and bugfix

In reply to Greg KH

From: Badari Pulavarty <[email protected]>

register_memory()/unregister_memory() never gets called with "root". unregister_memory() is accessing kobject_name of the object just freed up. Since no one uses the code, lets take the code out. And also, make register_memory() static.

Another bug fix - before calling unregister_memory() remove_memory_block() gets a ref on kobject. unregister_memory() need to drop that ref before calling sysdev_unregister().

---
 drivers/base/memory.c |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)
drivers/base/memory.c +7 -15
index 1f3801a..7891f7c 100644
@@ -62,8 +62,8 @@ void unregister_memory_notifier(struct notifier_block *nb)
 /*
  * register_memory - Setup a sysfs device for a memory block
  */
-int register_memory(struct memory_block *memory, struct mem_section *section,
-		struct node *root)
+static
+int register_memory(struct memory_block *memory, struct mem_section *section)
 {
 	int error;
 
@@ -71,26 +71,18 @@ int register_memory(struct memory_block *memory, struct mem_section *section,
 	memory->sysdev.id = __section_nr(section);
 
 	error = sysdev_register(&memory->sysdev);
-
-	if (root && !error)
-		error = sysfs_create_link(&root->sysdev.kobj,
-					  &memory->sysdev.kobj,
-					  kobject_name(&memory->sysdev.kobj));
-
 	return error;
 }
 
 static void
-unregister_memory(struct memory_block *memory, struct mem_section *section,
-		struct node *root)
+unregister_memory(struct memory_block *memory, struct mem_section *section)
 {
 	BUG_ON(memory->sysdev.cls != &memory_sysdev_class);
 	BUG_ON(memory->sysdev.id != __section_nr(section));
 
+	/* drop the ref. we got in remove_memory_block() */
+	kobject_put(&memory->sysdev.kobj);
 	sysdev_unregister(&memory->sysdev);
-	if (root)
-		sysfs_remove_link(&root->sysdev.kobj,
-				  kobject_name(&memory->sysdev.kobj));
 }
 
 /*
@@ -345,7 +337,7 @@ static int add_memory_block(unsigned long node_id, struct mem_section *section,
 	mutex_init(&mem->state_mutex);
 	mem->phys_device = phys_device;
 
-	ret = register_memory(mem, section, NULL);
+	ret = register_memory(mem, section);
 	if (!ret)
 		ret = mem_create_simple_file(mem, phys_index);
 	if (!ret)
@@ -396,7 +388,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section,
 	mem_remove_simple_file(mem, phys_index);
 	mem_remove_simple_file(mem, state);
 	mem_remove_simple_file(mem, phys_device);
-	unregister_memory(mem, section, NULL);
+	unregister_memory(mem, section);
 
 	return 0;
 }
Signature · 1 line
1.5.4.5
#10 lore raw

PATCH 10/36 driver core: Convert debug functions declared inline __attribute__((format (printf,x,y) to statement expression macros

In reply to Greg KH

From: Joe Perches <[email protected]>

When DEBUG is not defined, pr_debug and dev_dbg and some other local debugging functions are specified as:

"inline __attribute__((format (printf, x, y)))"

This is done to validate printk arguments when not debugging.

Converting these functions to macros or statement expressions "do { if (0) printk(fmt, ##arg); } while (0)"
or
"({ if (0) printk(fmt, ##arg); 0; })
makes at least gcc 4.2.2 produce smaller objects.

This has the additional benefit of allowing the optimizer to avoid calling functions like print_mac that might have been arguments to the printk.

defconfig x86 current:

$ size vmlinux
   text    data     bss     dec     hex filename
4716770  474560  618496 5809826  58a6a2 vmlinux

all converted: (More patches follow)

$ size vmlinux
   text    data     bss     dec     hex filename
4716642  474560  618496 5809698  58a622 vmlinux

Even kernel/sched.o, which doesn't even use these
functions, becomes smaller.

It appears that merely having an indirect include
of <linux/device.h> can cause bigger objects.

$ size sched.inline.o sched.if0.o
   text    data     bss     dec     hex filename
  31385    2854     328   34567    8707 sched.inline.o
  31366    2854     328   34548    86f4 sched.if0.o

The current preprocessed only kernel/sched.i file contains:

# 612 "include/linux/device.h"
static inline __attribute__((always_inline)) int __attribute__ ((format (printf, 2, 3))) dev_dbg(struct device *dev, const char *fmt, ...)
{
return 0;
}
# 628 "include/linux/device.h"
static inline __attribute__((always_inline)) int __attribute__ ((format (printf, 2, 3))) dev_vdbg(struct device *dev, const char *fmt, ...)
{
return 0;
}

Removing these unused inlines from sched.i shrinks sched.o

---
 include/linux/device.h |   15 +++++----------
 include/linux/kernel.h |    6 ++----
 2 files changed, 7 insertions(+), 14 deletions(-)
include/linux/device.h +5 -10
index 2258d89..d576611 100644
@@ -608,21 +608,16 @@ extern const char *dev_driver_string(struct device *dev);
 #define dev_dbg(dev, format, arg...)		\
 	dev_printk(KERN_DEBUG , dev , format , ## arg)
 #else
-static inline int __attribute__ ((format (printf, 2, 3)))
-dev_dbg(struct device *dev, const char *fmt, ...)
-{
-	return 0;
-}
+#define dev_dbg(dev, format, arg...)		\
+	({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
 #endif
 
 #ifdef VERBOSE_DEBUG
 #define dev_vdbg	dev_dbg
 #else
-static inline int __attribute__ ((format (printf, 2, 3)))
-dev_vdbg(struct device *dev, const char *fmt, ...)
-{
-	return 0;
-}
+
+#define dev_vdbg(dev, format, arg...)		\
+	({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
 #endif
 
 /* Create alias, so I can be autoloaded. */
include/linux/kernel.h +2 -4
index 2df44e7..cd6d02c 100644
@@ -293,10 +293,8 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
 #define pr_debug(fmt, arg...) \
 	printk(KERN_DEBUG fmt, ##arg)
 #else
-static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char * fmt, ...)
-{
-	return 0;
-}
+#define pr_debug(fmt, arg...) \
+	({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; })
 #endif
 
 /*
Signature · 1 line
1.5.4.5
#11 lore raw

PATCH 11/36 sysfs: small header file cleanup for SYSFS=n

In reply to Greg KH

From: David Rientjes <[email protected]>

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

---
 include/linux/sysfs.h |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
include/linux/sysfs.h +2 -7
index 8027104..03378e3 100644
@@ -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,
Signature · 1 line
1.5.4.5
#12 lore raw

PATCH 12/36 firmware: move firmware_class from Documentation/ to samples/

In reply to Greg KH

From: Randy Dunlap <[email protected]>

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

---
 .../firmware_class/firmware_sample_driver.c        |  115 -----------
 .../firmware_sample_firmware_class.c               |  207 --------------------
 samples/firmware_class/firmware_sample_driver.c    |  115 +++++++++++
 .../firmware_sample_firmware_class.c               |  207 ++++++++++++++++++++
 4 files changed, 322 insertions(+), 322 deletions(-)
 delete mode 100644 Documentation/firmware_class/firmware_sample_driver.c
 delete mode 100644 Documentation/firmware_class/firmware_sample_firmware_class.c
 create mode 100644 samples/firmware_class/firmware_sample_driver.c
 create mode 100644 samples/firmware_class/firmware_sample_firmware_class.c
Documentation/firmware_class/firmware_sample_driver.c deleted +0 -115
deleted file mode 100644
index 6865cbe..0000000
@@ -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");
Documentation/firmware_class/firmware_sample_firmware_class.c deleted +0 -207

207 lines not on this page · raw message

samples/firmware_class/firmware_sample_driver.c new file +115 -0

115 lines not on this page · raw message

samples/firmware_class/firmware_sample_firmware_class.c new file +207 -0

207 lines not on this page · raw message

Signature · 1 line
1.5.4.5
#13 lore raw

PATCH 13/36 firmware: clean up samples for coding style issues

In reply to Greg KH

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 <[email protected]>
Cc Marcel Holtmann <[email protected]>
---
 samples/firmware_class/firmware_sample_driver.c    |   45 +++++++++++---------
 .../firmware_sample_firmware_class.c               |   33 +++++++--------
 2 files changed, 40 insertions(+), 38 deletions(-)
samples/firmware_class/firmware_sample_driver.c +25 -20
index ff0f2f2..165cff9 100644
@@ -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");
samples/firmware_class/firmware_sample_firmware_class.c +15 -18
index 2799c47..9392116 100644
@@ -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)
Signature · 1 line
1.5.4.5
#14 lore raw

PATCH 14/36 PNP: add all PNP card device id's as individual aliases

In reply to Greg KH

From: Kay Sievers <[email protected]>

The current PNP combined card + devices module aliase can never ever match anything, because these values are not available all at the same time to request a module.

Instead of adding the combined alias, we add the device id's all as individual aliases. Device id's are exported by the PNP bus and can now properly used to request the loading of a matching module.

The module snd-sbawe currently exports aliases, which can never match anything:
alias: pnp:cCTLXXXXdCTL0045dCTL0022*
alias: pnp:cCTLXXXXdCTL0044dCTL0023*
alias: pnp:cCTLXXXXdCTL0042dCTL0022*
alias: pnp:cCTLXXXXdCTL0041dCTL0021*
alias: pnp:cCTLXXXXdCTL0031dCTL0021*
alias: pnp:cCTL00eddCTL0041dCTL0070*
alias: pnp:cCTL00e9dCTL0045dCTL0022*
alias: pnp:cCTL00e4dCTL0045dCTL0022*
alias: pnp:cCTL00c7dCTL0045dCTL0022*
alias: pnp:cCTL00c5dCTL0045dCTL0022*
alias: pnp:cCTL00c3dCTL0045dCTL0022*
alias: pnp:cCTL00c1dCTL0042dCTL0022*
alias: pnp:cCTL00b2dCTL0044dCTL0023*
alias: pnp:cCTL009edCTL0044dCTL0023*
alias: pnp:cCTL009ddCTL0042dCTL0022*
alias: pnp:cCTL009fdCTL0041dCTL0021*
alias: pnp:cCTL009cdCTL0041dCTL0021*
alias: pnp:cCTL009adCTL0041dCTL0021*
alias: pnp:cCTL0054dCTL0031dCTL0021*
alias: pnp:cCTL0048dCTL0031dCTL0021*
alias: pnp:cCTL0047dCTL0031dCTL0021*
alias: pnp:cCTL0046dCTL0031dCTL0021*
alias: pnp:cCTL0045dCTL0031dCTL0021*
alias: pnp:cCTL0044dCTL0031dCTL0021*
alias: pnp:cCTL0043dCTL0031dCTL0021*
alias: pnp:cCTL0042dCTL0031dCTL0021*
alias: pnp:cCTL0039dCTL0031dCTL0021*
alias: pnp:cCTL0035dCTL0031dCTL0021*

With this patch it exports only the device id's, as properly matchable aliases:
alias: pnp:dCTL0070*
alias: pnp:dCTL0045*
alias: pnp:dCTL0023*
alias: pnp:dCTL0044*
alias: pnp:dCTL0022*
alias: pnp:dCTL0042*
alias: pnp:dCTL0041*
alias: pnp:dCTL0021*
alias: pnp:dCTL0031*

Now, the exported value of the PNP bus can be used to autoload a matching module:

  $ modprobe --first-time -n -v pnp:dCTL0045
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/core/snd-rawmidi.ko
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/drivers/mpu401/snd-mpu401-uart.ko
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/core/snd-hwdep.ko
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sb-common.ko
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sb16-csp.ko
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sb16-dsp.ko
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/drivers/opl3/snd-opl3-lib.ko
  insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sbawe.ko
  $ grep CTL0045 /sys/bus/pnp/devices/*/id
  /sys/bus/pnp/devices/01:01.00/id:CTL0045
---
 scripts/mod/file2alias.c |   57 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 13 deletions(-)
scripts/mod/file2alias.c +44 -13
index 348d868..769b69d 100644
@@ -328,19 +328,52 @@ static int do_pnp_entry(const char *filename,
 	return 1;
 }
 
-/* looks like: "pnp:cCdD..." */
-static int do_pnp_card_entry(const char *filename,
-			struct pnp_card_device_id *id, char *alias)
+/* looks like: "pnp:dD" for every device of the card */
+static void do_pnp_card_entries(void *symval, unsigned long size,
+				struct module *mod)
 {
-	int i;
+	const unsigned long id_size = sizeof(struct pnp_card_device_id);
+	const unsigned int count = (size / id_size)-1;
+	const struct pnp_card_device_id *cards = symval;
+	unsigned int i;
 
-	sprintf(alias, "pnp:c%s", id->id);
-	for (i = 0; i < PNP_MAX_DEVICES; i++) {
-		if (! *id->devs[i].id)
-			break;
-		sprintf(alias + strlen(alias), "d%s", id->devs[i].id);
+	device_id_check(mod->name, "pnp", size, id_size, symval);
+
+	for (i = 0; i < count; i++) {
+		unsigned int j;
+		const struct pnp_card_device_id *card = &cards[i];
+
+		for (j = 0; j < PNP_MAX_DEVICES; j++) {
+			const char *id = (char *)card->devs[j].id;
+			int i2, j2;
+			int dup = 0;
+
+			if (!id[0])
+				break;
+
+			/* find duplicate, already added value */
+			for (i2 = 0; i2 < i && !dup; i2++) {
+				const struct pnp_card_device_id *card2 = &cards[i2];
+
+				for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) {
+					const char *id2 = (char *)card2->devs[j2].id;
+
+					if (!id2[0])
+						break;
+
+					if (!strcmp(id, id2)) {
+						dup = 1;
+						break;
+					}
+				}
+			}
+
+			/* add an individual alias for every device entry */
+			if (!dup)
+				buf_printf(&mod->dev_table_buf,
+					   "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
+		}
 	}
-	return 1;
 }
 
 /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
@@ -634,9 +667,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
 			 sizeof(struct pnp_device_id), "pnp",
 			 do_pnp_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_card_device_table"))
-		do_table(symval, sym->st_size,
-			 sizeof(struct pnp_card_device_id), "pnp_card",
-			 do_pnp_card_entry, mod);
+		do_pnp_card_entries(symval, sym->st_size, mod);
 	else if (sym_is(symname, "__mod_pcmcia_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct pcmcia_device_id), "pcmcia",
Signature · 1 line
1.5.4.5
#15 lore raw

PATCH 15/36 power_state: remove it from driver core

In reply to Greg KH

From: Pavel Machek <[email protected]>

power_state is scheduled for removal, and it is used only for debug prints by driver core. Remove it.

---
 drivers/base/power/main.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/base/power/main.c +0 -5
index d887d5c..26de2c0 100644
@@ -377,11 +377,6 @@ static int suspend_device(struct device *dev, pm_message_t state)
 
 	down(&dev->sem);
 
-	if (dev->power.power_state.event) {
-		dev_dbg(dev, "PM: suspend %d-->%d\n",
-			dev->power.power_state.event, state.event);
-	}
-
 	if (dev->class && dev->class->suspend) {
 		suspend_device_dbg(dev, state, "class ");
 		error = dev->class->suspend(dev, state);
Signature · 1 line
1.5.4.5
#16 lore raw

PATCH 16/36 driver core: cpu: fix section mismatch in cpu.c:store_online

In reply to Greg KH

From: Sam Ravnborg <[email protected]>

Fix following warning:
WARNING: vmlinux.o(.text+0x64609c): Section mismatch in reference from the function store_online() to the function .cpuinit.text:cpu_up()

store_online() is defined inside a HOTPLUG_CPU block so references are OK. Ignore references by annotating store_online() with __ref.

Note: This is needed because cpu_up() most likely should not have been __cpuinit but all the hotplug cpu code misuses the __cpuinit annotation.

---
 drivers/base/cpu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/base/cpu.c +2 -2
index 499b003..3e417a9 100644
@@ -28,7 +28,7 @@ static ssize_t show_online(struct sys_device *dev, char *buf)
 	return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id));
 }
 
-static ssize_t store_online(struct sys_device *dev, const char *buf,
+static ssize_t __ref store_online(struct sys_device *dev, const char *buf,
 			    size_t count)
 {
 	struct cpu *cpu = container_of(dev, struct cpu, sysdev);
@@ -55,7 +55,7 @@ static ssize_t store_online(struct sys_device *dev, const char *buf,
 }
 static SYSDEV_ATTR(online, 0644, show_online, store_online);
 
-static void __devinit register_cpu_control(struct cpu *cpu)
+static void __cpuinit register_cpu_control(struct cpu *cpu)
 {
 	sysdev_create_file(&cpu->sysdev, &attr_online);
 }
Signature · 1 line
1.5.4.5
#17 lore raw

PATCH 17/36 sysdev: detect multiple driver registrations

In reply to Greg KH

From: Ben Dooks <[email protected]>

I've just found how easy it is to accidentally register a sysdev_driver for two different classes. When this happens, bad things happen as the sysdev_driver structure keeps has the list entry for the driver registration.

The following patch makes a WARN_ON() if this happens, although I think BUG_ON or returning -EAGAIN could also be valid responses to this.

---
 drivers/base/sys.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/base/sys.c +16 -0
index 8e13fd9..1a06c23 100644
@@ -167,6 +167,22 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
 {
 	int err = 0;
 
+	if (!cls) {
+		printk(KERN_WARNING "sysdev: invalid class passed to "
+			"sysdev_driver_register!\n");
+		WARN_ON(1);
+		return -EINVAL;
+	}
+
+	/* Check whether this driver has already been added to a class. */
+	if ((drv->entry.next != drv->entry.prev) ||
+	    (drv->entry.next != NULL)) {
+		printk(KERN_WARNING "sysdev: class %s: driver (%p) has already"
+			" been registered to a class, something is wrong, but "
+			"will forge on!\n", cls->name, drv);
+		WARN_ON(1);
+	}
+
 	mutex_lock(&sysdev_drivers_lock);
 	if (cls && kset_get(&cls->kset)) {
 		list_add_tail(&drv->entry, &cls->drivers);
Signature · 1 line
1.5.4.5
#18 lore raw

PATCH 18/36 block: send disk "change" event for rescan_partitions()

In reply to Greg KH

From: Kay Sievers <[email protected]>

Userspace likes to get notified that the disk may have changed, when rescan_partitions() is called after partitioning or media change. It will make it possible to update the state of the disk with the "change" event, before the following partition "add" events are handled.

---
 fs/partitions/check.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
fs/partitions/check.c +4 -0
index 03f808c..6149e4b 100644
@@ -473,6 +473,10 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
 		return 0;
 	if (IS_ERR(state))	/* I/O error reading the partition table */
 		return -EIO;
+
+	/* tell userspace that the media / partition table may have changed */
+	kobject_uevent(&disk->dev.kobj, KOBJ_CHANGE);
+
 	for (p = 1; p < state->limit; p++) {
 		sector_t size = state->parts[p].size;
 		sector_t from = state->parts[p].from;
Signature · 1 line
1.5.4.5
#19 lore raw

PATCH 19/36 PM: Handle device registrations during suspend/resume

In reply to Greg KH

From: Rafael J. Wysocki <[email protected]>

Modify the PM core to protect its data structures, specifically the dpm_active list, from being corrupted if a child of the currently suspending device is registered concurrently with its ->suspend() callback. In that case, since the new device (the child) is added to dpm_active after its parent, the PM core will attempt to suspend it after the parent, which is wrong.

Introduce a new member of struct dev_pm_info, called 'sleeping', and use it to check if the parent of the device being added to dpm_active has been suspended, in which case the device registration fails. Also, use 'sleeping' for checking if the ordering of devices on dpm_active is correct.

Introduce variable 'all_sleeping' that will be set to 'true' once all devices have been suspended and make new device registrations fail until 'all_sleeping' is reset to 'false', in order to avoid having unsuspended devices around while the system is going into a sleep state.

Remove pm_sleep_rwsem which is not necessary any more.

Special thanks to Alan Stern for discussions and suggestions that lead to the creation of this patch.

---
 Documentation/power/devices.txt |    5 +++
 drivers/base/core.c             |    6 +++-
 drivers/base/power/main.c       |   57 +++++++++++++++++---------------------
 drivers/base/power/power.h      |   23 ++-------------
 include/linux/pm.h              |    1 +
 5 files changed, 40 insertions(+), 52 deletions(-)
Documentation/power/devices.txt +5 -0
index 461e4f1..421e7d0 100644
@@ -196,6 +196,11 @@ its parent; and can't be removed or suspended after that parent.
 
 The policy is that the device tree should match hardware bus topology.
 (Or at least the control bus, for devices which use multiple busses.)
+In particular, this means that a device registration may fail if the parent of
+the device is suspending (ie. has been chosen by the PM core as the next
+device to suspend) or has already suspended, as well as after all of the other
+devices have been suspended.  Device drivers must be prepared to cope with such
+situations.
 
 
 Suspending Devices
drivers/base/core.c +5 -1
index 24198ad..79848e6 100644
@@ -820,7 +820,11 @@ int device_add(struct device *dev)
 	error = dpm_sysfs_add(dev);
 	if (error)
 		goto PMError;
-	device_pm_add(dev);
+	error = device_pm_add(dev);
+	if (error) {
+		dpm_sysfs_remove(dev);
+		goto PMError;
+	}
 	error = bus_add_device(dev);
 	if (error)
 		goto BusError;
drivers/base/power/main.c +26 -31

121 lines not on this page · raw message

drivers/base/power/power.h +3 -20
index e32d3bd..a6894f2 100644
@@ -11,30 +11,13 @@ static inline struct device *to_device(struct list_head *entry)
 	return container_of(entry, struct device, power.entry);
 }
 
-extern void device_pm_add(struct device *);
+extern int device_pm_add(struct device *);
 extern void device_pm_remove(struct device *);
-extern int pm_sleep_lock(void);
-extern void pm_sleep_unlock(void);
 
 #else /* CONFIG_PM_SLEEP */
 
-
-static inline void device_pm_add(struct device *dev)
-{
-}
-
-static inline void device_pm_remove(struct device *dev)
-{
-}
-
-static inline int pm_sleep_lock(void)
-{
-	return 0;
-}
-
-static inline void pm_sleep_unlock(void)
-{
-}
+static inline int device_pm_add(struct device *dev) { return 0; }
+static inline void device_pm_remove(struct device *dev) {}
 
 #endif
 
include/linux/pm.h +1 -0
index 015b735..e6b9f29 100644
@@ -183,6 +183,7 @@ typedef struct pm_message {
 struct dev_pm_info {
 	pm_message_t		power_state;
 	unsigned		can_wakeup:1;
+	bool			sleeping:1;	/* Owned by the PM core */
 #ifdef	CONFIG_PM_SLEEP
 	unsigned		should_wakeup:1;
 	struct list_head	entry;
Signature · 1 line
1.5.4.5
#20 lore raw

PATCH 20/36 Driver core: Call device_pm_add() after bus_add_device() in device_add()

In reply to Greg KH

From: Rafael J. Wysocki <[email protected]>

Include dpm_sysfs_add() into device_pm_add(), in analogy with device_pm_remove(), and modify device_add() to call the latter after bus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful.

---
 drivers/base/core.c       |   15 +++++----------
 drivers/base/power/main.c |    4 +++-
 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/base/core.c +5 -10
index 79848e6..adbc017 100644
@@ -817,17 +817,12 @@ int device_add(struct device *dev)
 	error = device_add_attrs(dev);
 	if (error)
 		goto AttrsError;
-	error = dpm_sysfs_add(dev);
-	if (error)
-		goto PMError;
-	error = device_pm_add(dev);
-	if (error) {
-		dpm_sysfs_remove(dev);
-		goto PMError;
-	}
 	error = bus_add_device(dev);
 	if (error)
 		goto BusError;
+	error = device_pm_add(dev);
+	if (error)
+		goto PMError;
 	kobject_uevent(&dev->kobj, KOBJ_ADD);
 	bus_attach_device(dev);
 	if (parent)
@@ -847,9 +842,9 @@ int device_add(struct device *dev)
  Done:
 	put_device(dev);
 	return error;
- BusError:
-	device_pm_remove(dev);
  PMError:
+	bus_remove_device(dev);
+ BusError:
 	if (dev->bus)
 		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
 					     BUS_NOTIFY_DEL_DEVICE, dev);
drivers/base/power/main.c +3 -1
index 0e3991a..93a1469 100644
@@ -81,7 +81,9 @@ int device_pm_add(struct device *dev)
 		WARN_ON(true);
 		error = -EBUSY;
 	} else {
-		list_add_tail(&dev->power.entry, &dpm_active);
+		error = dpm_sysfs_add(dev);
+		if (!error)
+			list_add_tail(&dev->power.entry, &dpm_active);
 	}
 	mutex_unlock(&dpm_list_mtx);
 	return error;
Signature · 1 line
1.5.4.5
#21 lore raw

PATCH 21/36 PM: Fix misuse of wakeup flag accessors in serial core

In reply to Greg KH

From: Alan Stern <[email protected]>

This patch (as1059) fixes a mistake in the way the serial core initializes a device's wakeup settings. It should use the accessor routine instead of relying on a macro producing an lvalue.

---
 drivers/serial/serial_core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/serial/serial_core.c +1 -1
index c32c1ca..a9ca03e 100644
@@ -2422,7 +2422,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
 	 */
 	tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev);
 	if (likely(!IS_ERR(tty_dev))) {
-		device_can_wakeup(tty_dev) = 1;
+		device_init_wakeup(tty_dev, 1);
 		device_set_wakeup_enable(tty_dev, 0);
 	} else
 		printk(KERN_ERR "Cannot register tty device on line %d\n",
Signature · 1 line
1.5.4.5
#22 lore raw

PATCH 22/36 PM: Make wakeup flags available whenever CONFIG_PM is set

In reply to Greg KH

From: Alan Stern <[email protected]>

The various wakeup flags and their accessor macros in struct dev_pm_info should be available whenever CONFIG_PM is enabled, not just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always be configurable for runtime power management. This patch (as1056b) fixes the oversight.

David Brownell adds:
More accurately, fixes the "regression" ... as noted sometime last summer, after 296699de6bdc717189a331ab6bbe90e05c94db06 introduced CONFIG_SUSPEND. But that didn't make the regression list for that kernel, ergo the delay in fixing it.

[rjw: rebased]

---
 drivers/base/power/main.c  |    2 --
 drivers/base/power/sysfs.c |    2 ++
 include/linux/pm.h         |   36 +++++++++++++++++++++---------------
 3 files changed, 23 insertions(+), 17 deletions(-)
drivers/base/power/main.c +0 -2
index 93a1469..5630af3 100644
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);
 /* 'true' if all devices have been suspended, protected by dpm_list_mtx */
 static bool all_sleeping;
 
-int (*platform_enable_wakeup)(struct device *dev, int is_on);
-
 /**
  *	device_pm_add - add a device to the list of active devices
  *	@dev:	Device to be added to the list
drivers/base/power/sysfs.c +2 -0
index f2ed179..d11f74b 100644
@@ -6,6 +6,8 @@
 #include <linux/string.h>
 #include "power.h"
 
+int (*platform_enable_wakeup)(struct device *dev, int is_on);
+
 
 /*
  *	wakeup - Report/change current wakeup option for device
include/linux/pm.h +21 -15
index e6b9f29..3342627 100644
@@ -183,9 +183,9 @@ typedef struct pm_message {
 struct dev_pm_info {
 	pm_message_t		power_state;
 	unsigned		can_wakeup:1;
+	unsigned		should_wakeup:1;
 	bool			sleeping:1;	/* Owned by the PM core */
 #ifdef	CONFIG_PM_SLEEP
-	unsigned		should_wakeup:1;
 	struct list_head	entry;
 #endif
 };
@@ -198,11 +198,6 @@ extern void device_resume(void);
 extern int device_suspend(pm_message_t state);
 extern int device_prepare_suspend(pm_message_t state);
 
-#define device_set_wakeup_enable(dev,val) \
-	((dev)->power.should_wakeup = !!(val))
-#define device_may_wakeup(dev) \
-	(device_can_wakeup(dev) && (dev)->power.should_wakeup)
-
 extern void __suspend_report_result(const char *function, void *fn, int ret);
 
 #define suspend_report_result(fn, ret)					\
@@ -210,6 +205,24 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
 		__suspend_report_result(__FUNCTION__, fn, ret);		\
 	} while (0)
 
+#else /* !CONFIG_PM_SLEEP */
+
+static inline int device_suspend(pm_message_t state)
+{
+	return 0;
+}
+
+#define suspend_report_result(fn, ret) do { } while (0)
+
+#endif /* !CONFIG_PM_SLEEP */
+
+#ifdef CONFIG_PM
+
+#define device_set_wakeup_enable(dev,val) \
+	((dev)->power.should_wakeup = !!(val))
+#define device_may_wakeup(dev) \
+	(device_can_wakeup(dev) && (dev)->power.should_wakeup)
+
 /*
  * Platform hook to activate device wakeup capability, if that's not already
  * handled by enable_irq_wake() etc.
@@ -224,24 +237,17 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
 	return 0;
 }
 
-#else /* !CONFIG_PM_SLEEP */
-
-static inline int device_suspend(pm_message_t state)
-{
-	return 0;
-}
+#else /* !CONFIG_PM */
 
 #define device_set_wakeup_enable(dev,val)	do{}while(0)
 #define device_may_wakeup(dev)			(0)
 
-#define suspend_report_result(fn, ret) do { } while (0)
-
 static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
 {
 	return 0;
 }
 
-#endif /* !CONFIG_PM_SLEEP */
+#endif /* !CONFIG_PM */
 
 /* changes to device_may_wakeup take effect on the next pm state change.
  * by default, devices should wakeup if they can.
Signature · 1 line
1.5.4.5
#23 lore raw

PATCH 23/36 PM: Convert wakeup flag accessors to inline functions

In reply to Greg KH

From: Alan Stern <[email protected]>

This patch (as1058) improves the wakeup macros in include/linux/pm.h. All but the trivial ones are converted to inline routines, which requires moving them to a separate header file since they depend on the definition of struct device.

---
 include/linux/device.h    |    3 +
 include/linux/pm.h        |   46 +----------------------
 include/linux/pm_wakeup.h |   90 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 45 deletions(-)
 create mode 100644 include/linux/pm_wakeup.h
include/linux/device.h +3 -0
index d576611..d7a1ae0 100644
@@ -475,6 +475,9 @@ struct device {
 	void	(*release)(struct device *dev);
 };
 
+/* Get the wakeup routines, which depend on struct device */
+#include <linux/pm_wakeup.h>
+
 #ifdef CONFIG_NUMA
 static inline int dev_to_node(struct device *dev)
 {
include/linux/pm.h +1 -45

55 lines not on this page · raw message

include/linux/pm_wakeup.h new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
1.5.4.5
#24 lore raw

PATCH 24/36 Driver core: make device_is_registered() work for class devices

In reply to Greg KH

device_is_registered() can use the kobject value for this, so it will now work with devices that are associated with only a class, not a bus and a driver.

---
 drivers/base/bus.c     |    9 ++-------
 include/linux/device.h |    3 +--
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/base/bus.c +2 -7
index 2d207ad..450942a 100644
@@ -505,14 +505,11 @@ void bus_attach_device(struct device *dev)
 	int ret = 0;
 
 	if (bus) {
-		dev->is_registered = 1;
 		if (bus->p->drivers_autoprobe)
 			ret = device_attach(dev);
 		WARN_ON(ret < 0);
 		if (ret >= 0)
 			klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
-		else
-			dev->is_registered = 0;
 	}
 }
 
@@ -533,10 +530,8 @@ void bus_remove_device(struct device *dev)
 		sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
 				  dev->bus_id);
 		device_remove_attrs(dev->bus, dev);
-		if (dev->is_registered) {
-			dev->is_registered = 0;
-			klist_del(&dev->knode_bus);
-		}
+		klist_del(&dev->knode_bus);
+
 		pr_debug("bus: '%s': remove device %s\n",
 			 dev->bus->name, dev->bus_id);
 		device_release_driver(dev);
include/linux/device.h +1 -2
index d7a1ae0..441461f 100644
@@ -429,7 +429,6 @@ struct device {
 	struct kobject kobj;
 	char	bus_id[BUS_ID_SIZE];	/* position on parent bus */
 	struct device_type	*type;
-	unsigned		is_registered:1;
 	unsigned		uevent_suppress:1;
 
 	struct semaphore	sem;	/* semaphore to synchronize calls to
@@ -509,7 +508,7 @@ static inline void dev_set_drvdata(struct device *dev, void *data)
 
 static inline int device_is_registered(struct device *dev)
 {
-	return dev->is_registered;
+	return dev->kobj.state_in_sysfs;
 }
 
 void driver_init(void);
Signature · 1 line
1.5.4.5
#25 lore raw

PATCH 25/36 SYSFS: Explicitly include required header file slab.h.

In reply to Greg KH

From: Robert P. J. Day <[email protected]>

After an experimental deletion of the unnecessary inclusion of <linux/slab.h> from the header file <linux/percpu.h>, the following files under fs/sysfs were exposed as needing to explicitly include <linux/slab.h>.

---
 fs/sysfs/dir.c  |    1 +
 fs/sysfs/file.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
fs/sysfs/dir.c +1 -0
index 4948d9b..a1c3a1f 100644
@@ -20,6 +20,7 @@
 #include <linux/idr.h>
 #include <linux/completion.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include "sysfs.h"
 
 DEFINE_MUTEX(sysfs_mutex);
fs/sysfs/file.c +1 -0
index baa663e..a859c32 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/kobject.h>
 #include <linux/kallsyms.h>
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/poll.h>
 #include <linux/list.h>
Signature · 1 line
1.5.4.5
#26 lore raw

PATCH 26/36 Kobject: Replace list_for_each() with list_for_each_entry().

In reply to Greg KH

From: Robert P. J. Day <[email protected]>

Use the more concise list_for_each_entry(), which allows for the deletion of the to_kobj() routine at the same time.

---
 lib/kobject.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
lib/kobject.c +2 -8
index 60ae9e8..2c64903 100644
@@ -58,11 +58,6 @@ static int create_dir(struct kobject *kobj)
 	return error;
 }
 
-static inline struct kobject *to_kobj(struct list_head *entry)
-{
-	return container_of(entry, struct kobject, entry);
-}
-
 static int get_kobj_path_length(struct kobject *kobj)
 {
 	int length = 1;
@@ -752,12 +747,11 @@ void kset_unregister(struct kset *k)
  */
 struct kobject *kset_find_obj(struct kset *kset, const char *name)
 {
-	struct list_head *entry;
+	struct kobject *k;
 	struct kobject *ret = NULL;
 
 	spin_lock(&kset->list_lock);
-	list_for_each(entry, &kset->list) {
-		struct kobject *k = to_kobj(entry);
+	list_for_each_entry(k, &kset->list, entry) {
 		if (kobject_name(k) && !strcmp(kobject_name(k), name)) {
 			ret = kobject_get(k);
 			break;
Signature · 1 line
1.5.4.5
#27 lore raw

PATCH 27/36 PM: Remove legacy PM (fix)

In reply to Greg KH

From: Randy Dunlap <[email protected]>

Source file was removed. Need to remove docbook reference also.

---
 Documentation/DocBook/kernel-api.tmpl |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
Documentation/DocBook/kernel-api.tmpl +0 -5
index dc0f30c..488dd4a 100644
@@ -297,11 +297,6 @@ X!Earch/x86/kernel/mca_32.c
 !Ikernel/acct.c
   </chapter>
 
-  <chapter id="pmfuncs">
-     <title>Power Management</title>
-!Ekernel/power/pm.c
-  </chapter>
-
   <chapter id="devdrivers">
      <title>Device drivers infrastructure</title>
      <sect1><title>Device Drivers Base</title>
Signature · 1 line
1.5.4.5
#29 lore raw

PATCH 29/36 PM: Remove destroy_suspended_device()

In reply to Greg KH

From: Rafael J. Wysocki <[email protected]>

After 2.6.24 there was a plan to make the PM core acquire all device semaphores during a suspend/hibernation to protect itself from concurrent operations involving device objects. That proved to be too heavy-handed and we found a better way to achieve the goal, but before it happened, we had introduced the functions device_pm_schedule_removal() and destroy_suspended_device() to allow drivers to "safely" destroy a suspended device and we had adapted some drivers to use them. Now that these functions are no longer necessary, it seems reasonable to remove them and modify their users to use the normal device unregistration instead.

---
 arch/x86/kernel/cpuid.c         |    4 +--
 arch/x86/kernel/msr.c           |    4 +--
 drivers/base/core.c             |   29 ----------------------------
 drivers/base/power/main.c       |   40 ---------------------------------------
 drivers/char/hw_random/core.c   |   10 ++++----
 drivers/char/misc.c             |   13 +++--------
 drivers/leds/led-class.c        |   11 ++-------
 drivers/net/wireless/b43/leds.c |    5 +---
 drivers/net/wireless/b43/main.c |    8 +++---
 include/linux/device.h          |   14 -------------
 include/linux/hw_random.h       |   10 +--------
 include/linux/leds.h            |   10 +--------
 include/linux/miscdevice.h      |   10 +--------
 13 files changed, 22 insertions(+), 146 deletions(-)
arch/x86/kernel/cpuid.c +1 -3
index 288e7a6..daff52a 100644
@@ -154,12 +154,10 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
 		err = cpuid_device_create(cpu);
 		break;
 	case CPU_UP_CANCELED:
+	case CPU_UP_CANCELED_FROZEN:
 	case CPU_DEAD:
 		cpuid_device_destroy(cpu);
 		break;
-	case CPU_UP_CANCELED_FROZEN:
-		destroy_suspended_device(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
-		break;
 	}
 	return err ? NOTIFY_BAD : NOTIFY_OK;
 }
arch/x86/kernel/msr.c +1 -3
index 4dfb405..1f3abe0 100644
@@ -162,12 +162,10 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
 		err = msr_device_create(cpu);
 		break;
 	case CPU_UP_CANCELED:
+	case CPU_UP_CANCELED_FROZEN:
 	case CPU_DEAD:
 		msr_device_destroy(cpu);
 		break;
-	case CPU_UP_CANCELED_FROZEN:
-		destroy_suspended_device(msr_class, MKDEV(MSR_MAJOR, cpu));
-		break;
 	}
 	return err ? NOTIFY_BAD : NOTIFY_OK;
 }
drivers/base/core.c +0 -29
index adbc017..0262fc7 100644
@@ -1163,35 +1163,6 @@ void device_destroy(struct class *class, dev_t devt)
 }
 EXPORT_SYMBOL_GPL(device_destroy);
 
-#ifdef CONFIG_PM_SLEEP
-/**
- * destroy_suspended_device - asks the PM core to remove a suspended device
- * @class: pointer to the struct class that this device was registered with
- * @devt: the dev_t of the device that was previously registered
- *
- * This call notifies the PM core of the necessity to unregister a suspended
- * device created with a call to device_create() (devices cannot be
- * unregistered directly while suspended, since the PM core holds their
- * semaphores at that time).
- *
- * It can only be called within the scope of a system sleep transition.  In
- * practice this means it has to be directly or indirectly invoked either by
- * a suspend or resume method, or by the PM core (e.g. via
- * disable_nonboot_cpus() or enable_nonboot_cpus()).
- */
-void destroy_suspended_device(struct class *class, dev_t devt)
-{
-	struct device *dev;
-
-	dev = class_find_device(class, &devt, __match_devt);
-	if (dev) {
-		device_pm_schedule_removal(dev);
-		put_device(dev);
-	}
-}
-EXPORT_SYMBOL_GPL(destroy_suspended_device);
-#endif /* CONFIG_PM_SLEEP */
-
 /**
  * device_rename - renames a device
  * @dev: the pointer to the struct device to be renamed
drivers/base/power/main.c +0 -40
index 5630af3..c4568b8 100644
@@ -50,7 +50,6 @@
 LIST_HEAD(dpm_active);
 static LIST_HEAD(dpm_off);
 static LIST_HEAD(dpm_off_irq);
-static LIST_HEAD(dpm_destroy);
 
 static DEFINE_MUTEX(dpm_list_mtx);
 
@@ -104,24 +103,6 @@ void device_pm_remove(struct device *dev)
 	mutex_unlock(&dpm_list_mtx);
 }
 
-/**
- *	device_pm_schedule_removal - schedule the removal of a suspended device
- *	@dev:	Device to destroy
- *
- *	Moves the device to the dpm_destroy list for further processing by
- *	unregister_dropped_devices().
- */
-void device_pm_schedule_removal(struct device *dev)
-{
-	pr_debug("PM: Preparing for removal: %s:%s\n",
-		dev->bus ? dev->bus->name : "No Bus",
-		kobject_name(&dev->kobj));
-	mutex_lock(&dpm_list_mtx);
-	list_move_tail(&dev->power.entry, &dpm_destroy);
-	mutex_unlock(&dpm_list_mtx);
-}
-EXPORT_SYMBOL_GPL(device_pm_schedule_removal);
-
 /*------------------------- Resume routines -------------------------*/
 
 /**
@@ -246,26 +227,6 @@ static void dpm_resume(void)
 }
 
 /**
- *	unregister_dropped_devices - Unregister devices scheduled for removal
- *
- *	Unregister all devices on the dpm_destroy list.
- */
-static void unregister_dropped_devices(void)
-{
-	mutex_lock(&dpm_list_mtx);
-	while (!list_empty(&dpm_destroy)) {
-		struct list_head *entry = dpm_destroy.next;
-		struct device *dev = to_device(entry);
-
-		mutex_unlock(&dpm_list_mtx);
-		/* This also removes the device from the list */
-		device_unregister(dev);
-		mutex_lock(&dpm_list_mtx);
-	}
-	mutex_unlock(&dpm_list_mtx);
-}
-
-/**
  *	device_resume - Restore state of each device in system.
  *
  *	Resume all the devices, unlock them all, and allow new
@@ -275,7 +236,6 @@ void device_resume(void)
 {
 	might_sleep();
 	dpm_resume();
-	unregister_dropped_devices();
 }
 EXPORT_SYMBOL_GPL(device_resume);
 
drivers/char/hw_random/core.c +5 -5
index 349b6ed..662d60e 100644
@@ -238,11 +238,11 @@ static DEVICE_ATTR(rng_available, S_IRUGO,
 		   NULL);
 
 
-static void unregister_miscdev(bool suspended)
+static void unregister_miscdev(void)
 {
 	device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available);
 	device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
-	__misc_deregister(&rng_miscdev, suspended);
+	misc_deregister(&rng_miscdev);
 }
 
 static int register_miscdev(void)
@@ -317,7 +317,7 @@ out:
 }
 EXPORT_SYMBOL_GPL(hwrng_register);
 
-void __hwrng_unregister(struct hwrng *rng, bool suspended)
+void hwrng_unregister(struct hwrng *rng)
 {
 	int err;
 
@@ -336,11 +336,11 @@ void __hwrng_unregister(struct hwrng *rng, bool suspended)
 		}
 	}
 	if (list_empty(&rng_list))
-		unregister_miscdev(suspended);
+		unregister_miscdev();
 
 	mutex_unlock(&rng_mutex);
 }
-EXPORT_SYMBOL_GPL(__hwrng_unregister);
+EXPORT_SYMBOL_GPL(hwrng_unregister);
 
 
 MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
drivers/char/misc.c +4 -9
index a39101f..4d058da 100644
@@ -232,9 +232,8 @@ int misc_register(struct miscdevice * misc)
 }
 
 /**
- *	__misc_deregister - unregister a miscellaneous device
+ *	misc_deregister - unregister a miscellaneous device
  *	@misc: device to unregister
- *	@suspended: to be set if the function is used during suspend/resume
  *
  *	Unregister a miscellaneous device that was previously
  *	successfully registered with misc_register(). Success
@@ -242,7 +241,7 @@ int misc_register(struct miscdevice * misc)
  *	indicates an error.
  */
 
-int __misc_deregister(struct miscdevice *misc, bool suspended)
+int misc_deregister(struct miscdevice *misc)
 {
 	int i = misc->minor;
 
@@ -251,11 +250,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended)
 
 	mutex_lock(&misc_mtx);
 	list_del(&misc->list);
-	if (suspended)
-		destroy_suspended_device(misc_class,
-					MKDEV(MISC_MAJOR, misc->minor));
-	else
-		device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
+	device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
 	if (i < DYNAMIC_MINORS && i>0) {
 		misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
 	}
@@ -264,7 +259,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended)
 }
 
 EXPORT_SYMBOL(misc_register);
-EXPORT_SYMBOL(__misc_deregister);
+EXPORT_SYMBOL(misc_deregister);
 
 static int __init misc_init(void)
 {
drivers/leds/led-class.c +3 -8
index 4a93878..63aad90 100644
@@ -139,12 +139,10 @@ EXPORT_SYMBOL_GPL(led_classdev_register);
 /**
  * __led_classdev_unregister - unregisters a object of led_properties class.
  * @led_cdev: the led device to unregister
- * @suspended: indicates whether system-wide suspend or resume is in progress
  *
  * Unregisters a previously registered via led_classdev_register object.
  */
-void __led_classdev_unregister(struct led_classdev *led_cdev,
-				      bool suspended)
+void led_classdev_unregister(struct led_classdev *led_cdev)
 {
 	device_remove_file(led_cdev->dev, &dev_attr_brightness);
 #ifdef CONFIG_LEDS_TRIGGERS
@@ -155,16 +153,13 @@ void __led_classdev_unregister(struct led_classdev *led_cdev,
 	up_write(&led_cdev->trigger_lock);
 #endif
 
-	if (suspended)
-		device_pm_schedule_removal(led_cdev->dev);
-	else
-		device_unregister(led_cdev->dev);
+	device_unregister(led_cdev->dev);
 
 	down_write(&leds_list_lock);
 	list_del(&led_cdev->node);
 	up_write(&leds_list_lock);
 }
-EXPORT_SYMBOL_GPL(__led_classdev_unregister);
+EXPORT_SYMBOL_GPL(led_classdev_unregister);
 
 static int __init leds_init(void)
 {
drivers/net/wireless/b43/leds.c +1 -4
index 0aac1ff..36a9c42 100644
@@ -116,10 +116,7 @@ static void b43_unregister_led(struct b43_led *led)
 {
 	if (!led->dev)
 		return;
-	if (led->dev->suspend_in_progress)
-		led_classdev_unregister_suspended(&led->led_dev);
-	else
-		led_classdev_unregister(&led->led_dev);
+	led_classdev_unregister(&led->led_dev);
 	b43_led_turn_off(led->dev, led->index, led->activelow);
 	led->dev = NULL;
 }
drivers/net/wireless/b43/main.c +4 -4
index cf5c046..943cc85 100644
@@ -2804,10 +2804,10 @@ static int b43_rng_read(struct hwrng *rng, u32 * data)
 	return (sizeof(u16));
 }
 
-static void b43_rng_exit(struct b43_wl *wl, bool suspended)
+static void b43_rng_exit(struct b43_wl *wl)
 {
 	if (wl->rng_initialized)
-		__hwrng_unregister(&wl->rng, suspended);
+		hwrng_unregister(&wl->rng);
 }
 
 static int b43_rng_init(struct b43_wl *wl)
@@ -3824,7 +3824,7 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
 
 	if (!dev->suspend_in_progress) {
 		b43_leds_exit(dev);
-		b43_rng_exit(dev->wl, false);
+		b43_rng_exit(dev->wl);
 	}
 	b43_dma_free(dev);
 	b43_pio_free(dev);
@@ -4589,7 +4589,7 @@ static int b43_resume(struct ssb_device *dev)
 		err = b43_wireless_core_start(wldev);
 		if (err) {
 			b43_leds_exit(wldev);
-			b43_rng_exit(wldev->wl, true);
+			b43_rng_exit(wldev->wl);
 			b43_wireless_core_exit(wldev);
 			b43err(wl, "Resume failed at core start\n");
 			goto out;
include/linux/device.h +0 -14
index 441461f..dc3429e 100644
@@ -545,20 +545,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
 				    dev_t devt, const char *fmt, ...)
 				    __attribute__((format(printf, 4, 5)));
 extern void device_destroy(struct class *cls, dev_t devt);
-#ifdef CONFIG_PM_SLEEP
-extern void destroy_suspended_device(struct class *cls, dev_t devt);
-extern void device_pm_schedule_removal(struct device *);
-#else /* !CONFIG_PM_SLEEP */
-static inline void destroy_suspended_device(struct class *cls, dev_t devt)
-{
-	device_destroy(cls, devt);
-}
-
-static inline void device_pm_schedule_removal(struct device *dev)
-{
-	device_unregister(dev);
-}
-#endif /* !CONFIG_PM_SLEEP */
 
 /*
  * Platform "fixup" functions - allow the platform to have their say
include/linux/hw_random.h +1 -9
index 4213182..85d1191 100644
@@ -44,15 +44,7 @@ struct hwrng {
 /** Register a new Hardware Random Number Generator driver. */
 extern int hwrng_register(struct hwrng *rng);
 /** Unregister a Hardware Random Number Generator driver. */
-extern void __hwrng_unregister(struct hwrng *rng, bool suspended);
-static inline void hwrng_unregister(struct hwrng *rng)
-{
-	__hwrng_unregister(rng, false);
-}
-static inline void hwrng_unregister_suspended(struct hwrng *rng)
-{
-	__hwrng_unregister(rng, true);
-}
+extern void hwrng_unregister(struct hwrng *rng);
 
 #endif /* __KERNEL__ */
 #endif /* LINUX_HWRANDOM_H_ */
include/linux/leds.h +1 -9
index 0201f6f..b07e3d4 100644
@@ -59,15 +59,7 @@ struct led_classdev {
 
 extern int led_classdev_register(struct device *parent,
 				 struct led_classdev *led_cdev);
-extern void __led_classdev_unregister(struct led_classdev *led_cdev, bool sus);
-static inline void led_classdev_unregister(struct led_classdev *lcd)
-{
-	__led_classdev_unregister(lcd, false);
-}
-static inline void led_classdev_unregister_suspended(struct led_classdev *lcd)
-{
-	__led_classdev_unregister(lcd, true);
-}
+extern void led_classdev_unregister(struct led_classdev *lcd);
 extern void led_classdev_suspend(struct led_classdev *led_cdev);
 extern void led_classdev_resume(struct led_classdev *led_cdev);
 
include/linux/miscdevice.h +1 -9
index 24b30b9..26433ec 100644
@@ -43,15 +43,7 @@ struct miscdevice  {
 };
 
 extern int misc_register(struct miscdevice * misc);
-extern int __misc_deregister(struct miscdevice *misc, bool suspended);
-static inline int misc_deregister(struct miscdevice *misc)
-{
-	return __misc_deregister(misc, false);
-}
-static inline int misc_deregister_suspended(struct miscdevice *misc)
-{
-	return __misc_deregister(misc, true);
-}
+extern int misc_deregister(struct miscdevice *misc);
 
 #define MODULE_ALIAS_MISCDEV(minor)				\
 	MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR)	\
Signature · 1 line
1.5.4.5
#28 lore raw

PATCH 28/36 Firmware: add iSCSI iBFT Support

In reply to Greg KH

From: Konrad Rzeszutek <[email protected]>

Add /sysfs/firmware/ibft/[initiator|targetX|ethernetX] directories along with text properties which export the the iSCSI Boot Firmware Table (iBFT) structure.

What is iSCSI Boot Firmware Table? It is a mechanism for the iSCSI tools to extract from the machine NICs the iSCSI connection information so that they can automagically mount the iSCSI share/target. Currently the iSCSI information is hard-coded in the initrd. The /sysfs entries are read-only one-name-and-value fields.

The usual set of data exposed is:

# for a in `find /sys/firmware/ibft/ -type f -print`; do  echo -n "$a: ";  cat $a; done
/sys/firmware/ibft/target0/target-name: iqn.2007.com.intel-sbx44:storage-10gb
/sys/firmware/ibft/target0/nic-assoc: 0
/sys/firmware/ibft/target0/chap-type: 0
/sys/firmware/ibft/target0/lun: 00000000
/sys/firmware/ibft/target0/port: 3260
/sys/firmware/ibft/target0/ip-addr: 192.168.79.116
/sys/firmware/ibft/target0/flags: 3
/sys/firmware/ibft/target0/index: 0
/sys/firmware/ibft/ethernet0/mac: 00:11:25:9d:8b:01
/sys/firmware/ibft/ethernet0/vlan: 0
/sys/firmware/ibft/ethernet0/gateway: 192.168.79.254
/sys/firmware/ibft/ethernet0/origin: 0
/sys/firmware/ibft/ethernet0/subnet-mask: 255.255.252.0
/sys/firmware/ibft/ethernet0/ip-addr: 192.168.77.41
/sys/firmware/ibft/ethernet0/flags: 7
/sys/firmware/ibft/ethernet0/index: 0
/sys/firmware/ibft/initiator/initiator-name: iqn.2007-07.com:konrad.initiator
/sys/firmware/ibft/initiator/flags: 3
/sys/firmware/ibft/initiator/index: 0

For full details of the IBFT structure please take a look at:
ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf

[[email protected]: fix build]
Cc Mike Christie <[email protected]>
Cc Peter Jones <[email protected]>
Cc James Bottomley <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 Documentation/ABI/testing/sysfs-ibft |   23 +
 arch/x86/kernel/setup_32.c           |    3 +
 arch/x86/kernel/setup_64.c           |    4 +
 drivers/firmware/Kconfig             |   20 +
 drivers/firmware/Makefile            |    2 +
 drivers/firmware/iscsi_ibft.c        |  982 ++++++++++++++++++++++++++++++++++
 drivers/firmware/iscsi_ibft_find.c   |   84 +++
 include/linux/iscsi_ibft.h           |   50 ++
 8 files changed, 1168 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-ibft
 create mode 100644 drivers/firmware/iscsi_ibft.c
 create mode 100644 drivers/firmware/iscsi_ibft_find.c
 create mode 100644 include/linux/iscsi_ibft.h
Documentation/ABI/testing/sysfs-ibft new file +23 -0
new file mode 100644
index 0000000..c2b7d11
@@ -0,0 +1,23 @@
+What:		/sys/firmware/ibft/initiator
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/initiator directory will contain
+		files that expose the iSCSI Boot Firmware Table initiator data.
+		Usually this contains the Initiator name.
+
+What:		/sys/firmware/ibft/targetX
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/targetX directory will contain
+		files that expose the iSCSI Boot Firmware Table target data.
+		Usually this contains the target's IP address, boot LUN,
+		target name, and what NIC it is associated with. It can also
+		contain the CHAP name (and password), the reverse CHAP
+		name (and password)
+
+What:		/sys/firmware/ibft/ethernetX
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/ethernetX directory will contain
+		files that expose the iSCSI Boot Firmware Table NIC data.
+		This can this can the IP address, MAC, and gateway of the NIC.
arch/x86/kernel/setup_32.c +3 -0
index 5b0bffb..4ef9174 100644
@@ -39,6 +39,7 @@
 #include <linux/efi.h>
 #include <linux/init.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/nodemask.h>
 #include <linux/kexec.h>
 #include <linux/crash_dump.h>
@@ -689,6 +690,8 @@ void __init setup_bootmem_allocator(void)
 #endif
 	numa_kva_reserve();
 	reserve_crashkernel();
+
+	reserve_ibft_region();
 }
 
 /*
arch/x86/kernel/setup_64.c +4 -0
index 674ef35..216c93b 100644
@@ -33,6 +33,7 @@
 #include <linux/acpi.h>
 #include <linux/kallsyms.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/mmzone.h>
 #include <linux/kexec.h>
 #include <linux/cpufreq.h>
@@ -434,6 +435,9 @@ void __init setup_arch(char **cmdline_p)
 	}
 #endif
 	reserve_crashkernel();
+
+	reserve_ibft_region();
+
 	paging_init();
 	map_vsyscall();
 
drivers/firmware/Kconfig +20 -0
index 05f02a3..40ffd76 100644
@@ -93,4 +93,24 @@ config DMIID
 	  information from userspace through /sys/class/dmi/id/ or if you want
 	  DMI-based module auto-loading.
 
+config ISCSI_IBFT_FIND
+	bool "iSCSI Boot Firmware Table Attributes"
+	depends on X86
+	default n
+	help
+	  This option enables the kernel to find the region of memory
+	  in which the ISCSI Boot Firmware Table (iBFT) resides. This
+	  is necessary for iSCSI Boot Firmware Table Attributes module to work
+	  properly.
+
+config ISCSI_IBFT
+	tristate "iSCSI Boot Firmware Table Attributes module"
+	depends on ISCSI_IBFT_FIND
+	default	n
+	help
+	  This option enables support for detection and exposing of iSCSI
+	  Boot Firmware Table (iBFT) via sysfs to userspace. If you wish to
+	  detect iSCSI boot parameters dynamically during system boot, say Y.
+	  Otherwise, say N.
+
 endmenu
drivers/firmware/Makefile +2 -0
index 8d4ebc8..4c91471 100644
@@ -8,3 +8,5 @@ obj-$(CONFIG_EFI_PCDP)		+= pcdp.o
 obj-$(CONFIG_DELL_RBU)          += dell_rbu.o
 obj-$(CONFIG_DCDBAS)		+= dcdbas.o
 obj-$(CONFIG_DMIID)		+= dmi-id.o
+obj-$(CONFIG_ISCSI_IBFT_FIND)	+= iscsi_ibft_find.o
+obj-$(CONFIG_ISCSI_IBFT)	+= iscsi_ibft.o
drivers/firmware/iscsi_ibft.c new file +982 -0

982 lines not on this page · raw message

drivers/firmware/iscsi_ibft_find.c new file +84 -0

84 lines not on this page · raw message

include/linux/iscsi_ibft.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
1.5.4.5
#30 lore raw

PATCH 30/36 sysfs: refill attribute buffer when reading from offset 0

In reply to Greg KH

From: Dan Williams <[email protected]>

Requiring userspace to close and re-open sysfs attributes has been the policy since before 2.6.12. It allows userspace to get a consistent snapshot of kernel state and consume it with incremental reads and seeks.

Now, if the file position is zero the kernel assumes userspace wants to see the new value. The application for this change is to allow a userspace RAID metadata handler to check the state of an array without causing any memory allocations. Thus not causing writeback to a raid array that might be blocked waiting for userspace to take action.

---
 Documentation/filesystems/sysfs.txt |    9 +++++++--
 fs/sysfs/file.c                     |    5 ++---
 2 files changed, 9 insertions(+), 5 deletions(-)
Documentation/filesystems/sysfs.txt +7 -2
index 4598ef7..7f27b8f 100644
@@ -176,8 +176,10 @@ implementations:
   Recall that an attribute should only be exporting one value, or an
   array of similar values, so this shouldn't be that expensive. 
 
-  This allows userspace to do partial reads and seeks arbitrarily over
-  the entire file at will. 
+  This allows userspace to do partial reads and forward seeks
+  arbitrarily over the entire file at will. If userspace seeks back to
+  zero or does a pread(2) with an offset of '0' the show() method will
+  be called again, rearmed, to fill the buffer.
 
 - On write(2), sysfs expects the entire buffer to be passed during the
   first write. Sysfs then passes the entire buffer to the store()
@@ -192,6 +194,9 @@ implementations:
 
 Other notes:
 
+- Writing causes the show() method to be rearmed regardless of current
+  file position.
+
 - The buffer will always be PAGE_SIZE bytes in length. On i386, this
   is 4096. 
 
fs/sysfs/file.c +2 -3
index a859c32..ade9a7e 100644
@@ -129,7 +129,7 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	ssize_t retval = 0;
 
 	mutex_lock(&buffer->mutex);
-	if (buffer->needs_read_fill) {
+	if (buffer->needs_read_fill || *ppos == 0) {
 		retval = fill_read_buffer(file->f_path.dentry,buffer);
 		if (retval)
 			goto out;
@@ -410,8 +410,7 @@ static int sysfs_release(struct inode *inode, struct file *filp)
  * return POLLERR|POLLPRI, and select will return the fd whether
  * it is waiting for read, write, or exceptions.
  * Once poll/select indicates that the value has changed, you
- * need to close and re-open the file, as simply seeking and reading
- * again will not get new data, or reset the state of 'poll'.
+ * need to close and re-open the file, or seek to 0 and read again.
  * Reminder: this only works for attributes which actively support
  * it, and it is not possible to test an attribute from userspace
  * to see if it supports poll (Neither 'poll' nor 'select' return
Signature · 1 line
1.5.4.5
#31 lore raw

PATCH 31/36 driver core: replace remaining __FUNCTION__ occurrences

In reply to Greg KH

From: Harvey Harrison <[email protected]>

__FUNCTION__ is gcc-specific, use __func__

---
 drivers/base/bus.c            |    8 ++++----
 drivers/base/class.c          |    8 ++++----
 drivers/base/core.c           |   18 +++++++++---------
 drivers/base/dd.c             |   14 +++++++-------
 drivers/base/firmware_class.c |   18 +++++++++---------
 drivers/base/memory.c         |    4 ++--
 drivers/base/sys.c            |    2 +-
 7 files changed, 36 insertions(+), 36 deletions(-)
drivers/base/bus.c +4 -4
index 450942a..be1cc51 100644
@@ -79,7 +79,7 @@ static void driver_release(struct kobject *kobj)
 {
 	struct driver_private *drv_priv = to_driver(kobj);
 
-	pr_debug("driver: '%s': %s\n", kobject_name(kobj), __FUNCTION__);
+	pr_debug("driver: '%s': %s\n", kobject_name(kobj), __func__);
 	kfree(drv_priv);
 }
 
@@ -677,19 +677,19 @@ int bus_add_driver(struct device_driver *drv)
 	error = driver_create_file(drv, &driver_attr_uevent);
 	if (error) {
 		printk(KERN_ERR "%s: uevent attr (%s) failed\n",
-			__FUNCTION__, drv->name);
+			__func__, drv->name);
 	}
 	error = driver_add_attrs(bus, drv);
 	if (error) {
 		/* How the hell do we get out of this pickle? Give up */
 		printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
-			__FUNCTION__, drv->name);
+			__func__, drv->name);
 	}
 	error = add_bind_files(drv);
 	if (error) {
 		/* Ditto */
 		printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
-			__FUNCTION__, drv->name);
+			__func__, drv->name);
 	}
 
 	kobject_uevent(&priv->kobj, KOBJ_ADD);
drivers/base/class.c +4 -4
index 9d91537..b490179 100644
@@ -175,13 +175,13 @@ void class_unregister(struct class *cls)
 
 static void class_create_release(struct class *cls)
 {
-	pr_debug("%s called for %s\n", __FUNCTION__, cls->name);
+	pr_debug("%s called for %s\n", __func__, cls->name);
 	kfree(cls);
 }
 
 static void class_device_create_release(struct class_device *class_dev)
 {
-	pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id);
+	pr_debug("%s called for %s\n", __func__, class_dev->class_id);
 	kfree(class_dev);
 }
 
@@ -189,7 +189,7 @@ static void class_device_create_release(struct class_device *class_dev)
 static int class_device_create_uevent(struct class_device *class_dev,
 				      struct kobj_uevent_env *env)
 {
-	pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id);
+	pr_debug("%s called for %s\n", __func__, class_dev->class_id);
 	return 0;
 }
 
@@ -415,7 +415,7 @@ static int class_uevent(struct kset *kset, struct kobject *kobj,
 	struct device *dev = class_dev->dev;
 	int retval = 0;
 
-	pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
+	pr_debug("%s - name = %s\n", __func__, class_dev->class_id);
 
 	if (MAJOR(class_dev->devt)) {
 		add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt));
drivers/base/core.c +9 -9
index 0262fc7..0737fe5 100644
@@ -207,7 +207,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
 		retval = dev->bus->uevent(dev, env);
 		if (retval)
 			pr_debug("device: '%s': %s: bus uevent() returned %d\n",
-				 dev->bus_id, __FUNCTION__, retval);
+				 dev->bus_id, __func__, retval);
 	}
 
 	/* have the class specific function add its stuff */
@@ -216,7 +216,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
 		if (retval)
 			pr_debug("device: '%s': %s: class uevent() "
 				 "returned %d\n", dev->bus_id,
-				 __FUNCTION__, retval);
+				 __func__, retval);
 	}
 
 	/* have the device type specific fuction add its stuff */
@@ -225,7 +225,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
 		if (retval)
 			pr_debug("device: '%s': %s: dev_type uevent() "
 				 "returned %d\n", dev->bus_id,
-				 __FUNCTION__, retval);
+				 __func__, retval);
 	}
 
 	return retval;
@@ -782,7 +782,7 @@ int device_add(struct device *dev)
 		goto Done;
 	}
 
-	pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);
+	pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
 
 	parent = get_device(dev->parent);
 	setup_parent(dev, parent);
@@ -980,7 +980,7 @@ void device_del(struct device *dev)
  */
 void device_unregister(struct device *dev)
 {
-	pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);
+	pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
 	device_del(dev);
 	put_device(dev);
 }
@@ -1075,7 +1075,7 @@ EXPORT_SYMBOL_GPL(device_remove_file);
 
 static void device_create_release(struct device *dev)
 {
-	pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);
+	pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
 	kfree(dev);
 }
 
@@ -1180,7 +1180,7 @@ int device_rename(struct device *dev, char *new_name)
 		return -EINVAL;
 
 	pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id,
-		 __FUNCTION__, new_name);
+		 __func__, new_name);
 
 #ifdef CONFIG_SYSFS_DEPRECATED
 	if ((dev->class) && (dev->parent))
@@ -1219,7 +1219,7 @@ int device_rename(struct device *dev, char *new_name)
 					  dev->bus_id);
 		if (error) {
 			dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n",
-				__FUNCTION__, error);
+				__func__, error);
 		}
 	}
 #endif
@@ -1295,7 +1295,7 @@ int device_move(struct device *dev, struct device *new_parent)
 	new_parent_kobj = get_device_parent(dev, new_parent);
 
 	pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id,
-		 __FUNCTION__, new_parent ? new_parent->bus_id : "<NULL>");
+		 __func__, new_parent ? new_parent->bus_id : "<NULL>");
 	error = kobject_move(&dev->kobj, new_parent_kobj);
 	if (error) {
 		cleanup_glue_dir(dev, new_parent_kobj);
drivers/base/dd.c +7 -7
index a5cde94..3ac443b 100644
@@ -30,12 +30,12 @@ static void driver_bound(struct device *dev)
 {
 	if (klist_node_attached(&dev->knode_driver)) {
 		printk(KERN_WARNING "%s: device %s already bound\n",
-			__FUNCTION__, kobject_name(&dev->kobj));
+			__func__, kobject_name(&dev->kobj));
 		return;
 	}
 
 	pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id,
-		 __FUNCTION__, dev->driver->name);
+		 __func__, dev->driver->name);
 
 	if (dev->bus)
 		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
@@ -104,13 +104,13 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 
 	atomic_inc(&probe_count);
 	pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
-		 drv->bus->name, __FUNCTION__, drv->name, dev->bus_id);
+		 drv->bus->name, __func__, drv->name, dev->bus_id);
 	WARN_ON(!list_empty(&dev->devres_head));
 
 	dev->driver = drv;
 	if (driver_sysfs_add(dev)) {
 		printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
-			__FUNCTION__, dev->bus_id);
+			__func__, dev->bus_id);
 		goto probe_failed;
 	}
 
@@ -127,7 +127,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 	driver_bound(dev);
 	ret = 1;
 	pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
-		 drv->bus->name, __FUNCTION__, dev->bus_id, drv->name);
+		 drv->bus->name, __func__, dev->bus_id, drv->name);
 	goto done;
 
 probe_failed:
@@ -160,7 +160,7 @@ done:
  */
 int driver_probe_done(void)
 {
-	pr_debug("%s: probe_count = %d\n", __FUNCTION__,
+	pr_debug("%s: probe_count = %d\n", __func__,
 		 atomic_read(&probe_count));
 	if (atomic_read(&probe_count))
 		return -EBUSY;
@@ -194,7 +194,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
 		goto done;
 
 	pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
-		 drv->bus->name, __FUNCTION__, dev->bus_id, drv->name);
+		 drv->bus->name, __func__, dev->bus_id, drv->name);
 
 	ret = really_probe(dev, drv);
 
drivers/base/firmware_class.c +9 -9
index 4a1b9bf..1fef7df 100644
@@ -156,7 +156,7 @@ static ssize_t firmware_loading_store(struct device *dev,
 		}
 		/* fallthrough */
 	default:
-		printk(KERN_ERR "%s: unexpected value (%d)\n", __FUNCTION__,
+		printk(KERN_ERR "%s: unexpected value (%d)\n", __func__,
 		       loading);
 		/* fallthrough */
 	case -1:
@@ -209,7 +209,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
 	new_size = ALIGN(min_size, PAGE_SIZE);
 	new_data = vmalloc(new_size);
 	if (!new_data) {
-		printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__);
+		printk(KERN_ERR "%s: unable to alloc buffer\n", __func__);
 		/* Make sure that we don't keep incomplete data */
 		fw_load_abort(fw_priv);
 		return -ENOMEM;
@@ -307,7 +307,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
 	*dev_p = NULL;
 
 	if (!fw_priv || !f_dev) {
-		printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__);
+		printk(KERN_ERR "%s: kmalloc failed\n", __func__);
 		retval = -ENOMEM;
 		goto error_kfree;
 	}
@@ -328,7 +328,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
 	retval = device_register(f_dev);
 	if (retval) {
 		printk(KERN_ERR "%s: device_register failed\n",
-		       __FUNCTION__);
+		       __func__);
 		goto error_kfree;
 	}
 	*dev_p = f_dev;
@@ -362,14 +362,14 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
 	retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
 	if (retval) {
 		printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
-		       __FUNCTION__);
+		       __func__);
 		goto error_unreg;
 	}
 
 	retval = device_create_file(f_dev, &dev_attr_loading);
 	if (retval) {
 		printk(KERN_ERR "%s: device_create_file failed\n",
-		       __FUNCTION__);
+		       __func__);
 		goto error_unreg;
 	}
 
@@ -399,7 +399,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
 	*firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
 	if (!firmware) {
 		printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n",
-		       __FUNCTION__);
+		       __func__);
 		retval = -ENOMEM;
 		goto out;
 	}
@@ -570,13 +570,13 @@ firmware_class_init(void)
 	int error;
 	error = class_register(&firmware_class);
 	if (error) {
-		printk(KERN_ERR "%s: class_register failed\n", __FUNCTION__);
+		printk(KERN_ERR "%s: class_register failed\n", __func__);
 		return error;
 	}
 	error = class_create_file(&firmware_class, &class_attr_timeout);
 	if (error) {
 		printk(KERN_ERR "%s: class_create_file failed\n",
-		       __FUNCTION__);
+		       __func__);
 		class_unregister(&firmware_class);
 	}
 	return error;
drivers/base/memory.c +2 -2
index 7891f7c..8ce6de5 100644
@@ -186,7 +186,7 @@ memory_block_action(struct memory_block *mem, unsigned long action)
 			break;
 		default:
 			printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n",
-					__FUNCTION__, mem, action, action);
+					__func__, mem, action, action);
 			WARN_ON(1);
 			ret = -EINVAL;
 	}
@@ -444,6 +444,6 @@ int __init memory_dev_init(void)
 		ret = err;
 out:
 	if (ret)
-		printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret);
+		printk(KERN_ERR "%s() failed: %d\n", __func__, ret);
 	return ret;
 }
drivers/base/sys.c +1 -1
index 1a06c23..4fbb56b 100644
@@ -195,7 +195,7 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
 		}
 	} else {
 		err = -EINVAL;
-		printk(KERN_ERR "%s: invalid device class\n", __FUNCTION__);
+		printk(KERN_ERR "%s: invalid device class\n", __func__);
 		WARN_ON(1);
 	}
 	mutex_unlock(&sysdev_drivers_lock);
Signature · 1 line
1.5.4.5
#32 lore raw

PATCH 32/36 memstick: convert struct class_device to struct device

In reply to Greg KH

struct class_device is going away, struct device should be used instead.

---
 drivers/memstick/core/memstick.c    |   33 ++++++++++++++++-----------------
 drivers/memstick/core/mspro_block.c |    4 ++--
 drivers/memstick/host/jmb38x_ms.c   |   16 ++++++++--------
 include/linux/memstick.h            |    2 +-
 4 files changed, 27 insertions(+), 28 deletions(-)
drivers/memstick/core/memstick.c +16 -17
index 946e3d3..61b98c3 100644
@@ -177,16 +177,16 @@ static struct bus_type memstick_bus_type = {
 	.resume         = memstick_device_resume
 };
 
-static void memstick_free(struct class_device *cdev)
+static void memstick_free(struct device *dev)
 {
-	struct memstick_host *host = container_of(cdev, struct memstick_host,
-						  cdev);
+	struct memstick_host *host = container_of(dev, struct memstick_host,
+						  dev);
 	kfree(host);
 }
 
 static struct class memstick_host_class = {
 	.name       = "memstick_host",
-	.release    = memstick_free
+	.dev_release = memstick_free
 };
 
 static void memstick_free_card(struct device *dev)
@@ -383,8 +383,8 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host)
 	if (card) {
 		card->host = host;
 		snprintf(card->dev.bus_id, sizeof(card->dev.bus_id),
-			 "%s", host->cdev.class_id);
-		card->dev.parent = host->cdev.dev;
+			 "%s", host->dev.bus_id);
+		card->dev.parent = &host->dev;
 		card->dev.bus = &memstick_bus_type;
 		card->dev.release = memstick_free_card;
 		card->check = memstick_dummy_check;
@@ -427,7 +427,7 @@ static void memstick_check(struct work_struct *work)
 						  media_checker);
 	struct memstick_dev *card;
 
-	dev_dbg(host->cdev.dev, "memstick_check started\n");
+	dev_dbg(&host->dev, "memstick_check started\n");
 	mutex_lock(&host->lock);
 	if (!host->card)
 		memstick_power_on(host);
@@ -440,7 +440,7 @@ static void memstick_check(struct work_struct *work)
 			host->card = NULL;
 		}
 	} else {
-		dev_dbg(host->cdev.dev, "new card %02x, %02x, %02x\n",
+		dev_dbg(&host->dev, "new card %02x, %02x, %02x\n",
 			card->id.type, card->id.category, card->id.class);
 		if (host->card) {
 			if (memstick_set_rw_addr(host->card)
@@ -465,7 +465,7 @@ static void memstick_check(struct work_struct *work)
 		host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
 
 	mutex_unlock(&host->lock);
-	dev_dbg(host->cdev.dev, "memstick_check finished\n");
+	dev_dbg(&host->dev, "memstick_check finished\n");
 }
 
 /**
@@ -482,9 +482,9 @@ struct memstick_host *memstick_alloc_host(unsigned int extra,
 	if (host) {
 		mutex_init(&host->lock);
 		INIT_WORK(&host->media_checker, memstick_check);
-		host->cdev.class = &memstick_host_class;
-		host->cdev.dev = dev;
-		class_device_initialize(&host->cdev);
+		host->dev.class = &memstick_host_class;
+		host->dev.parent = dev;
+		device_initialize(&host->dev);
 	}
 	return host;
 }
@@ -507,10 +507,9 @@ int memstick_add_host(struct memstick_host *host)
 	if (rc)
 		return rc;
 
-	snprintf(host->cdev.class_id, BUS_ID_SIZE,
-		 "memstick%u", host->id);
+	snprintf(host->dev.bus_id, BUS_ID_SIZE, "memstick%u", host->id);
 
-	rc = class_device_add(&host->cdev);
+	rc = device_add(&host->dev);
 	if (rc) {
 		spin_lock(&memstick_host_lock);
 		idr_remove(&memstick_host_idr, host->id);
@@ -541,7 +540,7 @@ void memstick_remove_host(struct memstick_host *host)
 	spin_lock(&memstick_host_lock);
 	idr_remove(&memstick_host_idr, host->id);
 	spin_unlock(&memstick_host_lock);
-	class_device_del(&host->cdev);
+	device_del(&host->dev);
 }
 EXPORT_SYMBOL(memstick_remove_host);
 
@@ -552,7 +551,7 @@ EXPORT_SYMBOL(memstick_remove_host);
 void memstick_free_host(struct memstick_host *host)
 {
 	mutex_destroy(&host->lock);
-	class_device_put(&host->cdev);
+	put_device(&host->dev);
 }
 EXPORT_SYMBOL(memstick_free_host);
 
drivers/memstick/core/mspro_block.c +2 -2
index 557dbbb..477d0fb 100644
@@ -1127,8 +1127,8 @@ static int mspro_block_init_disk(struct memstick_dev *card)
 	u64 limit = BLK_BOUNCE_HIGH;
 	unsigned long capacity;
 
-	if (host->cdev.dev->dma_mask && *(host->cdev.dev->dma_mask))
-		limit = *(host->cdev.dev->dma_mask);
+	if (host->dev.dma_mask && *(host->dev.dma_mask))
+		limit = *(host->dev.dma_mask);
 
 	for (rc = 0; msb->attr_group.attrs[rc]; ++rc) {
 		s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]);
drivers/memstick/host/jmb38x_ms.c +8 -8
index 8770a5f..a054668 100644
@@ -361,15 +361,15 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
 	unsigned int data_len, cmd, t_val;
 
 	if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) {
-		dev_dbg(msh->cdev.dev, "no media status\n");
+		dev_dbg(&msh->dev, "no media status\n");
 		host->req->error = -ETIME;
 		return host->req->error;
 	}
 
-	dev_dbg(msh->cdev.dev, "control %08x\n",
+	dev_dbg(&msh->dev, "control %08x\n",
 		readl(host->addr + HOST_CONTROL));
-	dev_dbg(msh->cdev.dev, "status %08x\n", readl(host->addr + INT_STATUS));
-	dev_dbg(msh->cdev.dev, "hstatus %08x\n", readl(host->addr + STATUS));
+	dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS));
+	dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS));
 
 	host->cmd_flags = 0;
 	host->block_pos = 0;
@@ -448,7 +448,7 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
 	host->req->error = 0;
 
 	writel(cmd, host->addr + TPC);
-	dev_dbg(msh->cdev.dev, "executing TPC %08x, len %x\n", cmd, data_len);
+	dev_dbg(&msh->dev, "executing TPC %08x, len %x\n", cmd, data_len);
 
 	return 0;
 }
@@ -461,11 +461,11 @@ static void jmb38x_ms_complete_cmd(struct memstick_host *msh, int last)
 
 	del_timer(&host->timer);
 
-	dev_dbg(msh->cdev.dev, "c control %08x\n",
+	dev_dbg(&msh->dev, "c control %08x\n",
 		readl(host->addr + HOST_CONTROL));
-	dev_dbg(msh->cdev.dev, "c status %08x\n",
+	dev_dbg(&msh->dev, "c status %08x\n",
 		readl(host->addr + INT_STATUS));
-	dev_dbg(msh->cdev.dev, "c hstatus %08x\n", readl(host->addr + STATUS));
+	dev_dbg(&msh->dev, "c hstatus %08x\n", readl(host->addr + STATUS));
 
 	host->req->int_reg = readl(host->addr + STATUS) & 0xff;
 
include/linux/memstick.h +1 -1
index 3e686ec..37a5cdb 100644
@@ -276,7 +276,7 @@ struct memstick_host {
 #define MEMSTICK_CAP_PAR8          4
 
 	struct work_struct  media_checker;
-	struct class_device cdev;
+	struct device       dev;
 
 	struct memstick_dev *card;
 	unsigned int        retries;
Signature · 1 line
1.5.4.5
#33 lore raw

PATCH 33/36 IB: convert struct class_device to struct device

In reply to Greg KH

From: Tony Jones <[email protected]>

This converts the main ib_device to use struct device instead of struct class_device as class_device is going away.

---
 drivers/infiniband/core/sysfs.c              |   76 ++++++++++---------
 drivers/infiniband/core/ucm.c                |   62 +++++++-------
 drivers/infiniband/core/user_mad.c           |  109 +++++++++++++-------------
 drivers/infiniband/core/uverbs.h             |    4 +-
 drivers/infiniband/core/uverbs_main.c        |   51 ++++++------
 drivers/infiniband/hw/amso1100/c2_provider.c |   48 ++++++-----
 drivers/infiniband/hw/cxgb3/iwch_provider.c  |   75 +++++++++---------
 drivers/infiniband/hw/ipath/ipath_diag.c     |   10 +-
 drivers/infiniband/hw/ipath/ipath_file_ops.c |   44 +++++-----
 drivers/infiniband/hw/ipath/ipath_kernel.h   |    8 +-
 drivers/infiniband/hw/ipath/ipath_verbs.c    |   37 +++++----
 drivers/infiniband/hw/mlx4/main.c            |   49 +++++++-----
 drivers/infiniband/hw/mthca/mthca_provider.c |   48 +++++++-----
 drivers/infiniband/hw/nes/nes_verbs.c        |   48 ++++++-----
 include/rdma/ib_verbs.h                      |    2 +-
 15 files changed, 352 insertions(+), 319 deletions(-)
drivers/infiniband/core/sysfs.c +40 -36
index 5a4b2e6..9575655 100644
@@ -427,17 +427,17 @@ static struct kobj_type port_type = {
 	.default_attrs = port_default_attrs
 };
 
-static void ib_device_release(struct class_device *cdev)
+static void ib_device_release(struct device *device)
 {
-	struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
 
 	kfree(dev);
 }
 
-static int ib_device_uevent(struct class_device *cdev,
+static int ib_device_uevent(struct device *device,
 			    struct kobj_uevent_env *env)
 {
-	struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
 
 	if (add_uevent_var(env, "NAME=%s", dev->name))
 		return -ENOMEM;
@@ -567,9 +567,10 @@ err_put:
 	return ret;
 }
 
-static ssize_t show_node_type(struct class_device *cdev, char *buf)
+static ssize_t show_node_type(struct device *device,
+			      struct device_attribute *attr, char *buf)
 {
-	struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
 
 	if (!ibdev_is_alive(dev))
 		return -ENODEV;
@@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf)
 	}
 }
 
-static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
+static ssize_t show_sys_image_guid(struct device *device,
+				   struct device_attribute *dev_attr, char *buf)
 {
-	struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
 	struct ib_device_attr attr;
 	ssize_t ret;
 
@@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
 		       be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3]));
 }
 
-static ssize_t show_node_guid(struct class_device *cdev, char *buf)
+static ssize_t show_node_guid(struct device *device,
+			      struct device_attribute *attr, char *buf)
 {
-	struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
 
 	if (!ibdev_is_alive(dev))
 		return -ENODEV;
@@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
 		       be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
 }
 
-static ssize_t show_node_desc(struct class_device *cdev, char *buf)
+static ssize_t show_node_desc(struct device *device,
+			      struct device_attribute *attr, char *buf)
 {
-	struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
 
 	return sprintf(buf, "%.64s\n", dev->node_desc);
 }
 
-static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
-			      size_t count)
+static ssize_t set_node_desc(struct device *device,
+			     struct device_attribute *attr,
+			     const char *buf, size_t count)
 {
-	struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
 	struct ib_device_modify desc = {};
 	int ret;
 
@@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
 	return count;
 }
 
-static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
-static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
-static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
-static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc,
-			 set_node_desc);
-
-static struct class_device_attribute *ib_class_attributes[] = {
-	&class_device_attr_node_type,
-	&class_device_attr_sys_image_guid,
-	&class_device_attr_node_guid,
-	&class_device_attr_node_desc
+static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
+static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
+static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
+static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc);
+
+static struct device_attribute *ib_class_attributes[] = {
+	&dev_attr_node_type,
+	&dev_attr_sys_image_guid,
+	&dev_attr_node_guid,
+	&dev_attr_node_desc
 };
 
 static struct class ib_class = {
 	.name    = "infiniband",
-	.release = ib_device_release,
-	.uevent = ib_device_uevent,
+	.dev_release = ib_device_release,
+	.dev_uevent = ib_device_uevent,
 };
 
 int ib_device_register_sysfs(struct ib_device *device)
 {
-	struct class_device *class_dev = &device->class_dev;
+	struct device *class_dev = &device->dev;
 	int ret;
 	int i;
 
 	class_dev->class      = &ib_class;
-	class_dev->class_data = device;
-	class_dev->dev	      = device->dma_device;
-	strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE);
+	class_dev->driver_data = device;
+	class_dev->parent     = device->dma_device;
+	strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE);
 
 	INIT_LIST_HEAD(&device->port_list);
 
-	ret = class_device_register(class_dev);
+	ret = device_register(class_dev);
 	if (ret)
 		goto err;
 
 	for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
-		ret = class_device_create_file(class_dev, ib_class_attributes[i]);
+		ret = device_create_file(class_dev, ib_class_attributes[i]);
 		if (ret)
 			goto err_unregister;
 	}
@@ -723,7 +727,7 @@ err_put:
 	kobject_put(&class_dev->kobj);
 
 err_unregister:
-	class_device_unregister(class_dev);
+	device_unregister(class_dev);
 
 err:
 	return ret;
@@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device)
 	}
 
 	kobject_put(device->ports_parent);
-	class_device_unregister(&device->class_dev);
+	device_unregister(&device->dev);
 }
 
 int ib_sysfs_setup(void)
drivers/infiniband/core/ucm.c +31 -31

113 lines not on this page · raw message

drivers/infiniband/core/user_mad.c +55 -54

172 lines not on this page · raw message

drivers/infiniband/core/uverbs.h +2 -2
index 2cad8b4..376a57c 100644
@@ -73,8 +73,8 @@ struct ib_uverbs_device {
 	struct kref				ref;
 	struct completion			comp;
 	int					devnum;
-	struct cdev			       *dev;
-	struct class_device		       *class_dev;
+	struct cdev			       *cdev;
+	struct device			       *dev;
 	struct ib_device		       *ib_dev;
 	int					num_comp_vectors;
 };
drivers/infiniband/core/uverbs_main.c +26 -25

99 lines not on this page · raw message

drivers/infiniband/hw/amso1100/c2_provider.c +26 -22

80 lines not on this page · raw message

drivers/infiniband/hw/cxgb3/iwch_provider.c +37 -38

114 lines not on this page · raw message

drivers/infiniband/hw/ipath/ipath_diag.c +5 -5
index 6d49d2f..d4ce8b6 100644
@@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = {
 
 static atomic_t diagpkt_count = ATOMIC_INIT(0);
 static struct cdev *diagpkt_cdev;
-static struct class_device *diagpkt_class_dev;
+static struct device *diagpkt_dev;
 
 int ipath_diag_add(struct ipath_devdata *dd)
 {
@@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
 	if (atomic_inc_return(&diagpkt_count) == 1) {
 		ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR,
 				      "ipath_diagpkt", &diagpkt_file_ops,
-				      &diagpkt_cdev, &diagpkt_class_dev);
+				      &diagpkt_cdev, &diagpkt_dev);
 
 		if (ret) {
 			ipath_dev_err(dd, "Couldn't create ipath_diagpkt "
@@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
 
 	ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name,
 			      &diag_file_ops, &dd->diag_cdev,
-			      &dd->diag_class_dev);
+			      &dd->diag_dev);
 	if (ret)
 		ipath_dev_err(dd, "Couldn't create %s device: %d",
 			      name, ret);
@@ -114,9 +114,9 @@ done:
 void ipath_diag_remove(struct ipath_devdata *dd)
 {
 	if (atomic_dec_and_test(&diagpkt_count))
-		ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev);
+		ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev);
 
-	ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev);
+	ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev);
 }
 
 /**
drivers/infiniband/hw/ipath/ipath_file_ops.c +22 -22

114 lines not on this page · raw message

drivers/infiniband/hw/ipath/ipath_kernel.h +4 -4
index 5863cbe..202337a 100644
@@ -466,8 +466,8 @@ struct ipath_devdata {
 	struct pci_dev *pcidev;
 	struct cdev *user_cdev;
 	struct cdev *diag_cdev;
-	struct class_device *user_class_dev;
-	struct class_device *diag_class_dev;
+	struct device *user_dev;
+	struct device *diag_dev;
 	/* timer used to prevent stats overflow, error throttling, etc. */
 	struct timer_list ipath_stats_timer;
 	/* timer to verify interrupts work, and fallback if possible */
@@ -854,9 +854,9 @@ void ipath_clear_freeze(struct ipath_devdata *);
 
 struct file_operations;
 int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
-		    struct cdev **cdevp, struct class_device **class_devp);
+		    struct cdev **cdevp, struct device **devp);
 void ipath_cdev_cleanup(struct cdev **cdevp,
-			struct class_device **class_devp);
+			struct device **devp);
 
 int ipath_diag_add(struct ipath_devdata *);
 void ipath_diag_remove(struct ipath_devdata *);
drivers/infiniband/hw/ipath/ipath_verbs.c +20 -17
index 320a6d0..c38f9aa 100644
@@ -2172,18 +2172,20 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev)
 	ib_dealloc_device(ibdev);
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *device, struct device_attribute *attr,
+			char *buf)
 {
 	struct ipath_ibdev *dev =
-		container_of(cdev, struct ipath_ibdev, ibdev.class_dev);
+		container_of(device, struct ipath_ibdev, ibdev.dev);
 
 	return sprintf(buf, "%x\n", dev->dd->ipath_pcirev);
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *device, struct device_attribute *attr,
+			char *buf)
 {
 	struct ipath_ibdev *dev =
-		container_of(cdev, struct ipath_ibdev, ibdev.class_dev);
+		container_of(device, struct ipath_ibdev, ibdev.dev);
 	int ret;
 
 	ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128);
@@ -2196,10 +2198,11 @@ bail:
 	return ret;
 }
 
-static ssize_t show_stats(struct class_device *cdev, char *buf)
+static ssize_t show_stats(struct device *device, struct device_attribute *attr,
+			  char *buf)
 {
 	struct ipath_ibdev *dev =
-		container_of(cdev, struct ipath_ibdev, ibdev.class_dev);
+		container_of(device, struct ipath_ibdev, ibdev.dev);
 	int i;
 	int len;
 
@@ -2237,16 +2240,16 @@ static ssize_t show_stats(struct class_device *cdev, char *buf)
 	return len;
 }
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
 
-static struct class_device_attribute *ipath_class_attributes[] = {
-	&class_device_attr_hw_rev,
-	&class_device_attr_hca_type,
-	&class_device_attr_board_id,
-	&class_device_attr_stats
+static struct device_attribute *ipath_class_attributes[] = {
+	&dev_attr_hw_rev,
+	&dev_attr_hca_type,
+	&dev_attr_board_id,
+	&dev_attr_stats
 };
 
 static int ipath_verbs_register_sysfs(struct ib_device *dev)
@@ -2255,8 +2258,8 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev)
 	int ret;
 
 	for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i)
-		if (class_device_create_file(&dev->class_dev,
-					     ipath_class_attributes[i])) {
+		if (device_create_file(&dev->dev,
+				       ipath_class_attributes[i])) {
 			ret = 1;
 			goto bail;
 		}
drivers/infiniband/hw/mlx4/main.c +29 -20

79 lines not on this page · raw message

drivers/infiniband/hw/mthca/mthca_provider.c +28 -20

82 lines not on this page · raw message

drivers/infiniband/hw/nes/nes_verbs.c +26 -22

104 lines not on this page · raw message

include/rdma/ib_verbs.h +1 -1
index 95bf4ba..2dcbecc 100644
@@ -1051,7 +1051,7 @@ struct ib_device {
 	struct ib_dma_mapping_ops   *dma_ops;
 
 	struct module               *owner;
-	struct class_device          class_dev;
+	struct device                dev;
 	struct kobject               *ports_parent;
 	struct list_head             port_list;
 
Signature · 1 line
1.5.4.5
#35 lore raw

PATCH 34/36 IB: rename "dev" to "srp_dev" in srp_host structure

In reply to Greg KH

This sets us up to be able to convert the srp_host to use a struct device instead of a class_device.

Based on a original patch from Tony Jones, but split up into this piece by Greg.

---
 drivers/infiniband/ulp/srp/ib_srp.c |   49 ++++++++++++++++++----------------
 drivers/infiniband/ulp/srp/ib_srp.h |    2 +-
 2 files changed, 27 insertions(+), 24 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +26 -23
index 125765a..99a1106 100644
@@ -139,8 +139,9 @@ static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size,
 	if (!iu->buf)
 		goto out_free_iu;
 
-	iu->dma = ib_dma_map_single(host->dev->dev, iu->buf, size, direction);
-	if (ib_dma_mapping_error(host->dev->dev, iu->dma))
+	iu->dma = ib_dma_map_single(host->srp_dev->dev, iu->buf, size,
+				    direction);
+	if (ib_dma_mapping_error(host->srp_dev->dev, iu->dma))
 		goto out_free_buf;
 
 	iu->size      = size;
@@ -161,7 +162,8 @@ static void srp_free_iu(struct srp_host *host, struct srp_iu *iu)
 	if (!iu)
 		return;
 
-	ib_dma_unmap_single(host->dev->dev, iu->dma, iu->size, iu->direction);
+	ib_dma_unmap_single(host->srp_dev->dev, iu->dma, iu->size,
+			    iu->direction);
 	kfree(iu->buf);
 	kfree(iu);
 }
@@ -181,7 +183,7 @@ static int srp_init_qp(struct srp_target_port *target,
 	if (!attr)
 		return -ENOMEM;
 
-	ret = ib_find_cached_pkey(target->srp_host->dev->dev,
+	ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev,
 				  target->srp_host->port,
 				  be16_to_cpu(target->path.pkey),
 				  &attr->pkey_index);
@@ -208,7 +210,7 @@ static int srp_new_cm_id(struct srp_target_port *target)
 {
 	struct ib_cm_id *new_cm_id;
 
-	new_cm_id = ib_create_cm_id(target->srp_host->dev->dev,
+	new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev,
 				    srp_cm_handler, target);
 	if (IS_ERR(new_cm_id))
 		return PTR_ERR(new_cm_id);
@@ -229,8 +231,8 @@ static int srp_create_target_ib(struct srp_target_port *target)
 	if (!init_attr)
 		return -ENOMEM;
 
-	target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion,
-				  NULL, target, SRP_CQ_SIZE, 0);
+	target->cq = ib_create_cq(target->srp_host->srp_dev->dev,
+				  srp_completion, NULL, target, SRP_CQ_SIZE, 0);
 	if (IS_ERR(target->cq)) {
 		ret = PTR_ERR(target->cq);
 		goto out;
@@ -248,7 +250,7 @@ static int srp_create_target_ib(struct srp_target_port *target)
 	init_attr->send_cq             = target->cq;
 	init_attr->recv_cq             = target->cq;
 
-	target->qp = ib_create_qp(target->srp_host->dev->pd, init_attr);
+	target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr);
 	if (IS_ERR(target->qp)) {
 		ret = PTR_ERR(target->qp);
 		ib_destroy_cq(target->cq);
@@ -302,7 +304,7 @@ static int srp_lookup_path(struct srp_target_port *target)
 	init_completion(&target->done);
 
 	target->path_query_id = ib_sa_path_rec_get(&srp_sa_client,
-						   target->srp_host->dev->dev,
+						   target->srp_host->srp_dev->dev,
 						   target->srp_host->port,
 						   &target->path,
 						   IB_SA_PATH_REC_SERVICE_ID	|
@@ -403,7 +405,7 @@ static int srp_send_req(struct srp_target_port *target)
 			     (unsigned long long) be64_to_cpu(target->ioc_guid));
 		memset(req->priv.initiator_port_id, 0, 8);
 		memcpy(req->priv.initiator_port_id + 8,
-		       &target->srp_host->dev->dev->node_guid, 8);
+		       &target->srp_host->srp_dev->dev->node_guid, 8);
 	}
 
 	status = ib_send_cm_req(target->cm_id, &req->param);
@@ -520,7 +522,7 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
 		req->fmr = NULL;
 	}
 
-	ib_dma_unmap_sg(target->srp_host->dev->dev, scsi_sglist(scmnd),
+	ib_dma_unmap_sg(target->srp_host->srp_dev->dev, scsi_sglist(scmnd),
 			scsi_sg_count(scmnd), scmnd->sc_data_direction);
 }
 
@@ -628,7 +630,7 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
 	int page_cnt;
 	int i, j;
 	int ret;
-	struct srp_device *dev = target->srp_host->dev;
+	struct srp_device *dev = target->srp_host->srp_dev;
 	struct ib_device *ibdev = dev->dev;
 	struct scatterlist *sg;
 
@@ -723,7 +725,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
 	nents = scsi_sg_count(scmnd);
 	scat  = scsi_sglist(scmnd);
 
-	dev = target->srp_host->dev;
+	dev = target->srp_host->srp_dev;
 	ibdev = dev->dev;
 
 	count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction);
@@ -779,7 +781,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
 		buf->table_desc.va  =
 			cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf);
 		buf->table_desc.key =
-			cpu_to_be32(target->srp_host->dev->mr->rkey);
+			cpu_to_be32(target->srp_host->srp_dev->mr->rkey);
 		buf->table_desc.len =
 			cpu_to_be32(count * sizeof (struct srp_direct_buf));
 
@@ -855,7 +857,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
 
 	iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV];
 
-	dev = target->srp_host->dev->dev;
+	dev = target->srp_host->srp_dev->dev;
 	ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len,
 				   DMA_FROM_DEVICE);
 
@@ -937,7 +939,7 @@ static int __srp_post_recv(struct srp_target_port *target)
 
 	list.addr   = iu->dma;
 	list.length = iu->size;
-	list.lkey   = target->srp_host->dev->mr->lkey;
+	list.lkey   = target->srp_host->srp_dev->mr->lkey;
 
 	wr.next     = NULL;
 	wr.sg_list  = &list;
@@ -996,7 +998,7 @@ static int __srp_post_send(struct srp_target_port *target,
 
 	list.addr   = iu->dma;
 	list.length = len;
-	list.lkey   = target->srp_host->dev->mr->lkey;
+	list.lkey   = target->srp_host->srp_dev->mr->lkey;
 
 	wr.next       = NULL;
 	wr.wr_id      = target->tx_head & SRP_SQ_SIZE;
@@ -1039,7 +1041,7 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
 	if (!iu)
 		goto err;
 
-	dev = target->srp_host->dev->dev;
+	dev = target->srp_host->srp_dev->dev;
 	ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len,
 				   DMA_TO_DEVICE);
 
@@ -1563,7 +1565,7 @@ static ssize_t show_local_ib_device(struct class_device *cdev, char *buf)
 {
 	struct srp_target_port *target = host_to_target(class_to_shost(cdev));
 
-	return sprintf(buf, "%s\n", target->srp_host->dev->dev->name);
+	return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name);
 }
 
 static CLASS_DEVICE_ATTR(id_ext,	  S_IRUGO, show_id_ext,		 NULL);
@@ -1613,7 +1615,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
 	sprintf(target->target_name, "SRP.T10:%016llX",
 		 (unsigned long long) be64_to_cpu(target->id_ext));
 
-	if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device))
+	if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device))
 		return -ENODEV;
 
 	memcpy(ids.port_id, &target->id_ext, 8);
@@ -1871,7 +1873,8 @@ static ssize_t srp_create_target(struct class_device *class_dev,
 	if (ret)
 		goto err;
 
-	ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid);
+	ib_get_cached_gid(host->srp_dev->dev, host->port, 0,
+			  &target->path.sgid);
 
 	shost_printk(KERN_DEBUG, target->scsi_host, PFX
 		     "new target: id_ext %016llx ioc_guid %016llx pkey %04x "
@@ -1933,7 +1936,7 @@ static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
 	struct srp_host *host =
 		container_of(class_dev, struct srp_host, class_dev);
 
-	return sprintf(buf, "%s\n", host->dev->dev->name);
+	return sprintf(buf, "%s\n", host->srp_dev->dev->name);
 }
 
 static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
@@ -1959,7 +1962,7 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
 	INIT_LIST_HEAD(&host->target_list);
 	spin_lock_init(&host->target_lock);
 	init_completion(&host->released);
-	host->dev  = device;
+	host->srp_dev = device;
 	host->port = port;
 
 	host->class_dev.class = &srp_class;
drivers/infiniband/ulp/srp/ib_srp.h +1 -1
index cb6eb81..67e17c3 100644
@@ -97,7 +97,7 @@ struct srp_device {
 };
 
 struct srp_host {
-	struct srp_device      *dev;
+	struct srp_device      *srp_dev;
 	u8			port;
 	struct class_device	class_dev;
 	struct list_head	target_list;
Signature · 1 line
1.5.4.5
#36 lore raw

PATCH 35/36 DRM: remove unused dev_class

In reply to Greg KH

The struct class_device *dev_class is not used in the struct drm_head structure at all, so remove it as class_device is being removed entirely from the kernel.

Cc David Airlie <[email protected]>
Cc Tony Jones <[email protected]>
Cc Kay Sievers <[email protected]>
---
 drivers/char/drm/drmP.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/char/drm/drmP.h +0 -1
index 8ea9dd1..6540948 100644
@@ -640,7 +640,6 @@ struct drm_head {
 	struct drm_device *dev;
 	struct proc_dir_entry *dev_root;  /**< proc directory entry */
 	dev_t device;			/**< Device number for mknod */
-	struct class_device *dev_class;
 };
 
 /**
Signature · 1 line
1.5.4.5
#37 lore raw

PATCH 36/36 SCSI: convert struct class_device to struct device

In reply to Greg KH

From: Tony Jones <[email protected]>

It's big, but there doesn't seem to be a way to split it up smaller...

Cc Roland Dreier <[email protected]>
Cc Sean Hefty <[email protected]>
Cc Hal Rosenstock <[email protected]>
Cc James Bottomley <[email protected]>
---
 block/bsg.c                           |   11 +-
 drivers/ata/ahci.c                    |    4 +-
 drivers/ata/libata-scsi.c             |   15 +-
 drivers/base/attribute_container.c    |   77 +++---
 drivers/base/transport_class.c        |   14 +-
 drivers/infiniband/ulp/srp/ib_srp.c   |  132 +++++----
 drivers/infiniband/ulp/srp/ib_srp.h   |    2 +-
 drivers/message/fusion/mptscsih.c     |  122 +++++----
 drivers/message/fusion/mptscsih.h     |    2 +-
 drivers/misc/enclosure.c              |  118 +++++----
 drivers/scsi/3w-9xxx.c                |    9 +-
 drivers/scsi/3w-xxxx.c                |    9 +-
 drivers/scsi/aacraid/aachba.c         |    2 +-
 drivers/scsi/aacraid/aacraid.h        |    4 +-
 drivers/scsi/aacraid/linit.c          |   93 ++++---
 drivers/scsi/arcmsr/arcmsr.h          |    4 +-
 drivers/scsi/arcmsr/arcmsr_attr.c     |  163 +++++++-----
 drivers/scsi/ch.c                     |   13 +-
 drivers/scsi/hosts.c                  |   34 ++--
 drivers/scsi/hptiop.c                 |   14 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c      |   44 ++--
 drivers/scsi/ibmvscsi/ibmvstgt.c      |   25 +-
 drivers/scsi/ipr.c                    |  140 +++++-----
 drivers/scsi/lpfc/lpfc_attr.c         |  484 +++++++++++++++++---------------
 drivers/scsi/lpfc/lpfc_crtn.h         |    4 +-
 drivers/scsi/megaraid/megaraid_mbox.c |   13 +-
 drivers/scsi/ncr53c8xx.c              |    7 +-
 drivers/scsi/osst.c                   |   76 +++---
 drivers/scsi/pcmcia/sym53c500_cs.c    |   14 +-
 drivers/scsi/qla2xxx/qla_attr.c       |  177 +++++++------
 drivers/scsi/qla2xxx/qla_gbl.h        |    4 +-
 drivers/scsi/raid_class.c             |   73 +++---
 drivers/scsi/scsi_sas_internal.h      |   24 +-
 drivers/scsi/scsi_sysfs.c             |  150 ++++++-----
 drivers/scsi/scsi_transport_fc.c      |  385 ++++++++++++++------------
 drivers/scsi/scsi_transport_iscsi.c   |  107 ++++----
 drivers/scsi/scsi_transport_sas.c     |  157 ++++++-----
 drivers/scsi/scsi_transport_spi.c     |  185 +++++++------
 drivers/scsi/scsi_transport_srp.c     |   26 +-
 drivers/scsi/sd.c                     |   78 +++---
 drivers/scsi/ses.c                    |   28 +-
 drivers/scsi/sg.c                     |   36 ++--
 drivers/scsi/st.c                     |   82 +++---
 include/linux/attribute_container.h   |   28 +-
 include/linux/bsg.h                   |    2 +-
 include/linux/enclosure.h             |   11 +-
 include/linux/libata.h                |    2 +-
 include/linux/raid_class.h            |   12 +-
 include/linux/transport_class.h       |    6 +-
 include/scsi/scsi_device.h            |   10 +-
 include/scsi/scsi_host.h              |    7 +-
 include/scsi/scsi_transport.h         |    2 +-
 include/scsi/scsi_transport_fc.h      |   14 +-
 include/scsi/scsi_transport_sas.h     |   12 +-
 include/scsi/sd.h                     |    4 +-
 55 files changed, 1761 insertions(+), 1510 deletions(-)
block/bsg.c +5 -6
index 302ac1f..f51172e 100644
@@ -758,7 +758,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
 	mutex_lock(&bsg_mutex);
 	hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode)));
 
-	strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1);
+	strncpy(bd->name, rq->bsg_dev.class_dev->bus_id, sizeof(bd->name) - 1);
 	dprintk("bound to <%s>, max queue %d\n",
 		format_dev_t(buf, inode->i_rdev), bd->max_queue);
 
@@ -946,7 +946,7 @@ void bsg_unregister_queue(struct request_queue *q)
 	mutex_lock(&bsg_mutex);
 	idr_remove(&bsg_minor_idr, bcd->minor);
 	sysfs_remove_link(&q->kobj, "bsg");
-	class_device_unregister(bcd->class_dev);
+	device_unregister(bcd->class_dev);
 	put_device(bcd->dev);
 	bcd->class_dev = NULL;
 	mutex_unlock(&bsg_mutex);
@@ -959,7 +959,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
 	struct bsg_class_device *bcd;
 	dev_t dev;
 	int ret, minor;
-	struct class_device *class_dev = NULL;
+	struct device *class_dev = NULL;
 	const char *devname;
 
 	if (name)
@@ -998,8 +998,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
 	bcd->queue = q;
 	bcd->dev = get_device(gdev);
 	dev = MKDEV(bsg_major, bcd->minor);
-	class_dev = class_device_create(bsg_class, NULL, dev, gdev, "%s",
-					devname);
+	class_dev = device_create(bsg_class, gdev, dev, "%s", devname);
 	if (IS_ERR(class_dev)) {
 		ret = PTR_ERR(class_dev);
 		goto put_dev;
@@ -1016,7 +1015,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
 	return 0;
 
 unregister_class_dev:
-	class_device_unregister(class_dev);
+	device_unregister(class_dev);
 put_dev:
 	put_device(gdev);
 remove_idr:
drivers/ata/ahci.c +2 -2
index 739ba3f..986e332 100644
@@ -273,8 +273,8 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
 static int ahci_pci_device_resume(struct pci_dev *pdev);
 #endif
 
-static struct class_device_attribute *ahci_shost_attrs[] = {
-	&class_device_attr_link_power_management_policy,
+static struct device_attribute *ahci_shost_attrs[] = {
+	&dev_attr_link_power_management_policy,
 	NULL
 };
 
drivers/ata/libata-scsi.c +8 -7
index f3c69a8..a34f324 100644
@@ -131,10 +131,11 @@ static const char *ata_scsi_lpm_get(enum link_pm policy)
 	return NULL;
 }
 
-static ssize_t ata_scsi_lpm_put(struct class_device *class_dev,
-	const char *buf, size_t count)
+static ssize_t ata_scsi_lpm_put(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
 {
-	struct Scsi_Host *shost = class_to_shost(class_dev);
+	struct Scsi_Host *shost = class_to_shost(dev);
 	struct ata_port *ap = ata_shost_to_port(shost);
 	enum link_pm policy = 0;
 	int i;
@@ -162,9 +163,9 @@ static ssize_t ata_scsi_lpm_put(struct class_device *class_dev,
 }
 
 static ssize_t
-ata_scsi_lpm_show(struct class_device *class_dev, char *buf)
+ata_scsi_lpm_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct Scsi_Host *shost = class_to_shost(class_dev);
+	struct Scsi_Host *shost = class_to_shost(dev);
 	struct ata_port *ap = ata_shost_to_port(shost);
 	const char *policy =
 		ata_scsi_lpm_get(ap->pm_policy);
@@ -174,9 +175,9 @@ ata_scsi_lpm_show(struct class_device *class_dev, char *buf)
 
 	return snprintf(buf, 23, "%s\n", policy);
 }
-CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
+DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
 		ata_scsi_lpm_show, ata_scsi_lpm_put);
-EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy);
+EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy);
 
 static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
 				   void (*done)(struct scsi_cmnd *))
drivers/base/attribute_container.c +38 -39

245 lines not on this page · raw message

drivers/base/transport_class.c +7 -7
index cabd0ed..84997ef 100644
@@ -66,7 +66,7 @@ EXPORT_SYMBOL_GPL(transport_class_unregister);
 
 static int anon_transport_dummy_function(struct transport_container *tc,
 					 struct device *dev,
-					 struct class_device *cdev)
+					 struct device *cdev)
 {
 	/* do nothing */
 	return 0;
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(anon_transport_class_unregister);
 
 static int transport_setup_classdev(struct attribute_container *cont,
 				    struct device *dev,
-				    struct class_device *classdev)
+				    struct device *classdev)
 {
 	struct transport_class *tclass = class_to_transport_class(cont->class);
 	struct transport_container *tcont = attribute_container_to_transport_container(cont);
@@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(transport_setup_device);
 
 static int transport_add_class_device(struct attribute_container *cont,
 				      struct device *dev,
-				      struct class_device *classdev)
+				      struct device *classdev)
 {
 	int error = attribute_container_add_class_device(classdev);
 	struct transport_container *tcont = 
@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(transport_add_device);
 
 static int transport_configure(struct attribute_container *cont,
 			       struct device *dev,
-			       struct class_device *cdev)
+			       struct device *cdev)
 {
 	struct transport_class *tclass = class_to_transport_class(cont->class);
 	struct transport_container *tcont = attribute_container_to_transport_container(cont);
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(transport_configure_device);
 
 static int transport_remove_classdev(struct attribute_container *cont,
 				     struct device *dev,
-				     struct class_device *classdev)
+				     struct device *classdev)
 {
 	struct transport_container *tcont = 
 		attribute_container_to_transport_container(cont);
@@ -251,12 +251,12 @@ EXPORT_SYMBOL_GPL(transport_remove_device);
 
 static void transport_destroy_classdev(struct attribute_container *cont,
 				      struct device *dev,
-				      struct class_device *classdev)
+				      struct device *classdev)
 {
 	struct transport_class *tclass = class_to_transport_class(cont->class);
 
 	if (tclass->remove != anon_transport_dummy_function)
-		class_device_put(classdev);
+		put_device(classdev);
 }
 
 
drivers/infiniband/ulp/srp/ib_srp.c +71 -61

260 lines not on this page · raw message

drivers/infiniband/ulp/srp/ib_srp.h +1 -1
index 67e17c3..63d2ae7 100644
@@ -99,7 +99,7 @@ struct srp_device {
 struct srp_host {
 	struct srp_device      *srp_dev;
 	u8			port;
-	struct class_device	class_dev;
+	struct device		dev;
 	struct list_head	target_list;
 	spinlock_t		target_lock;
 	struct completion	released;
drivers/message/fusion/mptscsih.c +68 -54

240 lines not on this page · raw message

drivers/message/fusion/mptscsih.h +1 -1
index d289e97..7ea7da0 100644
@@ -129,4 +129,4 @@ extern void mptscsih_timer_expired(unsigned long data);
 extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout);
 extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id);
 extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id);
-extern struct class_device_attribute *mptscsih_host_attrs[];
+extern struct device_attribute *mptscsih_host_attrs[];
drivers/misc/enclosure.c +64 -54

286 lines not on this page · raw message

drivers/scsi/3w-9xxx.c +5 -4
index 51c3ebf..b31faec 100644
@@ -140,9 +140,10 @@ static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id);
 /* Functions */
 
 /* Show some statistics about the card */
-static ssize_t twa_show_stats(struct class_device *class_dev, char *buf)
+static ssize_t twa_show_stats(struct device *dev,
+			      struct device_attribute *attr, char *buf)
 {
-	struct Scsi_Host *host = class_to_shost(class_dev);
+	struct Scsi_Host *host = class_to_shost(dev);
 	TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
 	unsigned long flags = 0;
 	ssize_t len;
@@ -184,7 +185,7 @@ static int twa_change_queue_depth(struct scsi_device *sdev, int queue_depth)
 } /* End twa_change_queue_depth() */
 
 /* Create sysfs 'stats' entry */
-static struct class_device_attribute twa_host_stats_attr = {
+static struct device_attribute twa_host_stats_attr = {
 	.attr = {
 		.name = 	"stats",
 		.mode =		S_IRUGO,
@@ -193,7 +194,7 @@ static struct class_device_attribute twa_host_stats_attr = {
 };
 
 /* Host attributes initializer */
-static struct class_device_attribute *twa_host_attrs[] = {
+static struct device_attribute *twa_host_attrs[] = {
 	&twa_host_stats_attr,
 	NULL,
 };
drivers/scsi/3w-xxxx.c +5 -4
index adb98a2..8c22329 100644
@@ -484,9 +484,10 @@ static void tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id)
 } /* End tw_state_request_start() */
 
 /* Show some statistics about the card */
-static ssize_t tw_show_stats(struct class_device *class_dev, char *buf)
+static ssize_t tw_show_stats(struct device *dev, struct device_attribute *attr,
+			     char *buf)
 {
-	struct Scsi_Host *host = class_to_shost(class_dev);
+	struct Scsi_Host *host = class_to_shost(dev);
 	TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
 	unsigned long flags = 0;
 	ssize_t len;
@@ -528,7 +529,7 @@ static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth)
 } /* End tw_change_queue_depth() */
 
 /* Create sysfs 'stats' entry */
-static struct class_device_attribute tw_host_stats_attr = {
+static struct device_attribute tw_host_stats_attr = {
 	.attr = {
 		.name = 	"stats",
 		.mode =		S_IRUGO,
@@ -537,7 +538,7 @@ static struct class_device_attribute tw_host_stats_attr = {
 };
 
 /* Host attributes initializer */
-static struct class_device_attribute *tw_host_attrs[] = {
+static struct device_attribute *tw_host_attrs[] = {
 	&tw_host_stats_attr,
 	NULL,
 };
drivers/scsi/aacraid/aachba.c +1 -1
index 369fcf7..439fd81 100644
@@ -1316,7 +1316,7 @@ int aac_get_adapter_info(struct aac_dev* dev)
 			tmp>>24,(tmp>>16)&0xff,tmp&0xff,
 			le32_to_cpu(dev->adapter_info.biosbuild));
 		buffer[0] = '\0';
-		if (aac_show_serial_number(
+		if (aac_get_serial_number(
 		  shost_to_class(dev->scsi_host_ptr), buffer))
 			printk(KERN_INFO "%s%d: serial %s",
 			  dev->name, dev->id, buffer);
drivers/scsi/aacraid/aacraid.h +2 -2
index ace0b75..113ca9c 100644
@@ -1850,9 +1850,9 @@ int aac_get_containers(struct aac_dev *dev);
 int aac_scsi_cmd(struct scsi_cmnd *cmd);
 int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg);
 #ifndef shost_to_class
-#define shost_to_class(shost) &shost->shost_classdev
+#define shost_to_class(shost) &shost->shost_dev
 #endif
-ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf);
+ssize_t aac_get_serial_number(struct device *dev, char *buf);
 int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg);
 int aac_rx_init(struct aac_dev *dev);
 int aac_rkt_init(struct aac_dev *dev);
drivers/scsi/aacraid/linit.c +53 -40

240 lines not on this page · raw message

drivers/scsi/arcmsr/arcmsr.h +2 -2
index 3288be2..ab646e5 100644
@@ -44,7 +44,7 @@
 */
 #include <linux/interrupt.h>
 
-struct class_device_attribute;
+struct device_attribute;
 /*The limit of outstanding scsi command that firmware can handle*/
 #define ARCMSR_MAX_OUTSTANDING_CMD						256
 #define ARCMSR_MAX_FREECCB_NUM							320
@@ -556,6 +556,6 @@ struct SENSE_DATA
 extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *);
 extern void arcmsr_iop_message_read(struct AdapterControlBlock *);
 extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
-extern struct class_device_attribute *arcmsr_host_attrs[];
+extern struct device_attribute *arcmsr_host_attrs[];
 extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
 void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);
drivers/scsi/arcmsr/arcmsr_attr.c +96 -67

277 lines not on this page · raw message

drivers/scsi/ch.c +6 -7
index 92d1cb1..75c84d7 100644
@@ -881,7 +881,7 @@ static long ch_ioctl_compat(struct file * file,
 static int ch_probe(struct device *dev)
 {
 	struct scsi_device *sd = to_scsi_device(dev);
-	struct class_device *class_dev;
+	struct device *class_dev;
 	int minor, ret = -ENOMEM;
 	scsi_changer *ch;
 
@@ -910,11 +910,11 @@ static int ch_probe(struct device *dev)
 	ch->minor = minor;
 	sprintf(ch->name,"ch%d",ch->minor);
 
-	class_dev = class_device_create(ch_sysfs_class, NULL,
-					MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
-					dev, "s%s", ch->name);
+	class_dev = device_create(ch_sysfs_class, dev,
+				  MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
+				  "s%s", ch->name);
 	if (IS_ERR(class_dev)) {
-		printk(KERN_WARNING "ch%d: class_device_create failed\n",
+		printk(KERN_WARNING "ch%d: device_create failed\n",
 		       ch->minor);
 		ret = PTR_ERR(class_dev);
 		goto remove_idr;
@@ -945,8 +945,7 @@ static int ch_remove(struct device *dev)
 	idr_remove(&ch_index_idr, ch->minor);
 	spin_unlock(&ch_index_lock);
 
-	class_device_destroy(ch_sysfs_class,
-			     MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
+	device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
 	kfree(ch->dt);
 	kfree(ch);
 	return 0;
drivers/scsi/hosts.c +17 -17
index 1592640..c264a8c 100644
@@ -43,14 +43,14 @@
 static int scsi_host_next_hn;		/* host_no for next new host */
 
 
-static void scsi_host_cls_release(struct class_device *class_dev)
+static void scsi_host_cls_release(struct device *dev)
 {
-	put_device(&class_to_shost(class_dev)->shost_gendev);
+	put_device(&class_to_shost(dev)->shost_gendev);
 }
 
 static struct class shost_class = {
 	.name		= "scsi_host",
-	.release	= scsi_host_cls_release,
+	.dev_release	= scsi_host_cls_release,
 };
 
 /**
@@ -174,7 +174,7 @@ void scsi_remove_host(struct Scsi_Host *shost)
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
 	transport_unregister_device(&shost->shost_gendev);
-	class_device_unregister(&shost->shost_classdev);
+	device_unregister(&shost->shost_dev);
 	device_del(&shost->shost_gendev);
 	scsi_proc_hostdir_rm(shost->hostt);
 }
@@ -212,7 +212,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
 	scsi_host_set_state(shost, SHOST_RUNNING);
 	get_device(shost->shost_gendev.parent);
 
-	error = class_device_add(&shost->shost_classdev);
+	error = device_add(&shost->shost_dev);
 	if (error)
 		goto out_del_gendev;
 
@@ -223,7 +223,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
 					 GFP_KERNEL);
 		if (shost->shost_data == NULL) {
 			error = -ENOMEM;
-			goto out_del_classdev;
+			goto out_del_dev;
 		}
 	}
 
@@ -250,8 +250,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
 		destroy_workqueue(shost->work_q);
  out_free_shost_data:
 	kfree(shost->shost_data);
- out_del_classdev:
-	class_device_del(&shost->shost_classdev);
+ out_del_dev:
+	device_del(&shost->shost_dev);
  out_del_gendev:
 	device_del(&shost->shost_gendev);
  out:
@@ -385,11 +385,11 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
 		shost->host_no);
 	shost->shost_gendev.release = scsi_host_dev_release;
 
-	class_device_initialize(&shost->shost_classdev);
-	shost->shost_classdev.dev = &shost->shost_gendev;
-	shost->shost_classdev.class = &shost_class;
-	snprintf(shost->shost_classdev.class_id, BUS_ID_SIZE, "host%d",
-		  shost->host_no);
+	device_initialize(&shost->shost_dev);
+	shost->shost_dev.parent = &shost->shost_gendev;
+	shost->shost_dev.class = &shost_class;
+	snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d",
+		 shost->host_no);
 
 	shost->ehandler = kthread_run(scsi_error_handler, shost,
 			"scsi_eh_%d", shost->host_no);
@@ -432,12 +432,12 @@ void scsi_unregister(struct Scsi_Host *shost)
 }
 EXPORT_SYMBOL(scsi_unregister);
 
-static int __scsi_host_match(struct class_device *cdev, void *data)
+static int __scsi_host_match(struct device *dev, void *data)
 {
 	struct Scsi_Host *p;
 	unsigned short *hostnum = (unsigned short *)data;
 
-	p = class_to_shost(cdev);
+	p = class_to_shost(dev);
 	return p->host_no == *hostnum;
 }
 
@@ -450,10 +450,10 @@ static int __scsi_host_match(struct class_device *cdev, void *data)
  **/
 struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
 {
-	struct class_device *cdev;
+	struct device *cdev;
 	struct Scsi_Host *shost = ERR_PTR(-ENXIO);
 
-	cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match);
+	cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
 	if (cdev)
 		shost = scsi_host_get(class_to_shost(cdev));
 
drivers/scsi/hptiop.c +8 -6
index beecda9..5b7be1e 100644
@@ -859,14 +859,16 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,
 	return queue_depth;
 }
 
-static ssize_t hptiop_show_version(struct class_device *class_dev, char *buf)
+static ssize_t hptiop_show_version(struct device *dev,
+				   struct device_attribute *attr, char *buf)
 {
 	return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver);
 }
 
-static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf)
+static ssize_t hptiop_show_fw_version(struct device *dev,
+				      struct device_attribute *attr, char *buf)
 {
-	struct Scsi_Host *host = class_to_shost(class_dev);
+	struct Scsi_Host *host = class_to_shost(dev);
 	struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;
 
 	return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n",
@@ -876,7 +878,7 @@ static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf)
 				hba->firmware_version & 0xff);
 }
 
-static struct class_device_attribute hptiop_attr_version = {
+static struct device_attribute hptiop_attr_version = {
 	.attr = {
 		.name = "driver-version",
 		.mode = S_IRUGO,
@@ -884,7 +886,7 @@ static struct class_device_attribute hptiop_attr_version = {
 	.show = hptiop_show_version,
 };
 
-static struct class_device_attribute hptiop_attr_fw_version = {
+static struct device_attribute hptiop_attr_fw_version = {
 	.attr = {
 		.name = "firmware-version",
 		.mode = S_IRUGO,
@@ -892,7 +894,7 @@ static struct class_device_attribute hptiop_attr_fw_version = {
 	.show = hptiop_show_fw_version,
 };
 
-static struct class_device_attribute *hptiop_attrs[] = {
+static struct device_attribute *hptiop_attrs[] = {
 	&hptiop_attr_version,
 	&hptiop_attr_fw_version,
 	NULL
drivers/scsi/ibmvscsi/ibmvscsi.c +25 -19

130 lines not on this page · raw message

drivers/scsi/ibmvscsi/ibmvstgt.c +14 -11
index e5881e9..3b9514c 100644
@@ -780,32 +780,35 @@ static int ibmvstgt_it_nexus_response(struct Scsi_Host *shost, u64 itn_id,
 	return 0;
 }
 
-static ssize_t system_id_show(struct class_device *cdev, char *buf)
+static ssize_t system_id_show(struct device *dev,
+			      struct device_attribute *attr, char *buf)
 {
 	return snprintf(buf, PAGE_SIZE, "%s\n", system_id);
 }
 
-static ssize_t partition_number_show(struct class_device *cdev, char *buf)
+static ssize_t partition_number_show(struct device *dev,
+				     struct device_attribute *attr, char *buf)
 {
 	return snprintf(buf, PAGE_SIZE, "%x\n", partition_number);
 }
 
-static ssize_t unit_address_show(struct class_device *cdev, char *buf)
+static ssize_t unit_address_show(struct device *dev,
+				  struct device_attribute *attr, char *buf)
 {
-	struct Scsi_Host *shost = class_to_shost(cdev);
+	struct Scsi_Host *shost = class_to_shost(dev);
 	struct srp_target *target = host_to_srp_target(shost);
 	struct vio_port *vport = target_to_port(target);
 	return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address);
 }
 
-static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL);
-static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
-static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
+static DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL);
+static DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
+static DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
 
-static struct class_device_attribute *ibmvstgt_attrs[] = {
-	&class_device_attr_system_id,
-	&class_device_attr_partition_number,
-	&class_device_attr_unit_address,
+static struct device_attribute *ibmvstgt_attrs[] = {
+	&dev_attr_system_id,
+	&dev_attr_partition_number,
+	&dev_attr_unit_address,
 	NULL,
 };
 
drivers/scsi/ipr.c +75 -65

358 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_attr.c +257 -227

506 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_crtn.h +2 -2
index 0819f5f..7c9f831 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/megaraid/megaraid_mbox.c +7 -6
index 9f04192..820f91f 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/ncr53c8xx.c +4 -3
index c5ebf01..d892894 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/osst.c +39 -37

76 lines not on this page · raw message

drivers/scsi/pcmcia/sym53c500_cs.c +8 -6
index 3454a57..0be232b 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/qla2xxx/qla_attr.c +96 -81

177 lines not on this page · raw message

drivers/scsi/qla2xxx/qla_gbl.h +2 -2
index a9571c2..76eb4fe 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/raid_class.c +37 -36

73 lines not on this page · raw message

drivers/scsi/scsi_sas_internal.h +12 -12
index e1edab4..998cb5b 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/scsi_sysfs.c +85 -65

150 lines not on this page · raw message

drivers/scsi/scsi_transport_fc.c +208 -177

385 lines not on this page · raw message

drivers/scsi/scsi_transport_iscsi.c +55 -52

107 lines not on this page · raw message

drivers/scsi/scsi_transport_sas.c +88 -69

157 lines not on this page · raw message

drivers/scsi/scsi_transport_spi.c +98 -87

185 lines not on this page · raw message

drivers/scsi/scsi_transport_srp.c +14 -12
index 2445c98..8a7af95 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/sd.c +44 -34

78 lines not on this page · raw message

drivers/scsi/ses.c +14 -14
index a6d9669..45df83b 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/sg.c +18 -18
index e5156aa..2029422 100644

Lines of this file are not shown. View the raw message.

drivers/scsi/st.c +44 -38

82 lines not on this page · raw message

include/linux/attribute_container.h +14 -14
index 574b201..794ad74 100644

Lines of this file are not shown. View the raw message.

include/linux/bsg.h +1 -1
index 60e377b..e8406c5 100644

Lines of this file are not shown. View the raw message.

include/linux/enclosure.h +6 -5
index a5978f1..4332442 100644

Lines of this file are not shown. View the raw message.

include/linux/libata.h +1 -1
index 165734a..07ed56f 100644

Lines of this file are not shown. View the raw message.

include/linux/raid_class.h +6 -6
index d22ad39..6b537f1 100644

Lines of this file are not shown. View the raw message.

include/linux/transport_class.h +3 -3
index 6696cf7..eaec1ea 100644

Lines of this file are not shown. View the raw message.

include/scsi/scsi_device.h +5 -5
index ab7acbe..b8b19e2 100644

Lines of this file are not shown. View the raw message.

include/scsi/scsi_host.h +3 -4
index 4913286..d967d6d 100644

Lines of this file are not shown. View the raw message.

include/scsi/scsi_transport.h +1 -1
index 0dfef75..490bd13 100644

Lines of this file are not shown. View the raw message.

include/scsi/scsi_transport_fc.h +7 -7
index 4769efd..06f72ba 100644

Lines of this file are not shown. View the raw message.

include/scsi/scsi_transport_sas.h +6 -6
index 09125fa..61ad359 100644

Lines of this file are not shown. View the raw message.

include/scsi/sd.h +2 -2
index 8ea9f73..4f032d4 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.4.5

Part of the diff is not shown here. View the raw message.

#34 lore raw

Re: [PATCH 33/36] IB: convert struct class_device to struct device

In reply to Greg Kroah-Hartman

Looks like something slipped into the tree as part of my recent merge... please apply the following patch first if it's not too late, so this doesn't break the ipath driver build.

Otherwise we can merge this later I guess...
---
IB/ipath: Remove reference to dev->class_dev

Commit 124b4dcb ("IB/ipath: add calls to new 7220 code and enable in build") inadvertently added core to set dev->class_dev.dev back into ib_ipath. This is completely redundant since commit 1912ffbb ("IB: Set class_dev->dev in core for nice device symlink"), which removed class_dev setting from low-level drivers, and also will break the build when class_dev is removed completely from struct ib_device.

---
 drivers/infiniband/hw/ipath/ipath_verbs.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/infiniband/hw/ipath/ipath_verbs.c +0 -1
index 5734520..8af3b46 100644
@@ -2067,7 +2067,6 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
 	dev->phys_port_cnt = 1;
 	dev->num_comp_vectors = 1;
 	dev->dma_device = &dd->pcidev->dev;
-	dev->class_dev.dev = dev->dma_device;
 	dev->query_device = ipath_query_device;
 	dev->modify_device = ipath_modify_device;
 	dev->query_port = ipath_query_port;