Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp597320ybh; Wed, 22 Jul 2020 08:26:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPi4BbpRPXGw2e2FmIL993OXe9hYIZ4yAOfAhdsEfiRGYPcrR0WgaE0CYfpFFQMg8f6EBG X-Received: by 2002:a17:906:6959:: with SMTP id c25mr26987ejs.375.1595431581620; Wed, 22 Jul 2020 08:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595431581; cv=none; d=google.com; s=arc-20160816; b=WkV37TEHqZ0YO7Mtq3RXcjPMu1EiXgFNf2ytTUl4hp8f53Xl/v17pMto5Kx1p281jt iV1mMNOzzHtyd1y999+8T3dp63Tgi38RQjgLMiwjEq0QnlN5omIJ+rpymp5ltowWysl4 hyU3etuK4ndIN8xEf6roub4cUj9YIeAM679bME4iWDyp/OyVi6PE0IFf51tq6nnU1w4O Tl8DIh1QXgMuU70yKwQL7pqnhrcCpGNKeaQ92JohkVtIQEoJQcVHOf21UI8KPnqeIdQv QAiWXfQhf0KbNvkP+oyixU49KHiDOjqCXhW4vWS+rG6vSTCTFgqVN29MpyrDKVGuZFoX OJrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:dkim-signature; bh=szq1EIALXI1InaxXczbdpSUPUkPqU/Qn6lzK/O+OxWc=; b=Jxuldij3kVp7axiy6jkPTrUWHsSnHQEBkbB4dFMxlEnd7bAarM/o32GPy/C1fdqybI Hu5J7nVZDZ6cIbQkvwE85nsnSb4OLH2C8dC+X7nWoqB5ZkogG2aacbOVQu/doDOFMBt+ OS5mZsAmuLr5IG5zLv6RKDieUG/hrTi+jib08rmUtqn8MUSmPUuyisEg42yGWe4SljXh X2V9z4t5KyfLBvgwU474TR6RW9C0RlsuGAuD9yJQGBsD46+kc5AJaxm9pfMaiJc+oLxw xWW36Lt7QL2gLWgeSfwnmRnL7Pb+c24Qf12cGbXf6lYVm65znlf2fg/wbeskrr7LmEUa ukuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CAEQLD0O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si174011eju.554.2020.07.22.08.25.58; Wed, 22 Jul 2020 08:26:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CAEQLD0O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732705AbgGVPXu (ORCPT + 99 others); Wed, 22 Jul 2020 11:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728812AbgGVPXt (ORCPT ); Wed, 22 Jul 2020 11:23:49 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A1D7C0619DC; Wed, 22 Jul 2020 08:23:49 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id e7so2111096qti.1; Wed, 22 Jul 2020 08:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=szq1EIALXI1InaxXczbdpSUPUkPqU/Qn6lzK/O+OxWc=; b=CAEQLD0OIy3i76OKUVUS9iV+HfgTRqQh4zszhLDC4LN7XC5ZyA0o6CufBfhJxn4HO8 rH2qq5xY5Ex9GAc6mWgK1ej2k75dsWoGhYOwOvcT1chpP4OzZQ1/xAfEje5rEuEcgXXr l4Q8QC6jP3o3uok4YZMv4sNc4v9bZzljJaj47Xi1leBMAiZwN8hUV37/luAgXoQbdgMX GC7TS4nwFR79LtFHFQ2rcpFXYuBF8CWcYw3ZBrK7J5JWmfzpA0eGwaS00W/Es/iHZ8YF lqi8H3YxWX7fTaZxvuFLKRwzi9sXVvNFt+YRzZio29P+RxmqIqbSKN3vnf07XH0X3bvu DcPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=szq1EIALXI1InaxXczbdpSUPUkPqU/Qn6lzK/O+OxWc=; b=VG2Y4Kqz/2RMKYYEpt/e2hH11p4o0iAr6tlm/iPC0G8+Xmo8q388cTtYjjY7oVoe6P EX4IexiNuCm+sM0NLhmQA5WrVNT0sbPiS7piKEil0H7smRyRJ+MshYfDZgnU+/KBsmJX o13hQB2GBpFIB14MyaTbjZfCRoZjs/9B36Ly1oay/ojWIaHMRu+OM0V0FC2lkMApwDR4 acOK98AnB56zrGC4gKhdhLbWDcyFwgH5ryqeRbdWkguOTo+xCyshGs7eDUpEmrX7aRjg wCy2MIqBDkYRmdcMxl+N0lJsObBpIuPRbK+UdrCNeZsCNLgLxEJmiIzxpSdMrngrgUPB 4oMg== X-Gm-Message-State: AOAM5300//bfKV6AS5anhT68IxglKuP+UpWrFK3HgW0IFWWL4mjEHuAb BO4NK9HbKYDDtZ+Vkm/I5TI= X-Received: by 2002:ac8:41c6:: with SMTP id o6mr33903563qtm.292.1595431428291; Wed, 22 Jul 2020 08:23:48 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:11e1::10da? ([2620:10d:c091:480::1:4a2]) by smtp.gmail.com with ESMTPSA id d8sm6953qtr.12.2020.07.22.08.23.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 08:23:46 -0700 (PDT) From: Jes Sorensen X-Google-Original-From: Jes Sorensen Subject: Re: [PATCH v16 3/3] Input: new da7280 haptic driver To: Roy Im , Uwe Kleine-Koenig , Bartosz Golaszewski , Brian Masney , Dmitry Torokhov , Greg KH , Lee Jones , Luca Weiss , Maximilian Luz , Pascal PAILLET-LME , Rob Herring , Samuel Ortiz , Thierry Reding , Thomas Gleixner Cc: Support Opensource , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org References: Message-ID: Date: Wed, 22 Jul 2020 11:23:45 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/9/20 3:27 AM, Roy Im wrote: > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with > multiple mode and integrated waveform memory and wideband support. > It communicates via an I2C bus to the device. > > Signed-off-by: Roy Im > --- > v16: > - Corrected some code and updated description in Kconfig. > v15: > - Removed some defines and updated some comments. > v14: > - Updated pwm related code, alignments and comments. > v13: > - Updated some conditions in pwm function and alignments. > v12: No changes. > v11: > - Updated the pwm related code, comments and typo. > v10: > - Updated the pwm related function and added some comments. > v9: > - Removed the header file and put the definitions into the c file. > - Updated the pwm code and error logs with %pE > v8: > - Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT. > - Updated the dt-related code. > - Removed memless related functions. > v7: > - Added more attributes to handle one value per file. > - Replaced and updated the dt-related code and functions called. > - Fixed error/functions. > v6: No changes. > v5: Fixed errors in Kconfig file. > v4: Updated code as dt-bindings are changed. > v3: No changes. > v2: Fixed kbuild error/warning > > > drivers/input/misc/Kconfig | 13 + > drivers/input/misc/Makefile | 1 + > drivers/input/misc/da7280.c | 1840 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 1854 insertions(+) > create mode 100644 drivers/input/misc/da7280.c Hi Roy, Overall the driver looks pretty good now. I did find one issue, see below. If you fix that I am happy to add a Reviewed-by line. Reviewed-By: Jes Sorensen > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c > new file mode 100644 > index 0000000..c8c42ac > --- /dev/null > +++ b/drivers/input/misc/da7280.c [snip] > +static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool enabled) > +{ > + struct pwm_state state; > + u64 period_mag_multi; > + int error; > + > + if (!haptics->gain && enabled) { > + dev_err(haptics->dev, > + "Please set the gain first for the pwm mode\n"); > + return -EINVAL; > + } > + > + pwm_get_state(haptics->pwm_dev, &state); > + state.enabled = enabled; > + if (enabled) { > + period_mag_multi = state.period * haptics->gain; You are multiplying an unsigned int to a u16 and storing it in a u64. However, C doesn't promote the types, so you'll end up with an unexpected result here. You can fix it by promoting state.period to u64, ie: period_mage_multi = (u64)state.period * haptics->gain; See the following example code which demonstrates the problem. #include #include uint64_t foo(unsigned int a, uint16_t b) { uint64_t tmp = a * b; return tmp; } uint64_t bar(unsigned int a, uint16_t b) { uint64_t tmp = (uint64_t)a * b; return tmp; } int main() { uint64_t val; unsigned int a = 0xff00ff00; uint16_t b = 0x200; val = foo(a, b); printf("result(%0x, %0x) = %0llx\n", a, b, val); val = bar(a, b); printf("result(%0x, %0x) = %0llx\n", a, b, val); } Cheers, Jes