Loading drivers/misc/qpnp-misc.c +41 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,47 @@ static bool __misc_irqs_available(struct qpnp_misc_dev *dev) return 1; } int qpnp_misc_read_reg(struct device_node *node, u16 addr, u8 *val) { struct qpnp_misc_dev *mdev = NULL; struct qpnp_misc_dev *mdev_found = NULL; int rc; u8 temp; if (IS_ERR_OR_NULL(node)) { pr_err("Invalid device node pointer\n"); return -EINVAL; } mutex_lock(&qpnp_misc_dev_list_mutex); list_for_each_entry(mdev, &qpnp_misc_dev_list, list) { if (mdev->dev->of_node == node) { mdev_found = mdev; break; } } mutex_unlock(&qpnp_misc_dev_list_mutex); if (!mdev_found) { /* * No MISC device was found. This API should only * be called by drivers which have specified the * misc phandle in their device tree node. */ pr_err("no probed misc device found\n"); return -EPROBE_DEFER; } rc = qpnp_read_byte(mdev->spmi, addr, &temp); if (rc < 0) { dev_err(mdev->dev, "Failed to read addr %x, rc=%d\n", addr, rc); return rc; } *val = temp; return 0; } int qpnp_misc_irqs_available(struct device *consumer_dev) { struct device_node *misc_node = NULL; Loading include/linux/qpnp-misc.h +20 −2 Original line number Diff line number Diff line /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2014, 2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -29,8 +29,26 @@ */ int qpnp_misc_irqs_available(struct device *consumer_dev); /** * qpnp_misc_read_reg - read register from misc device * * @node: device node pointer * @address: address offset in misc peripheral to be read * @val: data read from register * * This function returns zero if reading the MISC register succeeds. * */ int qpnp_misc_read_reg(struct device_node *node, u16 addr, u8 *val); #else static int qpnp_misc_irqs_available(struct device *consumer_dev) static inline int qpnp_misc_irqs_available(struct device *consumer_dev) { return 0; } static inline int qpnp_misc_read_reg(struct device_node *node, u16 addr, u8 *val) { return 0; } Loading Loading
drivers/misc/qpnp-misc.c +41 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,47 @@ static bool __misc_irqs_available(struct qpnp_misc_dev *dev) return 1; } int qpnp_misc_read_reg(struct device_node *node, u16 addr, u8 *val) { struct qpnp_misc_dev *mdev = NULL; struct qpnp_misc_dev *mdev_found = NULL; int rc; u8 temp; if (IS_ERR_OR_NULL(node)) { pr_err("Invalid device node pointer\n"); return -EINVAL; } mutex_lock(&qpnp_misc_dev_list_mutex); list_for_each_entry(mdev, &qpnp_misc_dev_list, list) { if (mdev->dev->of_node == node) { mdev_found = mdev; break; } } mutex_unlock(&qpnp_misc_dev_list_mutex); if (!mdev_found) { /* * No MISC device was found. This API should only * be called by drivers which have specified the * misc phandle in their device tree node. */ pr_err("no probed misc device found\n"); return -EPROBE_DEFER; } rc = qpnp_read_byte(mdev->spmi, addr, &temp); if (rc < 0) { dev_err(mdev->dev, "Failed to read addr %x, rc=%d\n", addr, rc); return rc; } *val = temp; return 0; } int qpnp_misc_irqs_available(struct device *consumer_dev) { struct device_node *misc_node = NULL; Loading
include/linux/qpnp-misc.h +20 −2 Original line number Diff line number Diff line /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2014, 2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -29,8 +29,26 @@ */ int qpnp_misc_irqs_available(struct device *consumer_dev); /** * qpnp_misc_read_reg - read register from misc device * * @node: device node pointer * @address: address offset in misc peripheral to be read * @val: data read from register * * This function returns zero if reading the MISC register succeeds. * */ int qpnp_misc_read_reg(struct device_node *node, u16 addr, u8 *val); #else static int qpnp_misc_irqs_available(struct device *consumer_dev) static inline int qpnp_misc_irqs_available(struct device *consumer_dev) { return 0; } static inline int qpnp_misc_read_reg(struct device_node *node, u16 addr, u8 *val) { return 0; } Loading