From da19cbcf71cde3c09587b5924d113f0c7f1fd23a Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Mon, 4 Feb 2008 23:35:47 -0800 Subject: driver core: memory: semaphore to mutex Signed-off-by: Daniel Walker Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- include/linux/memory.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/linux/memory.h b/include/linux/memory.h index 33f0ff0cf63..f80e0e331cb 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -18,8 +18,7 @@ #include #include #include - -#include +#include 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 *); -- cgit v1.2.3 From 1429db83e276c2a16c7ea83bdcf0dcd3a36e406d Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 26 Feb 2008 19:08:42 -0800 Subject: driver core: Convert debug functions declared inline __attribute__((format (printf,x,y) to statement expression macros 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 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 Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- include/linux/device.h | 15 +++++---------- include/linux/kernel.h | 6 ++---- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/linux/device.h b/include/linux/device.h index 2258d89bf52..d57661129cb 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -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. */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 2df44e77327..cd6d02cf854 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -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 /* -- cgit v1.2.3 From 3612e06b2c1cec41e9a59da3eec673a206af4643 Mon Sep 17 00:00:00 2001 From: David Rientjes Date: Tue, 19 Feb 2008 17:39:02 -0800 Subject: sysfs: small header file cleanup for SYSFS=n Convert sysfs_remove_bin_file() to have a return type of 'void' for !CONFIG_SYSFS configurations. Also removes unnecessary colons from empty void functions. Signed-off-by: David Rientjes Reviewed-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- include/linux/sysfs.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 802710438a9..03378e3515b 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -131,7 +131,6 @@ static inline int sysfs_create_dir(struct kobject *kobj) static inline void sysfs_remove_dir(struct kobject *kobj) { - ; } static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name) @@ -160,7 +159,6 @@ static inline int sysfs_chmod_file(struct kobject *kobj, static inline void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr) { - ; } static inline int sysfs_create_bin_file(struct kobject *kobj, @@ -169,10 +167,9 @@ static inline int sysfs_create_bin_file(struct kobject *kobj, return 0; } -static inline int sysfs_remove_bin_file(struct kobject *kobj, - struct bin_attribute *attr) +static inline void sysfs_remove_bin_file(struct kobject *kobj, + struct bin_attribute *attr) { - return 0; } static inline int sysfs_create_link(struct kobject *kobj, @@ -183,7 +180,6 @@ static inline int sysfs_create_link(struct kobject *kobj, static inline void sysfs_remove_link(struct kobject *kobj, const char *name) { - ; } static inline int sysfs_create_group(struct kobject *kobj, @@ -195,7 +191,6 @@ static inline int sysfs_create_group(struct kobject *kobj, static inline void sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp) { - ; } static inline int sysfs_add_file_to_group(struct kobject *kobj, -- cgit v1.2.3 From 58aca23226a19983571bd3b65167521fc64f5869 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 12 Mar 2008 00:57:22 +0100 Subject: PM: Handle device registrations during suspend/resume 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. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- include/linux/pm.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/pm.h b/include/linux/pm.h index 015b735811b..e6b9f29e27d 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -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; -- cgit v1.2.3 From d288e47c471e1090e80c62ad95882fafbf3f499d Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 19 Mar 2008 22:37:42 +0100 Subject: PM: Make wakeup flags available whenever CONFIG_PM is set 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] Signed-off-by: Alan Stern Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- include/linux/pm.h | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/linux/pm.h b/include/linux/pm.h index e6b9f29e27d..3342627e2bd 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -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. -- cgit v1.2.3 From 9a3df1f7de0ecaf77a1dde86f2a4dc020f37f87e Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 19 Mar 2008 22:39:13 +0100 Subject: PM: Convert wakeup flag accessors to inline functions 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. Signed-off-by: Alan Stern Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- 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 (limited to 'include') diff --git a/include/linux/device.h b/include/linux/device.h index d57661129cb..d7a1ae063b6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -475,6 +475,9 @@ struct device { void (*release)(struct device *dev); }; +/* Get the wakeup routines, which depend on struct device */ +#include + #ifdef CONFIG_NUMA static inline int dev_to_node(struct device *dev) { diff --git a/include/linux/pm.h b/include/linux/pm.h index 3342627e2bd..1de72cbbe0d 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -212,54 +212,10 @@ static inline int device_suspend(pm_message_t state) return 0; } -#define suspend_report_result(fn, ret) do { } while (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. - * Returns zero on success, else negative errno - */ -extern int (*platform_enable_wakeup)(struct device *dev, int is_on); - -static inline int call_platform_enable_wakeup(struct device *dev, int is_on) -{ - if (platform_enable_wakeup) - return (*platform_enable_wakeup)(dev, is_on); - return 0; -} - -#else /* !CONFIG_PM */ - -#define device_set_wakeup_enable(dev,val) do{}while(0) -#define device_may_wakeup(dev) (0) - -static inline int call_platform_enable_wakeup(struct device *dev, int is_on) -{ - return 0; -} - -#endif /* !CONFIG_PM */ - -/* changes to device_may_wakeup take effect on the next pm state change. - * by default, devices should wakeup if they can. - */ -#define device_can_wakeup(dev) \ - ((dev)->power.can_wakeup) -#define device_init_wakeup(dev,val) \ - do { \ - device_can_wakeup(dev) = !!(val); \ - device_set_wakeup_enable(dev,val); \ - } while(0) - /* * Global Power Management flags * Used to keep APM and ACPI from both being active diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h new file mode 100644 index 00000000000..f0d0b2cb8d2 --- /dev/null +++ b/include/linux/pm_wakeup.h @@ -0,0 +1,90 @@ +/* + * pm_wakeup.h - Power management wakeup interface + * + * Copyright (C) 2008 Alan Stern + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LINUX_PM_WAKEUP_H +#define _LINUX_PM_WAKEUP_H + +#ifndef _DEVICE_H_ +# error "please don't include this file directly" +#endif + +#ifdef CONFIG_PM + +/* changes to device_may_wakeup take effect on the next pm state change. + * by default, devices should wakeup if they can. + */ +static inline void device_init_wakeup(struct device *dev, int val) +{ + dev->power.can_wakeup = dev->power.should_wakeup = !!val; +} + +static inline int device_can_wakeup(struct device *dev) +{ + return dev->power.can_wakeup; +} + +static inline void device_set_wakeup_enable(struct device *dev, int val) +{ + dev->power.should_wakeup = !!val; +} + +static inline int device_may_wakeup(struct device *dev) +{ + return dev->power.can_wakeup & dev->power.should_wakeup; +} + +/* + * Platform hook to activate device wakeup capability, if that's not already + * handled by enable_irq_wake() etc. + * Returns zero on success, else negative errno + */ +extern int (*platform_enable_wakeup)(struct device *dev, int is_on); + +static inline int call_platform_enable_wakeup(struct device *dev, int is_on) +{ + if (platform_enable_wakeup) + return (*platform_enable_wakeup)(dev, is_on); + return 0; +} + +#else /* !CONFIG_PM */ + +/* For some reason the next two routines work even without CONFIG_PM */ +static inline void device_init_wakeup(struct device *dev, int val) +{ + dev->power.can_wakeup = !!val; +} + +static inline int device_can_wakeup(struct device *dev) +{ + return dev->power.can_wakeup; +} + +#define device_set_wakeup_enable(dev, val) do {} while (0) +#define device_may_wakeup(dev) 0 + +static inline int call_platform_enable_wakeup(struct device *dev, int is_on) +{ + return 0; +} + +#endif /* !CONFIG_PM */ + +#endif /* _LINUX_PM_WAKEUP_H */ -- cgit v1.2.3 From 3f62e5700b2a679ae987b32a68126dd6dcf2488f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 13 Mar 2008 17:07:03 -0400 Subject: Driver core: make device_is_registered() work for class devices 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. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- include/linux/device.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/device.h b/include/linux/device.h index d7a1ae063b6..441461f5ee2 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -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); -- cgit v1.2.3 From 138fe4e069798d9aa948a5402ff15e58f483ee4e Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Date: Wed, 9 Apr 2008 19:50:41 -0700 Subject: Firmware: add iSCSI iBFT Support 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 [akpm@linux-foundation.org: fix build] Signed-off-by: Konrad Rzeszutek Cc: Mike Christie Cc: Peter Jones Cc: James Bottomley Cc: Ingo Molnar Cc: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- include/linux/iscsi_ibft.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 include/linux/iscsi_ibft.h (limited to 'include') diff --git a/include/linux/iscsi_ibft.h b/include/linux/iscsi_ibft.h new file mode 100644 index 00000000000..6092487e295 --- /dev/null +++ b/include/linux/iscsi_ibft.h @@ -0,0 +1,50 @@ +/* + * Copyright 2007 Red Hat, Inc. + * by Peter Jones + * Copyright 2007 IBM, Inc. + * by Konrad Rzeszutek + * Copyright 2008 + * by Konrad Rzeszutek + * + * This code exposes the iSCSI Boot Format Table to userland via sysfs. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License v2.0 as published by + * the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef ISCSI_IBFT_H +#define ISCSI_IBFT_H + +struct ibft_table_header { + char signature[4]; + u32 length; + u8 revision; + u8 checksum; + char oem_id[6]; + char oem_table_id[8]; + char reserved[24]; +} __attribute__((__packed__)); + +/* + * Logical location of iSCSI Boot Format Table. + * If the value is NULL there is no iBFT on the machine. + */ +extern struct ibft_table_header *ibft_addr; + +/* + * Routine used to find and reserve the iSCSI Boot Format Table. The + * mapped address is set in the ibft_addr variable. + */ +#ifdef CONFIG_ISCSI_IBFT_FIND +extern void __init reserve_ibft_region(void); +#else +static inline void reserve_ibft_region(void) { } +#endif + +#endif /* ISCSI_IBFT_H */ -- cgit v1.2.3 From b844eba292b477cda14582bfc6f535deed57a82d Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Sun, 23 Mar 2008 20:28:24 +0100 Subject: PM: Remove destroy_suspended_device() 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. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- include/linux/device.h | 14 -------------- include/linux/hw_random.h | 10 +--------- include/linux/leds.h | 10 +--------- include/linux/miscdevice.h | 10 +--------- 4 files changed, 3 insertions(+), 41 deletions(-) (limited to 'include') diff --git a/include/linux/device.h b/include/linux/device.h index 441461f5ee2..dc3429e2eb0 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -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 diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h index 42131820bb8..85d11916e9e 100644 --- a/include/linux/hw_random.h +++ b/include/linux/hw_random.h @@ -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_ */ diff --git a/include/linux/leds.h b/include/linux/leds.h index 0201f6f51ce..b07e3d400bd 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -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); diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index 24b30b9b4f8..26433ec520b 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h @@ -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) \ -- cgit v1.2.3 From c4c66cf1787d408066fbfc69209185701f5df15f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 4 Mar 2008 00:13:36 +0100 Subject: memstick: convert struct class_device to struct device struct class_device is going away, struct device should be used instead. Signed-off-by: Tony Jones Signed-off-by: Kay Sievers Cc: Alex Dubov Signed-off-by: Greg Kroah-Hartman --- include/linux/memstick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/memstick.h b/include/linux/memstick.h index 3e686ec6a96..37a5cdb0391 100644 --- a/include/linux/memstick.h +++ b/include/linux/memstick.h @@ -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; -- cgit v1.2.3 From f4e91eb4a81559da87a3843758a641b5cc590b65 Mon Sep 17 00:00:00 2001 From: Tony Jones Date: Fri, 22 Feb 2008 00:13:36 +0100 Subject: IB: convert struct class_device to struct device This converts the main ib_device to use struct device instead of struct class_device as class_device is going away. Signed-off-by: Tony Jones Signed-off-by: Kay Sievers Cc: Roland Dreier Cc: Sean Hefty Cc: Hal Rosenstock Signed-off-by: Greg Kroah-Hartman --- include/rdma/ib_verbs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 95bf4bac44c..2dcbecce3f6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -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; -- cgit v1.2.3 From ee959b00c335d7780136c5abda37809191fe52c3 Mon Sep 17 00:00:00 2001 From: Tony Jones Date: Fri, 22 Feb 2008 00:13:36 +0100 Subject: SCSI: convert struct class_device to struct device It's big, but there doesn't seem to be a way to split it up smaller... Signed-off-by: Tony Jones Signed-off-by: Kay Sievers Cc: Roland Dreier Cc: Sean Hefty Cc: Hal Rosenstock Cc: James Bottomley Signed-off-by: Greg Kroah-Hartman --- 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 ++-- 12 files changed, 55 insertions(+), 55 deletions(-) (limited to 'include') diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h index 574b201b99d..794ad74b1d6 100644 --- a/include/linux/attribute_container.h +++ b/include/linux/attribute_container.h @@ -1,5 +1,5 @@ /* - * class_container.h - a generic container for all classes + * attribute_container.h - a generic container for all classes * * Copyright (c) 2005 - James Bottomley * @@ -18,7 +18,7 @@ struct attribute_container { struct klist containers; struct class *class; struct attribute_group *grp; - struct class_device_attribute **attrs; + struct device_attribute **attrs; int (*match)(struct attribute_container *, struct device *); #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 unsigned long flags; @@ -41,31 +41,31 @@ int __must_check attribute_container_unregister(struct attribute_container *cont void attribute_container_create_device(struct device *dev, int (*fn)(struct attribute_container *, struct device *, - struct class_device *)); + struct device *)); void attribute_container_add_device(struct device *dev, int (*fn)(struct attribute_container *, struct device *, - struct class_device *)); + struct device *)); void attribute_container_remove_device(struct device *dev, void (*fn)(struct attribute_container *, struct device *, - struct class_device *)); + struct device *)); void attribute_container_device_trigger(struct device *dev, int (*fn)(struct attribute_container *, struct device *, - struct class_device *)); + struct device *)); void attribute_container_trigger(struct device *dev, int (*fn)(struct attribute_container *, struct device *)); -int attribute_container_add_attrs(struct class_device *classdev); -int attribute_container_add_class_device(struct class_device *classdev); +int attribute_container_add_attrs(struct device *classdev); +int attribute_container_add_class_device(struct device *classdev); int attribute_container_add_class_device_adapter(struct attribute_container *cont, struct device *dev, - struct class_device *classdev); -void attribute_container_remove_attrs(struct class_device *classdev); -void attribute_container_class_device_del(struct class_device *classdev); -struct attribute_container *attribute_container_classdev_to_container(struct class_device *); -struct class_device *attribute_container_find_class_device(struct attribute_container *, struct device *); -struct class_device_attribute **attribute_container_classdev_to_attrs(const struct class_device *classdev); + struct device *classdev); +void attribute_container_remove_attrs(struct device *classdev); +void attribute_container_class_device_del(struct device *classdev); +struct attribute_container *attribute_container_classdev_to_container(struct device *); +struct device *attribute_container_find_class_device(struct attribute_container *, struct device *); +struct device_attribute **attribute_container_classdev_to_attrs(const struct device *classdev); #endif diff --git a/include/linux/bsg.h b/include/linux/bsg.h index 60e377b520f..e8406c55c6d 100644 --- a/include/linux/bsg.h +++ b/include/linux/bsg.h @@ -55,7 +55,7 @@ struct sg_io_v4 { #if defined(CONFIG_BLK_DEV_BSG) struct bsg_class_device { - struct class_device *class_dev; + struct device *class_dev; struct device *dev; int minor; struct request_queue *queue; diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h index a5978f18ca4..4332442b1b5 100644 --- a/include/linux/enclosure.h +++ b/include/linux/enclosure.h @@ -82,7 +82,8 @@ struct enclosure_component_callbacks { struct enclosure_component { void *scratch; - struct class_device cdev; + struct device cdev; + struct device *dev; enum enclosure_component_type type; int number; int fault; @@ -94,20 +95,20 @@ struct enclosure_component { struct enclosure_device { void *scratch; struct list_head node; - struct class_device cdev; + struct device edev; struct enclosure_component_callbacks *cb; int components; struct enclosure_component component[0]; }; static inline struct enclosure_device * -to_enclosure_device(struct class_device *dev) +to_enclosure_device(struct device *dev) { - return container_of(dev, struct enclosure_device, cdev); + return container_of(dev, struct enclosure_device, edev); } static inline struct enclosure_component * -to_enclosure_component(struct class_device *dev) +to_enclosure_component(struct device *dev) { return container_of(dev, struct enclosure_component, cdev); } diff --git a/include/linux/libata.h b/include/linux/libata.h index 165734a2dd4..07ed56f7a76 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -443,7 +443,7 @@ enum link_pm { MAX_PERFORMANCE, MEDIUM_POWER, }; -extern struct class_device_attribute class_device_attr_link_power_management_policy; +extern struct device_attribute dev_attr_link_power_management_policy; #ifdef CONFIG_ATA_SFF struct ata_ioports { diff --git a/include/linux/raid_class.h b/include/linux/raid_class.h index d22ad392242..6b537f1ac96 100644 --- a/include/linux/raid_class.h +++ b/include/linux/raid_class.h @@ -53,20 +53,20 @@ struct raid_data { #define DEFINE_RAID_ATTRIBUTE(type, attr) \ static inline void \ raid_set_##attr(struct raid_template *r, struct device *dev, type value) { \ - struct class_device *cdev = \ + struct device *device = \ attribute_container_find_class_device(&r->raid_attrs.ac, dev);\ struct raid_data *rd; \ - BUG_ON(!cdev); \ - rd = class_get_devdata(cdev); \ + BUG_ON(!device); \ + rd = dev_get_drvdata(device); \ rd->attr = value; \ } \ static inline type \ raid_get_##attr(struct raid_template *r, struct device *dev) { \ - struct class_device *cdev = \ + struct device *device = \ attribute_container_find_class_device(&r->raid_attrs.ac, dev);\ struct raid_data *rd; \ - BUG_ON(!cdev); \ - rd = class_get_devdata(cdev); \ + BUG_ON(!device); \ + rd = dev_get_drvdata(device); \ return rd->attr; \ } diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h index 6696cf79c4f..eaec1ea9558 100644 --- a/include/linux/transport_class.h +++ b/include/linux/transport_class.h @@ -17,11 +17,11 @@ struct transport_container; struct transport_class { struct class class; int (*setup)(struct transport_container *, struct device *, - struct class_device *); + struct device *); int (*configure)(struct transport_container *, struct device *, - struct class_device *); + struct device *); int (*remove)(struct transport_container *, struct device *, - struct class_device *); + struct device *); }; #define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \ diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index ab7acbe8096..b8b19e2f57b 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -156,8 +156,8 @@ struct scsi_device { int timeout; - struct device sdev_gendev; - struct class_device sdev_classdev; + struct device sdev_gendev, + sdev_dev; struct execute_work ew; /* used to get process context on put */ @@ -167,9 +167,9 @@ struct scsi_device { #define to_scsi_device(d) \ container_of(d, struct scsi_device, sdev_gendev) #define class_to_sdev(d) \ - container_of(d, struct scsi_device, sdev_classdev) + container_of(d, struct scsi_device, sdev_dev) #define transport_class_to_sdev(class_dev) \ - to_scsi_device(class_dev->dev) + to_scsi_device(class_dev->parent) #define sdev_printk(prefix, sdev, fmt, a...) \ dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) @@ -220,7 +220,7 @@ static inline struct scsi_target *scsi_target(struct scsi_device *sdev) return to_scsi_target(sdev->sdev_gendev.parent); } #define transport_class_to_starget(class_dev) \ - to_scsi_target(class_dev->dev) + to_scsi_target(class_dev->parent) #define starget_printk(prefix, starget, fmt, a...) \ dev_printk(prefix, &(starget)->dev, fmt, ##a) diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 49132862bfa..d967d6dc7a2 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -470,7 +470,7 @@ struct scsi_host_template { /* * Pointer to the sysfs class properties for this host, NULL terminated. */ - struct class_device_attribute **shost_attrs; + struct device_attribute **shost_attrs; /* * Pointer to the SCSI device properties for this host, NULL terminated. @@ -655,8 +655,7 @@ struct Scsi_Host { enum scsi_host_state shost_state; /* ldm bits */ - struct device shost_gendev; - struct class_device shost_classdev; + struct device shost_gendev, shost_dev; /* * List of hosts per template. @@ -683,7 +682,7 @@ struct Scsi_Host { }; #define class_to_shost(d) \ - container_of(d, struct Scsi_Host, shost_classdev) + container_of(d, struct Scsi_Host, shost_dev) #define shost_printk(prefix, shost, fmt, a...) \ dev_printk(prefix, &(shost)->shost_gendev, fmt, ##a) diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h index 0dfef752f0e..490bd13a634 100644 --- a/include/scsi/scsi_transport.h +++ b/include/scsi/scsi_transport.h @@ -80,7 +80,7 @@ struct scsi_transport_template { }; #define transport_class_to_shost(tc) \ - dev_to_shost((tc)->dev) + dev_to_shost((tc)->parent) /* Private area maintenance. The driver requested allocations come diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index 4769efd4db2..06f72bab9df 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h @@ -163,8 +163,8 @@ enum fc_tgtid_binding_type { /* Macro for use in defining Virtual Port attributes */ -#define FC_VPORT_ATTR(_name,_mode,_show,_store) \ -struct class_device_attribute class_device_attr_vport_##_name = \ +#define FC_VPORT_ATTR(_name,_mode,_show,_store) \ +struct device_attribute dev_attr_vport_##_name = \ __ATTR(_name,_mode,_show,_store) @@ -234,8 +234,8 @@ struct fc_vport { #define dev_to_vport(d) \ container_of(d, struct fc_vport, dev) -#define transport_class_to_vport(classdev) \ - dev_to_vport(classdev->dev) +#define transport_class_to_vport(dev) \ + dev_to_vport(dev->parent) #define vport_to_shost(v) \ (v->shost) #define vport_to_shost_channel(v) \ @@ -271,7 +271,7 @@ struct fc_rport_identifiers { /* Macro for use in defining Remote Port attributes */ #define FC_RPORT_ATTR(_name,_mode,_show,_store) \ -struct class_device_attribute class_device_attr_rport_##_name = \ +struct device_attribute dev_attr_rport_##_name = \ __ATTR(_name,_mode,_show,_store) @@ -341,8 +341,8 @@ struct fc_rport { /* aka fc_starget_attrs */ #define dev_to_rport(d) \ container_of(d, struct fc_rport, dev) -#define transport_class_to_rport(classdev) \ - dev_to_rport(classdev->dev) +#define transport_class_to_rport(dev) \ + dev_to_rport(dev->parent) #define rport_to_shost(r) \ dev_to_shost(r->dev.parent) diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h index 09125fa95b9..61ad3594aad 100644 --- a/include/scsi/scsi_transport_sas.h +++ b/include/scsi/scsi_transport_sas.h @@ -80,8 +80,8 @@ struct sas_phy { #define dev_to_phy(d) \ container_of((d), struct sas_phy, dev) -#define transport_class_to_phy(cdev) \ - dev_to_phy((cdev)->dev) +#define transport_class_to_phy(dev) \ + dev_to_phy((dev)->parent) #define phy_to_shost(phy) \ dev_to_shost((phy)->dev.parent) @@ -96,8 +96,8 @@ struct sas_rphy { #define dev_to_rphy(d) \ container_of((d), struct sas_rphy, dev) -#define transport_class_to_rphy(cdev) \ - dev_to_rphy((cdev)->dev) +#define transport_class_to_rphy(dev) \ + dev_to_rphy((dev)->parent) #define rphy_to_shost(rphy) \ dev_to_shost((rphy)->dev.parent) #define target_to_rphy(targ) \ @@ -152,8 +152,8 @@ struct sas_port { #define dev_to_sas_port(d) \ container_of((d), struct sas_port, dev) -#define transport_class_to_sas_port(cdev) \ - dev_to_sas_port((cdev)->dev) +#define transport_class_to_sas_port(dev) \ + dev_to_sas_port((dev)->parent) struct sas_phy_linkrates { enum sas_linkrate maximum_linkrate; diff --git a/include/scsi/sd.h b/include/scsi/sd.h index 8ea9f7358ac..4f032d48cb6 100644 --- a/include/scsi/sd.h +++ b/include/scsi/sd.h @@ -34,7 +34,7 @@ struct scsi_disk { struct scsi_driver *driver; /* always &sd_template */ struct scsi_device *device; - struct class_device cdev; + struct device dev; struct gendisk *disk; unsigned int openers; /* protected by BKL for now, yuck */ sector_t capacity; /* size in 512-byte sectors */ @@ -46,7 +46,7 @@ struct scsi_disk { unsigned RCD : 1; /* state of disk RCD bit, unused */ unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ }; -#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev) +#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) #define sd_printk(prefix, sdsk, fmt, a...) \ (sdsk)->disk ? \ -- cgit v1.2.3