Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f7869e6 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "input: misc: qti-haptics: check NULL pointer before using it"

parents 0895a655 0743490a
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -49,13 +49,6 @@ Properties:
		0 to 3596. If this is not specified, then 1800 mV will be
		used by default.

- qcom,ilim-ma
  Usage:      optional
  Value type: <u32>
  Definition: Specifies the maximum allowed output current in mA for the
		actuator. Allowed values: 400 or 800. If this is not
		specified, 400 mA will be used by default.

- qcom,play-rate-us
  Usage:      optional
  Value type: <u32>
@@ -188,7 +181,6 @@ Example:
	interrupt-names = "hap-sc-irq", "hap-play-irq";
	qcom,actuator-type = "lra";
	qcom,vmax-mv = <1800>;
	qcom,ilim-ma = <400>;
	qcom,play-rate-us = <8000>;
	qcom,lra-resonance-sig-shape = "sine";
	qcom,lra-auto-resonance-mode = "qwd";
+8 −11
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/debugfs.h>
@@ -57,8 +57,6 @@ enum haptics_custom_effect_param {
#define HAP_WAVEFORM_BUFFER_MAX		8
#define HAP_VMAX_MV_DEFAULT		1800
#define HAP_VMAX_MV_MAX			3596
#define HAP_ILIM_MA_DEFAULT		400
#define HAP_ILIM_MA_MAX			800
#define HAP_PLAY_RATE_US_DEFAULT	5715
#define HAP_PLAY_RATE_US_MAX		20475
#define HAP_PLAY_RATE_US_LSB		5
@@ -130,6 +128,8 @@ enum haptics_custom_effect_param {
#define HAP_VMAX_MV_LSB			116

#define REG_HAP_ILIM_CFG		0x52
#define HAP_ILIM_SEL_1000MA		BIT(1)
#define HAP_ILIM_DEFAULT_SEL		HAP_ILIM_SEL_1000MA
#define REG_HAP_SC_DEB_CFG		0x53
#define REG_HAP_RATE_CFG1		0x54
#define REG_HAP_RATE_CFG2		0x55
@@ -195,7 +195,6 @@ struct qti_hap_config {
	enum lra_auto_res_mode	lra_auto_res_mode;
	enum wf_src		ext_src;
	u16			vmax_mv;
	u16			ilim_ma;
	u16			play_rate_us;
	bool			lra_allow_variable_play_rate;
	bool			use_ext_wf_src;
@@ -731,6 +730,10 @@ static irqreturn_t qti_haptics_play_irq_handler(int irq, void *data)
	int rc;

	dev_dbg(chip->dev, "play_irq triggered\n");

	if (effect == NULL)
		goto handled;

	if (play->playing_pos == effect->pattern_length) {
		dev_dbg(chip->dev, "waveform playing done\n");
		if (chip->play_irq_en) {
@@ -1046,7 +1049,7 @@ static int qti_haptics_hw_init(struct qti_hap_chip *chip)

	/* Config ilim_ma */
	addr = REG_HAP_ILIM_CFG;
	val = config->ilim_ma == 400 ? 0 : 1;
	val = HAP_ILIM_DEFAULT_SEL;
	rc = qti_haptics_write(chip, addr, &val, 1);
	if (rc < 0) {
		dev_err(chip->dev, "write ilim_ma failed, rc=%d\n", rc);
@@ -1413,12 +1416,6 @@ static int qti_haptics_parse_dt(struct qti_hap_chip *chip)
		config->vmax_mv = (tmp > HAP_VMAX_MV_MAX) ?
			HAP_VMAX_MV_MAX : tmp;

	config->ilim_ma = HAP_ILIM_MA_DEFAULT;
	rc = of_property_read_u32(node, "qcom,ilim-ma", &tmp);
	if (!rc)
		config->ilim_ma = (tmp >= HAP_ILIM_MA_MAX) ?
			HAP_ILIM_MA_MAX : HAP_ILIM_MA_DEFAULT;

	config->play_rate_us = HAP_PLAY_RATE_US_DEFAULT;
	rc = of_property_read_u32(node, "qcom,play-rate-us", &tmp);
	if (!rc)