* <gbean@codeaurora.org>
*/
-#include <asm/gpio.h>
#include <dm.h>
#include <dm/device-internal.h>
#include <dm/device.h>
#include <log.h>
#include <power/regulator.h>
#include <regmap.h>
+#include <linux/bug.h>
+#include <asm/gpio.h>
#define err(format, arg...) printf("ERR:" format "\n", ##arg)
#define dbg(format, arg...) printf("DBG:" format "\n", ##arg)
{
int ret, n;
const int width = sx150x_reg_width(pctl, reg);
- unsigned int idx, val;
+ unsigned int val, idx;
/*
* There are four potential cases covered by this function:
* reg 3 [ 3 3 2 2 1 1 0 0 ]
*/
- for (n = width, val = 0, idx = reg; n > 0; n -= 8, idx) {
+ for (n = width, val = 0; n > 0; n -= 8) {
val <<= 8;
+ idx = reg;
ret = dm_i2c_reg_read(pctl->i2c, idx);
if (ret < 0)
if (ret < 0)
return ret;
- reg;
n -= 8;
} while (n >= 0);
{},
};
-static const struct pinconf_param sx150x_conf_params[] = {
+static const struct pinconf_param __maybe_unused sx150x_conf_params[] = {
{ "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
{ "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },
{ "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN, 1 },
return pin_name;
}
-static int sx150x_pinctrl_conf_set(struct udevice *dev, unsigned int pin,
+static int __maybe_unused sx150x_pinctrl_conf_set(struct udevice *dev, unsigned int pin,
unsigned int param, unsigned int arg)
{
int ret;
static int sx150x_pinctrl_bind(struct udevice *dev)
{
struct sx150x_pinctrl_priv *pctl = dev_get_plat(dev);
- int ret, reg;
+ int ret;
if (!dev_read_bool(dev, "gpio-controller"))
return 0;
- reg = (int)dev_read_addr_ptr(dev);
-
ret = device_bind(dev, &sx150x_gpio_driver, dev_read_name(dev), NULL,
dev_ofnode(dev), &pctl->gpio);
if (ret)
pctl->data = drv_data;
- reg = (int)dev_read_addr_ptr(dev);
+ reg = dev_read_u32_default(dev, "reg", -ENODEV);
+ if (reg < 0)
+ return -ENODEV;
+
ret = dm_i2c_probe(dev->parent, reg, 0, &pctl->i2c);
if (ret) {
err("Cannot find I2C chip %02x (%d)", reg, ret);