Skip to content

Commit 72ad9f9

Browse files
committed
Merge tag 'pnp-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull PNP updates from Rafael Wysocki: "These get rid of unnecessary local variables and function, reduce code duplication and clean up message printing. Specifics: - Remove unnecessary local variables from isapnp_proc_attach_device() (Anupama K Patil). - Make the callers of pnp_alloc() use kzalloc() directly and drop the former (Heiner Kallweit). - Make two pieces of code use dev_dbg() instead of dev_printk() with the KERN_DEBUG message level (Heiner Kallweit). - Use DEVICE_ATTR_RO() instead of full DEVICE_ATTR() in some places in card.c (Zhen Lei). - Use list_for_each_entry() instead of list_for_each() in insert_device() (Zou Wei)" * tag 'pnp-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PNP: pnpbios: Use list_for_each_entry() instead of list_for_each() PNP: use DEVICE_ATTR_RO macro PNP: Switch over to dev_dbg() PNP: Remove pnp_alloc() drivers: pnp: isapnp: proc.c: Remove unnecessary local variables
2 parents 5e69282 + 17aa26c commit 72ad9f9

File tree

7 files changed

+19
-36
lines changed

7 files changed

+19
-36
lines changed

drivers/pnp/base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
extern struct mutex pnp_lock;
88
extern const struct attribute_group *pnp_dev_groups[];
9-
void *pnp_alloc(long size);
109

1110
int pnp_register_protocol(struct pnp_protocol *protocol);
1211
void pnp_unregister_protocol(struct pnp_protocol *protocol);

drivers/pnp/card.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
8080
if (!id)
8181
return 0;
8282

83-
clink = pnp_alloc(sizeof(*clink));
83+
clink = kzalloc(sizeof(*clink), GFP_KERNEL);
8484
if (!clink)
8585
return 0;
8686
clink->card = card;
@@ -181,8 +181,8 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnp
181181
return card;
182182
}
183183

184-
static ssize_t pnp_show_card_name(struct device *dmdev,
185-
struct device_attribute *attr, char *buf)
184+
static ssize_t name_show(struct device *dmdev,
185+
struct device_attribute *attr, char *buf)
186186
{
187187
char *str = buf;
188188
struct pnp_card *card = to_pnp_card(dmdev);
@@ -191,10 +191,10 @@ static ssize_t pnp_show_card_name(struct device *dmdev,
191191
return (str - buf);
192192
}
193193

194-
static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL);
194+
static DEVICE_ATTR_RO(name);
195195

196-
static ssize_t pnp_show_card_ids(struct device *dmdev,
197-
struct device_attribute *attr, char *buf)
196+
static ssize_t card_id_show(struct device *dmdev,
197+
struct device_attribute *attr, char *buf)
198198
{
199199
char *str = buf;
200200
struct pnp_card *card = to_pnp_card(dmdev);
@@ -207,7 +207,7 @@ static ssize_t pnp_show_card_ids(struct device *dmdev,
207207
return (str - buf);
208208
}
209209

210-
static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL);
210+
static DEVICE_ATTR_RO(card_id);
211211

212212
static int pnp_interface_attach_card(struct pnp_card *card)
213213
{

drivers/pnp/core.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ DEFINE_MUTEX(pnp_lock);
3131
int pnp_platform_devices;
3232
EXPORT_SYMBOL(pnp_platform_devices);
3333

34-
void *pnp_alloc(long size)
35-
{
36-
void *result;
37-
38-
result = kzalloc(size, GFP_KERNEL);
39-
if (!result) {
40-
printk(KERN_ERR "pnp: Out of Memory\n");
41-
return NULL;
42-
}
43-
return result;
44-
}
45-
4634
static void pnp_remove_protocol(struct pnp_protocol *protocol)
4735
{
4836
mutex_lock(&pnp_lock);
@@ -227,9 +215,8 @@ int pnp_add_device(struct pnp_dev *dev)
227215
for (id = dev->id; id; id = id->next)
228216
len += scnprintf(buf + len, sizeof(buf) - len, " %s", id->id);
229217

230-
dev_printk(KERN_DEBUG, &dev->dev, "%s device, IDs%s (%s)\n",
231-
dev->protocol->name, buf,
232-
dev->active ? "active" : "disabled");
218+
dev_dbg(&dev->dev, "%s device, IDs%s (%s)\n", dev->protocol->name, buf,
219+
dev->active ? "active" : "disabled");
233220
return 0;
234221
}
235222

drivers/pnp/interface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static ssize_t options_show(struct device *dmdev, struct device_attribute *attr,
214214
int ret, dep = 0, set = 0;
215215
char *indent;
216216

217-
buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
217+
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
218218
if (!buffer)
219219
return -ENOMEM;
220220

@@ -257,7 +257,7 @@ static ssize_t resources_show(struct device *dmdev,
257257
if (!dev)
258258
return -EINVAL;
259259

260-
buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
260+
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
261261
if (!buffer)
262262
return -ENOMEM;
263263

drivers/pnp/isapnp/proc.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,20 @@ static const struct proc_ops isapnp_proc_bus_proc_ops = {
5757
static int isapnp_proc_attach_device(struct pnp_dev *dev)
5858
{
5959
struct pnp_card *bus = dev->card;
60-
struct proc_dir_entry *de, *e;
6160
char name[16];
6261

63-
if (!(de = bus->procdir)) {
62+
if (!bus->procdir) {
6463
sprintf(name, "%02x", bus->number);
65-
de = bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir);
66-
if (!de)
64+
bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir);
65+
if (!bus->procdir)
6766
return -ENOMEM;
6867
}
6968
sprintf(name, "%02x", dev->number);
70-
e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de,
69+
dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, bus->procdir,
7170
&isapnp_proc_bus_proc_ops, dev);
72-
if (!e)
71+
if (!dev->procent)
7372
return -ENOMEM;
74-
proc_set_size(e, 256);
73+
proc_set_size(dev->procent, 256);
7574
return 0;
7675
}
7776

drivers/pnp/pnpbios/core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,12 @@ struct pnp_protocol pnpbios_protocol = {
298298

299299
static int __init insert_device(struct pnp_bios_node *node)
300300
{
301-
struct list_head *pos;
302301
struct pnp_dev *dev;
303302
char id[8];
304303
int error;
305304

306305
/* check if the device is already added */
307-
list_for_each(pos, &pnpbios_protocol.devices) {
308-
dev = list_entry(pos, struct pnp_dev, protocol_list);
306+
list_for_each_entry(dev, &pnpbios_protocol.devices, protocol_list) {
309307
if (dev->number == node->handle)
310308
return -EEXIST;
311309
}

drivers/pnp/resource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
540540
res->start = irq;
541541
res->end = irq;
542542

543-
dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res);
543+
dev_dbg(&dev->dev, "%pR\n", res);
544544
return pnp_res;
545545
}
546546

0 commit comments

Comments
 (0)