Commit 72ad9f9d authored by Linus Torvalds's avatar Linus Torvalds

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
parents 5e692824 17aa26c9
......@@ -6,7 +6,6 @@
extern struct mutex pnp_lock;
extern const struct attribute_group *pnp_dev_groups[];
void *pnp_alloc(long size);
int pnp_register_protocol(struct pnp_protocol *protocol);
void pnp_unregister_protocol(struct pnp_protocol *protocol);
......
......@@ -80,7 +80,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
if (!id)
return 0;
clink = pnp_alloc(sizeof(*clink));
clink = kzalloc(sizeof(*clink), GFP_KERNEL);
if (!clink)
return 0;
clink->card = card;
......@@ -181,8 +181,8 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnp
return card;
}
static ssize_t pnp_show_card_name(struct device *dmdev,
struct device_attribute *attr, char *buf)
static ssize_t name_show(struct device *dmdev,
struct device_attribute *attr, char *buf)
{
char *str = buf;
struct pnp_card *card = to_pnp_card(dmdev);
......@@ -191,10 +191,10 @@ static ssize_t pnp_show_card_name(struct device *dmdev,
return (str - buf);
}
static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL);
static DEVICE_ATTR_RO(name);
static ssize_t pnp_show_card_ids(struct device *dmdev,
struct device_attribute *attr, char *buf)
static ssize_t card_id_show(struct device *dmdev,
struct device_attribute *attr, char *buf)
{
char *str = buf;
struct pnp_card *card = to_pnp_card(dmdev);
......@@ -207,7 +207,7 @@ static ssize_t pnp_show_card_ids(struct device *dmdev,
return (str - buf);
}
static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL);
static DEVICE_ATTR_RO(card_id);
static int pnp_interface_attach_card(struct pnp_card *card)
{
......
......@@ -31,18 +31,6 @@ DEFINE_MUTEX(pnp_lock);
int pnp_platform_devices;
EXPORT_SYMBOL(pnp_platform_devices);
void *pnp_alloc(long size)
{
void *result;
result = kzalloc(size, GFP_KERNEL);
if (!result) {
printk(KERN_ERR "pnp: Out of Memory\n");
return NULL;
}
return result;
}
static void pnp_remove_protocol(struct pnp_protocol *protocol)
{
mutex_lock(&pnp_lock);
......@@ -227,9 +215,8 @@ int pnp_add_device(struct pnp_dev *dev)
for (id = dev->id; id; id = id->next)
len += scnprintf(buf + len, sizeof(buf) - len, " %s", id->id);
dev_printk(KERN_DEBUG, &dev->dev, "%s device, IDs%s (%s)\n",
dev->protocol->name, buf,
dev->active ? "active" : "disabled");
dev_dbg(&dev->dev, "%s device, IDs%s (%s)\n", dev->protocol->name, buf,
dev->active ? "active" : "disabled");
return 0;
}
......
......@@ -214,7 +214,7 @@ static ssize_t options_show(struct device *dmdev, struct device_attribute *attr,
int ret, dep = 0, set = 0;
char *indent;
buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
if (!buffer)
return -ENOMEM;
......@@ -257,7 +257,7 @@ static ssize_t resources_show(struct device *dmdev,
if (!dev)
return -EINVAL;
buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
if (!buffer)
return -ENOMEM;
......
......@@ -57,21 +57,20 @@ static const struct proc_ops isapnp_proc_bus_proc_ops = {
static int isapnp_proc_attach_device(struct pnp_dev *dev)
{
struct pnp_card *bus = dev->card;
struct proc_dir_entry *de, *e;
char name[16];
if (!(de = bus->procdir)) {
if (!bus->procdir) {
sprintf(name, "%02x", bus->number);
de = bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir);
if (!de)
bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir);
if (!bus->procdir)
return -ENOMEM;
}
sprintf(name, "%02x", dev->number);
e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de,
dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, bus->procdir,
&isapnp_proc_bus_proc_ops, dev);
if (!e)
if (!dev->procent)
return -ENOMEM;
proc_set_size(e, 256);
proc_set_size(dev->procent, 256);
return 0;
}
......
......@@ -298,14 +298,12 @@ struct pnp_protocol pnpbios_protocol = {
static int __init insert_device(struct pnp_bios_node *node)
{
struct list_head *pos;
struct pnp_dev *dev;
char id[8];
int error;
/* check if the device is already added */
list_for_each(pos, &pnpbios_protocol.devices) {
dev = list_entry(pos, struct pnp_dev, protocol_list);
list_for_each_entry(dev, &pnpbios_protocol.devices, protocol_list) {
if (dev->number == node->handle)
return -EEXIST;
}
......
......@@ -540,7 +540,7 @@ struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
res->start = irq;
res->end = irq;
dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res);
dev_dbg(&dev->dev, "%pR\n", res);
return pnp_res;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment