Commit cea234e9 authored by Markus Elfring's avatar Markus Elfring Committed by Linus Walleij

pinctrl: Adjust nine checks for null pointers

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 390e1046
...@@ -170,7 +170,7 @@ const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin) ...@@ -170,7 +170,7 @@ const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin)
const struct pin_desc *desc; const struct pin_desc *desc;
desc = pin_desc_get(pctldev, pin); desc = pin_desc_get(pctldev, pin);
if (desc == NULL) { if (!desc) {
dev_err(pctldev->dev, "failed to get pin(%d) name\n", dev_err(pctldev->dev, "failed to get pin(%d) name\n",
pin); pin);
return NULL; return NULL;
...@@ -214,7 +214,7 @@ static void pinctrl_free_pindescs(struct pinctrl_dev *pctldev, ...@@ -214,7 +214,7 @@ static void pinctrl_free_pindescs(struct pinctrl_dev *pctldev,
pindesc = radix_tree_lookup(&pctldev->pin_desc_tree, pindesc = radix_tree_lookup(&pctldev->pin_desc_tree,
pins[i].number); pins[i].number);
if (pindesc != NULL) { if (pindesc) {
radix_tree_delete(&pctldev->pin_desc_tree, radix_tree_delete(&pctldev->pin_desc_tree,
pins[i].number); pins[i].number);
if (pindesc->dynamic_name) if (pindesc->dynamic_name)
...@@ -230,7 +230,7 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev, ...@@ -230,7 +230,7 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
struct pin_desc *pindesc; struct pin_desc *pindesc;
pindesc = pin_desc_get(pctldev, pin->number); pindesc = pin_desc_get(pctldev, pin->number);
if (pindesc != NULL) { if (pindesc) {
dev_err(pctldev->dev, "pin %d already registered\n", dev_err(pctldev->dev, "pin %d already registered\n",
pin->number); pin->number);
return -EINVAL; return -EINVAL;
...@@ -248,7 +248,7 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev, ...@@ -248,7 +248,7 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
pindesc->name = pin->name; pindesc->name = pin->name;
} else { } else {
pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", pin->number); pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", pin->number);
if (pindesc->name == NULL) { if (!pindesc->name) {
kfree(pindesc); kfree(pindesc);
return -ENOMEM; return -ENOMEM;
} }
...@@ -402,7 +402,7 @@ static int pinctrl_get_device_gpio_range(unsigned gpio, ...@@ -402,7 +402,7 @@ static int pinctrl_get_device_gpio_range(unsigned gpio,
struct pinctrl_gpio_range *range; struct pinctrl_gpio_range *range;
range = pinctrl_match_gpio_range(pctldev, gpio); range = pinctrl_match_gpio_range(pctldev, gpio);
if (range != NULL) { if (range) {
*outdev = pctldev; *outdev = pctldev;
*outrange = range; *outrange = range;
mutex_unlock(&pinctrldev_list_mutex); mutex_unlock(&pinctrldev_list_mutex);
...@@ -947,7 +947,7 @@ static int add_setting(struct pinctrl *p, struct pinctrl_dev *pctldev, ...@@ -947,7 +947,7 @@ static int add_setting(struct pinctrl *p, struct pinctrl_dev *pctldev,
else else
setting->pctldev = setting->pctldev =
get_pinctrl_dev_from_devname(map->ctrl_dev_name); get_pinctrl_dev_from_devname(map->ctrl_dev_name);
if (setting->pctldev == NULL) { if (!setting->pctldev) {
kfree(setting); kfree(setting);
/* Do not defer probing of hogs (circular loop) */ /* Do not defer probing of hogs (circular loop) */
if (!strcmp(map->ctrl_dev_name, map->dev_name)) if (!strcmp(map->ctrl_dev_name, map->dev_name))
...@@ -1094,7 +1094,7 @@ struct pinctrl *pinctrl_get(struct device *dev) ...@@ -1094,7 +1094,7 @@ struct pinctrl *pinctrl_get(struct device *dev)
* return another pointer to it. * return another pointer to it.
*/ */
p = find_pinctrl(dev); p = find_pinctrl(dev);
if (p != NULL) { if (p) {
dev_dbg(dev, "obtain a copy of previously claimed pinctrl\n"); dev_dbg(dev, "obtain a copy of previously claimed pinctrl\n");
kref_get(&p->users); kref_get(&p->users);
return p; return p;
...@@ -1565,7 +1565,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) ...@@ -1565,7 +1565,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
pin = pctldev->desc->pins[i].number; pin = pctldev->desc->pins[i].number;
desc = pin_desc_get(pctldev, pin); desc = pin_desc_get(pctldev, pin);
/* Pin space may be sparse */ /* Pin space may be sparse */
if (desc == NULL) if (!desc)
continue; continue;
seq_printf(s, "pin %d (%s) ", pin, desc->name); seq_printf(s, "pin %d (%s) ", pin, desc->name);
...@@ -2145,7 +2145,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev) ...@@ -2145,7 +2145,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
{ {
struct pinctrl_gpio_range *range, *n; struct pinctrl_gpio_range *range, *n;
if (pctldev == NULL) if (!pctldev)
return; return;
mutex_lock(&pctldev->mutex); mutex_lock(&pctldev->mutex);
......
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