Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+19 -36
-1
drivers/pnp/base.h
··· 6 6 7 7 extern struct mutex pnp_lock; 8 8 extern const struct attribute_group *pnp_dev_groups[]; 9 - void *pnp_alloc(long size); 10 9 11 10 int pnp_register_protocol(struct pnp_protocol *protocol); 12 11 void pnp_unregister_protocol(struct pnp_protocol *protocol);
+7 -7
drivers/pnp/card.c
··· 80 80 if (!id) 81 81 return 0; 82 82 83 - clink = pnp_alloc(sizeof(*clink)); 83 + clink = kzalloc(sizeof(*clink), GFP_KERNEL); 84 84 if (!clink) 85 85 return 0; 86 86 clink->card = card; ··· 181 181 return card; 182 182 } 183 183 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) 186 186 { 187 187 char *str = buf; 188 188 struct pnp_card *card = to_pnp_card(dmdev); ··· 191 191 return (str - buf); 192 192 } 193 193 194 - static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL); 194 + static DEVICE_ATTR_RO(name); 195 195 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) 198 198 { 199 199 char *str = buf; 200 200 struct pnp_card *card = to_pnp_card(dmdev); ··· 207 207 return (str - buf); 208 208 } 209 209 210 - static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL); 210 + static DEVICE_ATTR_RO(card_id); 211 211 212 212 static int pnp_interface_attach_card(struct pnp_card *card) 213 213 {
+2 -15
drivers/pnp/core.c
··· 31 31 int pnp_platform_devices; 32 32 EXPORT_SYMBOL(pnp_platform_devices); 33 33 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 - 46 34 static void pnp_remove_protocol(struct pnp_protocol *protocol) 47 35 { 48 36 mutex_lock(&pnp_lock); ··· 215 227 for (id = dev->id; id; id = id->next) 216 228 len += scnprintf(buf + len, sizeof(buf) - len, " %s", id->id); 217 229 218 - dev_printk(KERN_DEBUG, &dev->dev, "%s device, IDs%s (%s)\n", 219 - dev->protocol->name, buf, 220 - dev->active ? "active" : "disabled"); 230 + dev_dbg(&dev->dev, "%s device, IDs%s (%s)\n", dev->protocol->name, buf, 231 + dev->active ? "active" : "disabled"); 221 232 return 0; 222 233 } 223 234
+2 -2
drivers/pnp/interface.c
··· 214 214 int ret, dep = 0, set = 0; 215 215 char *indent; 216 216 217 - buffer = pnp_alloc(sizeof(pnp_info_buffer_t)); 217 + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); 218 218 if (!buffer) 219 219 return -ENOMEM; 220 220 ··· 257 257 if (!dev) 258 258 return -EINVAL; 259 259 260 - buffer = pnp_alloc(sizeof(pnp_info_buffer_t)); 260 + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); 261 261 if (!buffer) 262 262 return -ENOMEM; 263 263
+6 -7
drivers/pnp/isapnp/proc.c
··· 57 57 static int isapnp_proc_attach_device(struct pnp_dev *dev) 58 58 { 59 59 struct pnp_card *bus = dev->card; 60 - struct proc_dir_entry *de, *e; 61 60 char name[16]; 62 61 63 - if (!(de = bus->procdir)) { 62 + if (!bus->procdir) { 64 63 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) 67 66 return -ENOMEM; 68 67 } 69 68 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, 71 70 &isapnp_proc_bus_proc_ops, dev); 72 - if (!e) 71 + if (!dev->procent) 73 72 return -ENOMEM; 74 - proc_set_size(e, 256); 73 + proc_set_size(dev->procent, 256); 75 74 return 0; 76 75 } 77 76
+1 -3
drivers/pnp/pnpbios/core.c
··· 298 298 299 299 static int __init insert_device(struct pnp_bios_node *node) 300 300 { 301 - struct list_head *pos; 302 301 struct pnp_dev *dev; 303 302 char id[8]; 304 303 int error; 305 304 306 305 /* 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) { 309 307 if (dev->number == node->handle) 310 308 return -EEXIST; 311 309 }
+1 -1
drivers/pnp/resource.c
··· 540 540 res->start = irq; 541 541 res->end = irq; 542 542 543 - dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res); 543 + dev_dbg(&dev->dev, "%pR\n", res); 544 544 return pnp_res; 545 545 } 546 546