Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp54200lfv; Tue, 12 Apr 2022 17:02:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjTdeTMXqzheKtl9taSJ7zEGCUKOs8nM3JOdhiCsgYmZ2RZgexr2BTHuk2ztPlNO0etV04 X-Received: by 2002:a05:6a00:18a2:b0:505:ccae:42f7 with SMTP id x34-20020a056a0018a200b00505ccae42f7mr10691962pfh.28.1649808166100; Tue, 12 Apr 2022 17:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649808166; cv=none; d=google.com; s=arc-20160816; b=v36JuUQxhvNjKdTaLXGOVWB9FGLJjo/Ye4R/vI+x+EZ3qX/iGFVhTP92RbE6cpF4hf gxM1li94AD+63YRaKEJdI+3TrJsTUubo/8Fx8AVmZ9iEjLqD5SQ0rUiIQA3b2rU6A+Cy nZrWlqL7ZvSWOR1CoAn7z2ZhTRM0nEX16PIBY1242FxPxlUfDyWmK+fAoiCiiPm7lLug yTs+SXlgPIsBtkkAc7+wHgXkFhOrR7Gk8WAXMrq3qsBjaEHiBg2DJOOfKiSkpboEEI6a V9cowFXFP0SEOnCADlLC93egmpdewnDMXWwYA1YZlxEJXoN8Rt7xWLxGjW/cZQ3U8lJT GpiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EHG2IbCAiVOF3vEZ4P/yUZxJg6ubvPpIH2rRWthOYrg=; b=IJ+GVJ2ivzhAP+73qUSPVVVjulMtiMLmimuOri7lbC79HtvRQt50qBieYeM3MmozMf MRYYkXsA44Be5o4RbSI4kwzdvvbeOnEUPaL5aDgT8fxT2lBW4CaREbqalpyTYNRtei1Y Q4x/6R0tGL382uIjus6socq3BlkDo48qU/ISNEoVOzTMPjyZR2DUEyOTWYu78n97BGhS RvM+9U2DcHmMl/wQucAmX2iMDTeNO47pB6/OGQg9BEcoIdSvw3joE8dFuF6cTUcncyR+ 5yzFsGl4fA15EUy1WCZQtOVu/uvN96py9nxb/En6pwcbUhNK6RWUSiJR8T5ZcUIyhlSA bmEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=G92Gn1YJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k11-20020a63d10b000000b0039991aaaf5bsi3926055pgg.304.2022.04.12.17.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 17:02:46 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=G92Gn1YJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C511137B1E; Tue, 12 Apr 2022 14:58:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244755AbiDLKVF (ORCPT + 99 others); Tue, 12 Apr 2022 06:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359427AbiDLKTU (ORCPT ); Tue, 12 Apr 2022 06:19:20 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 303127CB29; Tue, 12 Apr 2022 02:16:35 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id p15so36033991ejc.7; Tue, 12 Apr 2022 02:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EHG2IbCAiVOF3vEZ4P/yUZxJg6ubvPpIH2rRWthOYrg=; b=G92Gn1YJZuxQyQgqMa+NS6Km5+yE1SrRMLyGFD3365N87vl2wEmsHL2KkEobxIy6J2 soQ40KENXoB2sJjJmZerSMF5oiRPd7j15Tw3JFo3dKken455nMA5sZKtvdPFxoLDhFX6 9CfRWFAqrg+X0hBsFl2y7lUiRj+gw9VGPYx51a9/96ks5WgrersDjJbZRab3tKrekG1+ IgyaO3hcAjfF0DyBLEEPPo1JrELJg3hFROlNxkoeBrucG+6IEP19L/O7NeameZo2foeB zvd9r1FcB/4zSxS2fi4qwOar8bUypCC3sGjU+Q6LixImmDwLVFOVfr3xSf15SQshYkMr VABA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EHG2IbCAiVOF3vEZ4P/yUZxJg6ubvPpIH2rRWthOYrg=; b=iamKGvYtyGZinPt5eKdmwafbA356gnq0uBF8ysjWPx3nX4tKuJvlYmGyuxTAgDN5S7 2Cw5pL0BJvUhiy2R6KD3Mdweta65Mpx/FAvafvgy0BOMZuug8k8Ur3ybwW3MgBrqX4Z9 YcfQ3qBifQ607LArI7eHNYK8Cm5P1nXt5zFAK3g7rqO4FeRin/cF6++GXNLwHdewMmWk B3vhSO4E/2OXyr6xB6t46wKnXjMf12SAoyud8zrlu8ctJedoFNMOi/XhATLCPO9Y55SJ kuiIN0AY8z7b00uaG6U/43Xv3GcS7TJidv934NfYb04BuUvphyBhezXQVvKBkpsn26Tx wDyw== X-Gm-Message-State: AOAM532Etsnd7jENw0qLJ1qriHaTQFy+EfdndBjV89qbWkGh9nlPYa2W +44UCVrF9LbjZ6k140gIEXdQj2q/wIHBS42LM9XJMIVwROo= X-Received: by 2002:a17:907:e8d:b0:6e0:19e7:9549 with SMTP id ho13-20020a1709070e8d00b006e019e79549mr33953776ejc.44.1649754994299; Tue, 12 Apr 2022 02:16:34 -0700 (PDT) MIME-Version: 1.0 References: <20220411203133.19929-1-jagathjog1996@gmail.com> <20220411203133.19929-5-jagathjog1996@gmail.com> In-Reply-To: <20220411203133.19929-5-jagathjog1996@gmail.com> From: Andy Shevchenko Date: Tue, 12 Apr 2022 12:12:21 +0300 Message-ID: Subject: Re: [PATCH v3 4/9] iio: accel: bma400: Add triggered buffer support To: Jagath Jog J Cc: Dan Robertson , Jonathan Cameron , linux-iio , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 11, 2022 at 11:31 PM Jagath Jog J wrote: > > Added trigger buffer support to read continuous acceleration > data from device with data ready interrupt which is mapped > to INT1 pin. Can you explain the locking schema in this driver? > + /* Configure INT1 pin to open drain */ > + ret = regmap_write(data->regmap, BMA400_INT_IO_CTRL_REG, 0x06); > + if (ret) > + return ret; No locking (or regmap only locking). ... > +static int bma400_data_rdy_trigger_set_state(struct iio_trigger *trig, > + bool state) > +{ > + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); > + struct bma400_data *data = iio_priv(indio_dev); > + int ret; > + > + ret = regmap_update_bits(data->regmap, BMA400_INT_CONFIG0_REG, > + BMA400_INT_DRDY_MSK, > + FIELD_PREP(BMA400_INT_DRDY_MSK, state)); > + if (ret) > + return ret; > + > + return regmap_update_bits(data->regmap, BMA400_INT1_MAP_REG, > + BMA400_INT_DRDY_MSK, > + FIELD_PREP(BMA400_INT_DRDY_MSK, state)); > +} Ditto. ... > + mutex_lock(&data->mutex); > + > + /* bulk read six registers, with the base being the LSB register */ > + ret = regmap_bulk_read(data->regmap, BMA400_X_AXIS_LSB_REG, > + &data->buffer.buff, sizeof(data->buffer.buff)); > + mutex_unlock(&data->mutex); > + if (ret) > + return IRQ_NONE; But here only above with locking... > + ret = regmap_read(data->regmap, BMA400_TEMP_DATA_REG, &temp); > + if (ret) > + return IRQ_NONE; ...followed by no locking. ... > + mutex_lock(&data->mutex); > + ret = regmap_bulk_read(data->regmap, BMA400_INT_STAT0_REG, &status, > + sizeof(status)); > + mutex_unlock(&data->mutex); > + if (ret) > + return IRQ_NONE; And again with locking. ... So, 1) Does regmap is configured with locking? What for? 2) What's the role of data->mutex? -- With Best Regards, Andy Shevchenko