OMAPDSS: VENC: fix NULL pointer dereference in DSS2 VENC sysfs debug attr on OMAP4
[zen-stable.git] / include / linux / mfd / pm8xxx / core.h
blobbd2f4f64e931db4fc109b73fbece9b64c9fe8fd5
1 /*
2 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 * Qualcomm PMIC 8xxx driver header file
18 #ifndef __MFD_PM8XXX_CORE_H
19 #define __MFD_PM8XXX_CORE_H
21 #include <linux/mfd/core.h>
23 struct pm8xxx_drvdata {
24 int (*pmic_readb) (const struct device *dev, u16 addr, u8 *val);
25 int (*pmic_writeb) (const struct device *dev, u16 addr, u8 val);
26 int (*pmic_read_buf) (const struct device *dev, u16 addr, u8 *buf,
27 int n);
28 int (*pmic_write_buf) (const struct device *dev, u16 addr, u8 *buf,
29 int n);
30 int (*pmic_read_irq_stat) (const struct device *dev, int irq);
31 void *pm_chip_data;
34 static inline int pm8xxx_readb(const struct device *dev, u16 addr, u8 *val)
36 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
38 if (!dd)
39 return -EINVAL;
40 return dd->pmic_readb(dev, addr, val);
43 static inline int pm8xxx_writeb(const struct device *dev, u16 addr, u8 val)
45 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
47 if (!dd)
48 return -EINVAL;
49 return dd->pmic_writeb(dev, addr, val);
52 static inline int pm8xxx_read_buf(const struct device *dev, u16 addr, u8 *buf,
53 int n)
55 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
57 if (!dd)
58 return -EINVAL;
59 return dd->pmic_read_buf(dev, addr, buf, n);
62 static inline int pm8xxx_write_buf(const struct device *dev, u16 addr, u8 *buf,
63 int n)
65 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
67 if (!dd)
68 return -EINVAL;
69 return dd->pmic_write_buf(dev, addr, buf, n);
72 static inline int pm8xxx_read_irq_stat(const struct device *dev, int irq)
74 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
76 if (!dd)
77 return -EINVAL;
78 return dd->pmic_read_irq_stat(dev, irq);
81 #endif