Skip to content

Commit

Permalink
PM / OPP / clk: Remove unnecessary OOM message
Browse files Browse the repository at this point in the history
This patch reduces the kernel size by removing error messages that duplicate
the normal OOM message.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr)

@@
identifier f,print,l;
expression e;
constant char[] c;
@@

e = \(kzalloc\|kmalloc\|devm_kzalloc\|devm_kmalloc\)(...);
if (e == NULL) {
  <+...
-  print(...,c,...);
  ... when any
(
  goto l;
|
  return ...;
)
  ...+> }

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Quentin Lambert authored and Rafael J. Wysocki committed Feb 12, 2015
1 parent 04bf1c7 commit 59d84ca
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
1 change: 0 additions & 1 deletion drivers/base/firmware_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,6 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,

fw_priv = kzalloc(sizeof(*fw_priv), GFP_KERNEL);
if (!fw_priv) {
dev_err(device, "%s: kmalloc failed\n", __func__);
fw_priv = ERR_PTR(-ENOMEM);
goto exit;
}
Expand Down
4 changes: 1 addition & 3 deletions drivers/base/power/clock_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ static int __pm_clk_add(struct device *dev, const char *con_id,
return -EINVAL;

ce = kzalloc(sizeof(*ce), GFP_KERNEL);
if (!ce) {
dev_err(dev, "Not enough memory for clock entry.\n");
if (!ce)
return -ENOMEM;
}

if (con_id) {
ce->con_id = kstrdup(con_id, GFP_KERNEL);
Expand Down
8 changes: 2 additions & 6 deletions drivers/base/power/opp.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,8 @@ static int _opp_add_dynamic(struct device *dev, unsigned long freq,

/* allocate new OPP node */
new_opp = kzalloc(sizeof(*new_opp), GFP_KERNEL);
if (!new_opp) {
dev_warn(dev, "%s: Unable to create new OPP node\n", __func__);
if (!new_opp)
return -ENOMEM;
}

/* Hold our list modification lock here */
mutex_lock(&dev_opp_list_lock);
Expand Down Expand Up @@ -695,10 +693,8 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,

/* keep the node allocated */
new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL);
if (!new_opp) {
dev_warn(dev, "%s: Unable to create OPP\n", __func__);
if (!new_opp)
return -ENOMEM;
}

mutex_lock(&dev_opp_list_lock);

Expand Down

0 comments on commit 59d84ca

Please sign in to comment.