From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C73F2C433EF for ; Sun, 19 Jun 2022 11:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MGiVnAF0RF7anQVc0eei/v7c3yiRNYHl7h9yiXGWFCo=; b=nR3Duz08a7bEF4 jdsa7iwpEE68Y8i0CEftLKrD34BdYSG3qnoyOlxX/AFTQFfrd64EH1oskfowl/oX+L5dsbLLxsMUZ qvRGSu/c/je5t4M7iycgvKO7MLJ61a2bamZkLHKMSkUTed/CIsWoYjlpeFSBzFtxiNne1ZvSi09Ot S5Be+xaQdIidokxDueaicwZFmWNDcgXIqh9qrc/gL1aXemJuN3MV0IXuxUK/0PUXXYlQahB1PX/HZ OzAdnbA1x+j/09VnyHLVDOAc/cNcL04cSsmAAYX6jLI8DK36zAQYfMDenA2X/Y/COW7xf04hyld8a LT3zDulWv//pdUY+A07g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2tM8-00E2kt-Vj; Sun, 19 Jun 2022 11:44:41 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2tM5-00E2j1-RS for linux-arm-kernel@lists.infradead.org; Sun, 19 Jun 2022 11:44:39 +0000 Received: by mail-ej1-x630.google.com with SMTP id y19so16245934ejq.6 for ; Sun, 19 Jun 2022 04:44:36 -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=FQbBjcBfD7V1TcniNo3XYd/5J9V350QbGnDoj858ycY=; b=Xb2iTmdVGW+PvMqYxyub4QxQHV0TQ3b1izCzfoW+XluTzOwzcJfFWuSbZRoAA8lbzD v8FNJy0aJolsQjoY545X+w1K24MJJ5xZ1YJcMRSE57UH+wPFznA2G+6mpi7DS/3FlPRd FFalUTcBi633WGar9Efv/B9+GqSU1Y7hiwCWUOppYIlzQ0q+41xmysIiOxkknSiCpHUS TcZ86uKkqZAwlnnwnxfOIm9jG85icOGl9SiA0lwCsTpyP/KlLoaHvhupschG9uoJflWM f2DM8vuegImSXr+iCVartWQDiucYQCQDLz9opYJK4TWDIvyu7T9lB9/C+vOtLHmw2NT0 PWYg== 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=FQbBjcBfD7V1TcniNo3XYd/5J9V350QbGnDoj858ycY=; b=q7BbPy39JcnPO3SQt7OyURszAUjEc4Zkb0SWXPQmalqzIhOuFuJIrAL2DuflLHcEJ5 F0+pAGm9WGvQocHFFvlMEZcXma7/ZskMaf86aFqiPwggUx/yY31zSWwSZyrv+dtydbIy su4hpwYNvOucClpUhzKruAsqtXHM2MAZCUyvcw9DYIozscuypPms4AHBcpP6AZVd1OvK i6+uLsQaxJBygwKjAslJFY3292pa/O0iBFslQmsTUBBxvXuuMB1yPCxPZNvkb3sGLU9U VVLWXppJV+HIOzmwdQvbENjTHSwVeP3Uj4FDu03zwvjTzEtQfOQwaX0v6NvcIv+Kc++o T7LQ== X-Gm-Message-State: AJIora8XNdWO5N/ZvycuDhFStU8+ykMdYp/mLz6lyyWak6xry6AoSeut 5jSzlHhrQLyPZc9XoMq0y2z9ruAvIWu9psP7Ebk= X-Google-Smtp-Source: AGRyM1tlqH8/GM63li+9dtAK0sP+225UJsR/jtnTMd09exzoSTHeAoncSqMSOd4NfnVRj4GYFD3MYUvNG3rNbv4f1SY= X-Received: by 2002:a17:906:d550:b0:704:7ba6:9854 with SMTP id cr16-20020a170906d55000b007047ba69854mr16758726ejc.579.1655639075680; Sun, 19 Jun 2022 04:44:35 -0700 (PDT) MIME-Version: 1.0 References: <20220618165747.55709-1-samuel@sholland.org> <20220618165747.55709-3-samuel@sholland.org> In-Reply-To: <20220618165747.55709-3-samuel@sholland.org> From: Andy Shevchenko Date: Sun, 19 Jun 2022 13:43:59 +0200 Message-ID: Subject: Re: [PATCH v4 2/4] Input: pinephone-keyboard - Add PinePhone keyboard driver To: Samuel Holland Cc: Dmitry Torokhov , linux-input , Linux Kernel Mailing List , Rob Herring , Ondrej Jirman , Krzysztof Kozlowski , devicetree , Andy Shevchenko , Chen-Yu Tsai , Colin Ian King , David Gow , Jernej Skrabec , Krzysztof Kozlowski , Marco Felsch , Mattijs Korpershoek , Stephen Boyd , Yassine Oudjana , "fengping.yu" , linux-arm Mailing List , linux-sunxi@lists.linux.dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220619_044437_946289_2937659C X-CRM114-Status: GOOD ( 22.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Jun 18, 2022 at 7:10 PM Samuel Holland wrote: > > The official Pine64 PinePhone keyboard case contains a matrix keypad and > a MCU which runs a libre firmware. Add support for its I2C interface. ... > +#include > +#include > +#include > +#include > +#include > +#include Missed types.h ... > +#define PPKB_ROWS 6 > +#define PPKB_COLS 12 ... > + for (col = 0; col < PPKB_COLS; ++col) { > + u8 old = old_buf[1 + col]; > + u8 new = new_buf[1 + col]; > + u8 changed = old ^ new; > + > + if (!changed) > + continue; > + > + for (row = 0; row < PPKB_ROWS; ++row) { > + u8 mask = BIT(row); > + u8 value = new & mask; > + unsigned short code; > + bool fn_state; > + > + if (!(changed & mask)) > + continue; > + > + /* > + * Save off the FN key state when the key was pressed, > + * and use that to determine the code during a release. > + */ > + fn_state = value ? ppkb->fn_pressed : ppkb->fn_state[col] & mask; > + if (fn_state) > + ppkb->fn_state[col] ^= mask; Can't it be converted to use bitmap APIs? > + } > + } ... > +static int ppkb_set_scan(struct i2c_client *client, bool enable) > +{ > + struct device *dev = &client->dev; > + int ret, val; > + > + ret = i2c_smbus_read_byte_data(client, PPKB_SYS_CONFIG); > + if (ret < 0) { > + dev_err(dev, "Failed to read config: %d\n", ret); > + return ret; > + } > + > + if (enable) > + val = ret & ~PPKB_SYS_CONFIG_DISABLE_SCAN; > + else > + val = ret | PPKB_SYS_CONFIG_DISABLE_SCAN; > + ret = i2c_smbus_write_byte_data(client, PPKB_SYS_CONFIG, val); > + if (ret) { > + dev_err(dev, "Failed to write config: %d\n", ret); > + return ret; > + } > + > + return 0; return ret; > +} ... > +static int ppkb_open(struct input_dev *input) > +{ > + struct i2c_client *client = input_get_drvdata(input); > + int ret; > + > + ret = ppkb_set_scan(client, true); > + if (ret) > + return ret; > + > + return 0; return ppkb_set_scan(...); > +} -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel