Commit 4202151f authored by Markus Elfring's avatar Markus Elfring Committed by Lee Jones

mfd: sm501: Adjust 12 checks for null pointers

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 avatarLee Jones <lee.jones@linaro.org>
parent 3eec4fad
...@@ -1050,13 +1050,13 @@ static int sm501_register_gpio(struct sm501_devdata *sm) ...@@ -1050,13 +1050,13 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
spin_lock_init(&gpio->lock); spin_lock_init(&gpio->lock);
gpio->regs_res = request_mem_region(iobase, 0x20, "sm501-gpio"); gpio->regs_res = request_mem_region(iobase, 0x20, "sm501-gpio");
if (gpio->regs_res == NULL) { if (!gpio->regs_res) {
dev_err(sm->dev, "gpio: failed to request region\n"); dev_err(sm->dev, "gpio: failed to request region\n");
return -ENXIO; return -ENXIO;
} }
gpio->regs = ioremap(iobase, 0x20); gpio->regs = ioremap(iobase, 0x20);
if (gpio->regs == NULL) { if (!gpio->regs) {
dev_err(sm->dev, "gpio: failed to remap registers\n"); dev_err(sm->dev, "gpio: failed to remap registers\n");
ret = -ENXIO; ret = -ENXIO;
goto err_claimed; goto err_claimed;
...@@ -1358,7 +1358,7 @@ static int sm501_init_dev(struct sm501_devdata *sm) ...@@ -1358,7 +1358,7 @@ static int sm501_init_dev(struct sm501_devdata *sm)
sm501_register_gpio(sm); sm501_register_gpio(sm);
} }
if (pdata && pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) { if (pdata && pdata->gpio_i2c && pdata->gpio_i2c_nr > 0) {
if (!sm501_gpio_isregistered(sm)) if (!sm501_gpio_isregistered(sm))
dev_err(sm->dev, "no gpio available for i2c gpio.\n"); dev_err(sm->dev, "no gpio available for i2c gpio.\n");
else else
...@@ -1384,7 +1384,7 @@ static int sm501_plat_probe(struct platform_device *dev) ...@@ -1384,7 +1384,7 @@ static int sm501_plat_probe(struct platform_device *dev)
int ret; int ret;
sm = kzalloc(sizeof(*sm), GFP_KERNEL); sm = kzalloc(sizeof(*sm), GFP_KERNEL);
if (sm == NULL) { if (!sm) {
ret = -ENOMEM; ret = -ENOMEM;
goto err1; goto err1;
} }
...@@ -1402,8 +1402,7 @@ static int sm501_plat_probe(struct platform_device *dev) ...@@ -1402,8 +1402,7 @@ static int sm501_plat_probe(struct platform_device *dev)
sm->io_res = platform_get_resource(dev, IORESOURCE_MEM, 1); sm->io_res = platform_get_resource(dev, IORESOURCE_MEM, 1);
sm->mem_res = platform_get_resource(dev, IORESOURCE_MEM, 0); sm->mem_res = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!sm->io_res || !sm->mem_res) {
if (sm->io_res == NULL || sm->mem_res == NULL) {
dev_err(&dev->dev, "failed to get IO resource\n"); dev_err(&dev->dev, "failed to get IO resource\n");
ret = -ENOENT; ret = -ENOENT;
goto err_res; goto err_res;
...@@ -1411,8 +1410,7 @@ static int sm501_plat_probe(struct platform_device *dev) ...@@ -1411,8 +1410,7 @@ static int sm501_plat_probe(struct platform_device *dev)
sm->regs_claim = request_mem_region(sm->io_res->start, sm->regs_claim = request_mem_region(sm->io_res->start,
0x100, "sm501"); 0x100, "sm501");
if (!sm->regs_claim) {
if (sm->regs_claim == NULL) {
dev_err(&dev->dev, "cannot claim registers\n"); dev_err(&dev->dev, "cannot claim registers\n");
ret = -EBUSY; ret = -EBUSY;
goto err_res; goto err_res;
...@@ -1421,8 +1419,7 @@ static int sm501_plat_probe(struct platform_device *dev) ...@@ -1421,8 +1419,7 @@ static int sm501_plat_probe(struct platform_device *dev)
platform_set_drvdata(dev, sm); platform_set_drvdata(dev, sm);
sm->regs = ioremap(sm->io_res->start, resource_size(sm->io_res)); sm->regs = ioremap(sm->io_res->start, resource_size(sm->io_res));
if (!sm->regs) {
if (sm->regs == NULL) {
dev_err(&dev->dev, "cannot remap registers\n"); dev_err(&dev->dev, "cannot remap registers\n");
ret = -EIO; ret = -EIO;
goto err_claim; goto err_claim;
...@@ -1448,7 +1445,7 @@ static void sm501_set_power(struct sm501_devdata *sm, int on) ...@@ -1448,7 +1445,7 @@ static void sm501_set_power(struct sm501_devdata *sm, int on)
{ {
struct sm501_platdata *pd = sm->platdata; struct sm501_platdata *pd = sm->platdata;
if (pd == NULL) if (!pd)
return; return;
if (pd->get_power) { if (pd->get_power) {
...@@ -1573,7 +1570,7 @@ static int sm501_pci_probe(struct pci_dev *dev, ...@@ -1573,7 +1570,7 @@ static int sm501_pci_probe(struct pci_dev *dev,
int err; int err;
sm = kzalloc(sizeof(*sm), GFP_KERNEL); sm = kzalloc(sizeof(*sm), GFP_KERNEL);
if (sm == NULL) { if (!sm) {
err = -ENOMEM; err = -ENOMEM;
goto err1; goto err1;
} }
...@@ -1624,15 +1621,14 @@ static int sm501_pci_probe(struct pci_dev *dev, ...@@ -1624,15 +1621,14 @@ static int sm501_pci_probe(struct pci_dev *dev,
sm->regs_claim = request_mem_region(sm->io_res->start, sm->regs_claim = request_mem_region(sm->io_res->start,
0x100, "sm501"); 0x100, "sm501");
if (sm->regs_claim == NULL) { if (!sm->regs_claim) {
dev_err(&dev->dev, "cannot claim registers\n"); dev_err(&dev->dev, "cannot claim registers\n");
err= -EBUSY; err= -EBUSY;
goto err3; goto err3;
} }
sm->regs = pci_ioremap_bar(dev, 1); sm->regs = pci_ioremap_bar(dev, 1);
if (!sm->regs) {
if (sm->regs == NULL) {
dev_err(&dev->dev, "cannot remap registers\n"); dev_err(&dev->dev, "cannot remap registers\n");
err = -EIO; err = -EIO;
goto err4; goto err4;
......
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