Skip to content

Commit ab69bcd

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (28 commits) driver core: device_rename's new_name can be const sysfs: Remove owner field from sysfs struct attribute powerpc/pci: Remove owner field from attribute initialization in PCI bridge init regulator: Remove owner field from attribute initialization in regulator core driver leds: Remove owner field from attribute initialization in bd2802 driver scsi: Remove owner field from attribute initialization in ARCMSR driver scsi: Remove owner field from attribute initialization in LPFC driver cgroupfs: create /sys/fs/cgroup to mount cgroupfs on Driver core: Add BUS_NOTIFY_BIND_DRIVER driver core: fix memory leak on one error path in bus_register() debugfs: no longer needs to depend on SYSFS sysfs: Fix one more signature discrepancy between sysfs implementation and docs. sysfs: fix discrepancies between implementation and documentation dcdbas: remove a redundant smi_data_buf_free in dcdbas_exit dmi-id: fix a memory leak in dmi_id_init error path sysfs: sysfs_chmod_file's attr can be const firmware: Update hotplug script Driver core: move platform device creation helpers to .init.text (if MODULE=n) Driver core: reduce duplicated code for platform_device creation Driver core: use kmemdup in platform_device_add_resources ...
2 parents c513b67 + 6937e8f commit ab69bcd

26 files changed

Lines changed: 288 additions & 290 deletions

File tree

‎Documentation/DocBook/device-drivers.tmpl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ X!Edrivers/base/attribute_container.c
111111
<!--
112112
X!Edrivers/base/interface.c
113113
-->
114+
!Iinclude/linux/platform_device.h
114115
!Edrivers/base/platform.c
115116
!Edrivers/base/bus.c
116117
</sect1>

‎Documentation/filesystems/sysfs.txt‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sysfs - _The_ filesystem for exporting kernel objects.
44
Patrick Mochel <mochel@osdl.org>
55
Mike Murphy <mamurph@cs.clemson.edu>
66

7-
Revised: 22 February 2009
7+
Revised: 15 July 2010
88
Original: 10 January 2003
99

1010

@@ -124,7 +124,7 @@ show and store methods of the attribute owners.
124124

125125
struct sysfs_ops {
126126
ssize_t (*show)(struct kobject *, struct attribute *, char *);
127-
ssize_t (*store)(struct kobject *, struct attribute *, const char *);
127+
ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t);
128128
};
129129

130130
[ Subsystems should have already defined a struct kobj_type as a
@@ -139,18 +139,22 @@ calls the associated methods.
139139

140140
To illustrate:
141141

142+
#define to_dev(obj) container_of(obj, struct device, kobj)
142143
#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
143-
#define to_dev(d) container_of(d, struct device, kobj)
144144

145-
static ssize_t
146-
dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
145+
static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
146+
char *buf)
147147
{
148-
struct device_attribute * dev_attr = to_dev_attr(attr);
149-
struct device * dev = to_dev(kobj);
150-
ssize_t ret = 0;
148+
struct device_attribute *dev_attr = to_dev_attr(attr);
149+
struct device *dev = to_dev(kobj);
150+
ssize_t ret = -EIO;
151151

152152
if (dev_attr->show)
153-
ret = dev_attr->show(dev, buf);
153+
ret = dev_attr->show(dev, dev_attr, buf);
154+
if (ret >= (ssize_t)PAGE_SIZE) {
155+
print_symbol("dev_attr_show: %s returned bad count\n",
156+
(unsigned long)dev_attr->show);
157+
}
154158
return ret;
155159
}
156160

@@ -163,10 +167,9 @@ To read or write attributes, show() or store() methods must be
163167
specified when declaring the attribute. The method types should be as
164168
simple as those defined for device attributes:
165169

166-
ssize_t (*show)(struct device * dev, struct device_attribute * attr,
167-
char * buf);
168-
ssize_t (*store)(struct device * dev, struct device_attribute * attr,
169-
const char * buf);
170+
ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf);
171+
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
172+
const char *buf, size_t count);
170173

171174
IOW, they should take only an object, an attribute, and a buffer as parameters.
172175

@@ -209,8 +212,8 @@ Other notes:
209212

210213
- show() should always use snprintf().
211214

212-
- store() should return the number of bytes used from the buffer. This
213-
can be done using strlen().
215+
- store() should return the number of bytes used from the buffer. If the
216+
entire buffer has been used, just return the count argument.
214217

215218
- show() or store() can always return errors. If a bad value comes
216219
through, be sure to return an error.
@@ -223,15 +226,18 @@ Other notes:
223226

224227
A very simple (and naive) implementation of a device attribute is:
225228

226-
static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
229+
static ssize_t show_name(struct device *dev, struct device_attribute *attr,
230+
char *buf)
227231
{
228232
return snprintf(buf, PAGE_SIZE, "%s\n", dev->name);
229233
}
230234

231-
static ssize_t store_name(struct device * dev, const char * buf)
235+
static ssize_t store_name(struct device *dev, struct device_attribute *attr,
236+
const char *buf, size_t count)
232237
{
233-
sscanf(buf, "%20s", dev->name);
234-
return strnlen(buf, PAGE_SIZE);
238+
snprintf(dev->name, sizeof(dev->name), "%.*s",
239+
(int)min(count, sizeof(dev->name) - 1), buf);
240+
return count;
235241
}
236242

237243
static DEVICE_ATTR(name, S_IRUGO, show_name, store_name);
@@ -327,7 +333,7 @@ Structure:
327333
struct bus_attribute {
328334
struct attribute attr;
329335
ssize_t (*show)(struct bus_type *, char * buf);
330-
ssize_t (*store)(struct bus_type *, const char * buf);
336+
ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
331337
};
332338

333339
Declaring:

‎Documentation/firmware_class/hotplug-script‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/
88

9-
echo 1 > /sys/$DEVPATH/loading
10-
cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
11-
echo 0 > /sys/$DEVPATH/loading
12-
13-
# To cancel the load in case of error:
14-
#
15-
# echo -1 > /sys/$DEVPATH/loading
16-
#
9+
if [ "$SUBSYSTEM" == "firmware" -a "$ACTION" == "add" ]; then
10+
if [ -f $HOTPLUG_FW_DIR/$FIRMWARE ]; then
11+
echo 1 > /sys/$DEVPATH/loading
12+
cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
13+
echo 0 > /sys/$DEVPATH/loading
14+
else
15+
echo -1 > /sys/$DEVPATH/loading
16+
fi
17+
fi

‎arch/powerpc/sysdev/mv64x60_pci.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static struct bin_attribute mv64x60_hs_reg_attr = { /* Hotswap register */
7373
.attr = {
7474
.name = "hs_reg",
7575
.mode = S_IRUGO | S_IWUSR,
76-
.owner = THIS_MODULE,
7776
},
7877
.size = MV64X60_VAL_LEN_MAX,
7978
.read = mv64x60_hs_reg_read,

‎drivers/base/bus.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,8 @@ int bus_register(struct bus_type *bus)
945945
bus_remove_file(bus, &bus_attr_uevent);
946946
bus_uevent_fail:
947947
kset_unregister(&bus->p->subsys);
948-
kfree(bus->p);
949948
out:
949+
kfree(bus->p);
950950
bus->p = NULL;
951951
return retval;
952952
}

‎drivers/base/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ EXPORT_SYMBOL_GPL(device_destroy);
15991599
* on the same device to ensure that new_name is valid and
16001600
* won't conflict with other devices.
16011601
*/
1602-
int device_rename(struct device *dev, char *new_name)
1602+
int device_rename(struct device *dev, const char *new_name)
16031603
{
16041604
char *old_class_name = NULL;
16051605
char *new_class_name = NULL;

‎drivers/base/dd.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ static int driver_sysfs_add(struct device *dev)
5151
{
5252
int ret;
5353

54+
if (dev->bus)
55+
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
56+
BUS_NOTIFY_BIND_DRIVER, dev);
57+
5458
ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj,
5559
kobject_name(&dev->kobj));
5660
if (ret == 0) {

‎drivers/base/dma-coherent.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
struct dma_coherent_mem {
1010
void *virt_base;
11-
u32 device_base;
11+
dma_addr_t device_base;
1212
int size;
1313
int flags;
1414
unsigned long *bitmap;

0 commit comments

Comments
 (0)