treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / x86 / platform / intel-mid / device_libs / platform_max7315.c
blobe9287c3184da45f7a42cb748d5b252f168828b6c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * platform_max7315.c: max7315 platform data initialization file
5 * (C) Copyright 2013 Intel Corporation
6 * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
7 */
9 #include <linux/init.h>
10 #include <linux/gpio.h>
11 #include <linux/i2c.h>
12 #include <linux/platform_data/pca953x.h>
13 #include <asm/intel-mid.h>
15 #define MAX7315_NUM 2
17 static void __init *max7315_platform_data(void *info)
19 static struct pca953x_platform_data max7315_pdata[MAX7315_NUM];
20 static int nr;
21 struct pca953x_platform_data *max7315 = &max7315_pdata[nr];
22 struct i2c_board_info *i2c_info = info;
23 int gpio_base, intr;
24 char base_pin_name[SFI_NAME_LEN + 1];
25 char intr_pin_name[SFI_NAME_LEN + 1];
27 if (nr == MAX7315_NUM) {
28 pr_err("too many max7315s, we only support %d\n",
29 MAX7315_NUM);
30 return NULL;
32 /* we have several max7315 on the board, we only need load several
33 * instances of the same pca953x driver to cover them
35 strcpy(i2c_info->type, "max7315");
36 if (nr++) {
37 snprintf(base_pin_name, sizeof(base_pin_name),
38 "max7315_%d_base", nr);
39 snprintf(intr_pin_name, sizeof(intr_pin_name),
40 "max7315_%d_int", nr);
41 } else {
42 strcpy(base_pin_name, "max7315_base");
43 strcpy(intr_pin_name, "max7315_int");
46 gpio_base = get_gpio_by_name(base_pin_name);
47 intr = get_gpio_by_name(intr_pin_name);
49 if (gpio_base < 0)
50 return NULL;
51 max7315->gpio_base = gpio_base;
52 if (intr != -1) {
53 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
54 max7315->irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
55 } else {
56 i2c_info->irq = -1;
57 max7315->irq_base = -1;
59 return max7315;
62 static const struct devs_id max7315_dev_id __initconst = {
63 .name = "i2c_max7315",
64 .type = SFI_DEV_TYPE_I2C,
65 .delay = 1,
66 .get_platform_data = &max7315_platform_data,
69 static const struct devs_id max7315_2_dev_id __initconst = {
70 .name = "i2c_max7315_2",
71 .type = SFI_DEV_TYPE_I2C,
72 .delay = 1,
73 .get_platform_data = &max7315_platform_data,
76 sfi_device(max7315_dev_id);
77 sfi_device(max7315_2_dev_id);