Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbdLEI3o (ORCPT ); Tue, 5 Dec 2017 03:29:44 -0500 Received: from mail-os2jpn01on0055.outbound.protection.outlook.com ([104.47.92.55]:38002 "EHLO JPN01-OS2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750810AbdLEI3n (ORCPT ); Tue, 5 Dec 2017 03:29:43 -0500 From: Masaki Ota To: =?utf-8?B?UGFsaSBSb2jDoXI=?= CC: Masaki Ota <012nexus@gmail.com>, "dmitry.torokhov@gmail.com" , "benjamin.tissoires@redhat.com" , "aaron.ma@canonical.com" , "jaak@ristioja.ee" , "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "net147@gmail.com" Subject: RE: [PATCH] Support TrackStick of Thinkpad L570 Thread-Topic: [PATCH] Support TrackStick of Thinkpad L570 Thread-Index: AQHTaOzUDxdK9vCj+kGpYakFxrItJ6Mu/wiAgAOhCsCAAE3tgIAABZ4ggAAFPoCAAXkbsA== Date: Tue, 5 Dec 2017 08:29:37 +0000 Message-ID: References: <20171129083358.5063-1-masaki.ota@jp.alps.com> <20171201210749.el6q62sc22jshwc5@pali> <20171204091153.q2i355gqbmf7dbvk@pali> <20171204095045.lp2vuxtxmmjpsjo7@pali> In-Reply-To: <20171204095045.lp2vuxtxmmjpsjo7@pali> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=masaki.ota@jp.alps.com; x-originating-ip: [106.184.109.136] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;TYXPR01MB0718;20:Jg623Vf/JDTAVHz9An6TVnlEOFFhci//zVI6Wt8YsYpKGAouYbOamALzGaaX2voQMGfx61RyNO7U1Nd6rV14f0wx3mge6IE3pM4/QWAHQ7xMhYdMUDWAdv1NqxmqmOGlZ8sZstT9zB4FYCu6Omuc6rs+A5iP4U8qZIMU9U4d1Qw= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 2620fd78-4369-453c-1a83-08d53bba52cb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603286);SRVR:TYXPR01MB0718; x-ms-traffictypediagnostic: TYXPR01MB0718: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(198206253151910)(9931346810618); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(3231022)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(6072148)(201708071742011);SRVR:TYXPR01MB0718;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:TYXPR01MB0718; x-forefront-prvs: 0512CC5201 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(346002)(39860400002)(376002)(366004)(13464003)(199003)(24454002)(189002)(5660300001)(53936002)(77096006)(3846002)(25786009)(6116002)(6436002)(66066001)(6506006)(2900100001)(99286004)(102836003)(229853002)(9686003)(85182001)(7696005)(39060400002)(54356011)(54906003)(33656002)(97736004)(76176011)(316002)(105586002)(53546010)(14454004)(8936002)(74316002)(93886005)(7736002)(106356001)(101416001)(6246003)(478600001)(4326008)(86362001)(575784001)(6916009)(2906002)(42882006)(3280700002)(2950100002)(3660700001)(189998001)(68736007)(8676002)(81156014)(305945005)(81166006)(55016002);DIR:OUT;SFP:1101;SCL:1;SRVR:TYXPR01MB0718;H:TYXPR01MB0719.jpnprd01.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:0;MX:1;LANG:en; x-microsoft-antispam-message-info: aNzuMP9nPn2qv5TtNPzbkrlU+87NKIO1cm7kRCLuKB77woDOfqgvtb54AVzQ/7orMlBOHzLfJBqmSITEJa1gLNkjMbweokHARbzkNU5+8ratdviurv6iY5mmBZsayUwLcCnpMADnPZJSy/jJFuwzSJrCIOmTG03FxTvuOkKvUjHRBn2hbV1/GffhdKaMpiryFOMCUD0gQJXMLCsA8f88kA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: jp.alps.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2620fd78-4369-453c-1a83-08d53bba52cb X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2017 08:29:37.9603 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 57e76998-77bd-4b82-a424-198f46eb2254 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYXPR01MB0718 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vB58ToLS009337 Content-Length: 5901 Lines: 157 Hi, Pali, OK, I got it. So, the problem of structure will be solved next chance. Best Regards, Masaki Ota -----Original Message----- From: Pali Rohár [mailto:pali.rohar@gmail.com] Sent: Monday, December 04, 2017 6:51 PM To: 太田 真喜 Masaki Ota Cc: Masaki Ota <012nexus@gmail.com>; dmitry.torokhov@gmail.com; benjamin.tissoires@redhat.com; aaron.ma@canonical.com; jaak@ristioja.ee; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH] Support TrackStick of Thinkpad L570 On Monday 04 December 2017 09:40:04 Masaki Ota wrote: > Hi, Pali, > > It does not work in my test result. Hm.. that is strange, we have dangling pointers in struct alps_data? Otherwise I have no idea why does not work. > BTW, other some functions also use both of "struct psmouse" and "struct alps_data" argument. It does not make sense to pass one structure (via pointers) two times. And if this "pattern" is already used in code and reason is that one pointer "does not work" because it is dangling, then it is really wrong. I know it is irrelevant to your patch, but this problem with dangling pointer should be fixed, e.g. in next patches (not in this one). Problems (with memory allocation/pointers) should not be camouflaged. Memory corruption in kernel can lead to fatal problems. > I just followed it. Blindly following bad code is a bad idea. When we see something like this, we should at least stop and ask question "why is this code pattern used?". > Best Regards, > Masaki Ota > -----Original Message----- > From: Pali Rohár [mailto:pali.rohar@gmail.com] > Sent: Monday, December 04, 2017 6:12 PM > To: 太田 真喜 Masaki Ota > Cc: Masaki Ota <012nexus@gmail.com>; dmitry.torokhov@gmail.com; > benjamin.tissoires@redhat.com; aaron.ma@canonical.com; > jaak@ristioja.ee; linux-input@vger.kernel.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH] Support TrackStick of Thinkpad L570 > > On Monday 04 December 2017 04:48:43 Masaki Ota wrote: > > Hi, Pali, > > > > I don't get your point. > > Please modify the code if you have an idea. > > See below > > > Best Regards, > > Masaki Ota > > -----Original Message----- > > From: Pali Rohár [mailto:pali.rohar@gmail.com] > > Sent: Saturday, December 02, 2017 6:08 AM > > To: Masaki Ota <012nexus@gmail.com> > > Cc: dmitry.torokhov@gmail.com; benjamin.tissoires@redhat.com; > > aaron.ma@canonical.com; jaak@ristioja.ee; 太田 真喜 Masaki Ota > > ; linux-input@vger.kernel.org; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH] Support TrackStick of Thinkpad L570 > > > > On Wednesday 29 November 2017 17:33:58 Masaki Ota wrote: > > > From: Masaki Ota > > > - The issue is that Thinkpad L570 TrackStick does not work. Because the main interface of Thinkpad L570 device is SMBus, so ALPS overlooked PS2 interface Firmware setting of TrackStick. The detail is that TrackStick otp bit is disabled. > > > - Add the code that checks 0xD7 address value. This value is device number information, so we can identify the device by checking this value. > > > - If we check 0xD7 value, we need to enable Command mode and after check the value we need to disable Command mode, then we have to enable the device(0xF4 command). > > > - Thinkpad L570 device number is 0x0C or 0x1D. If it is TRUE, enable ALPS_DUALPOINT flag. > > > > > > Signed-off-by: Masaki Ota > > > --- > > > drivers/input/mouse/alps.c | 24 +++++++++++++++++++++--- > > > 1 file changed, 21 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/input/mouse/alps.c > > > b/drivers/input/mouse/alps.c index 850b00e3ad8e..6f092bdd9fc5 > > > 100644 > > > --- a/drivers/input/mouse/alps.c > > > +++ b/drivers/input/mouse/alps.c > > > @@ -2541,13 +2541,31 @@ static int > > > alps_update_btn_info_ss4_v2(unsigned char otp[][4], } > > > > > > static int alps_update_dual_info_ss4_v2(unsigned char otp[][4], > > > - struct alps_data *priv) > > > + struct alps_data *priv, > > > + struct psmouse *psmouse) > > > { > > You can access psmouse from the priv structure as: > > struct psmouse *psmouse = priv->psmouse; > > Therefore you do not have to extend function parameters with psmouse pointer as that is already present int alps_data. > > struct alps_data is defined as: > > struct alps_data { > struct psmouse *psmouse; > ... > } > > > > bool is_dual = false; > > > + int reg_val = 0; > > > + struct ps2dev *ps2dev = &psmouse->ps2dev; > > > > > > - if (IS_SS4PLUS_DEV(priv->dev_id)) > > > + if (IS_SS4PLUS_DEV(priv->dev_id)) { > > > is_dual = (otp[0][0] >> 4) & 0x01; > > > > > > + if (!is_dual) { > > > + /* For support TrackStick of Thinkpad L/E series */ > > > + if (alps_exit_command_mode(psmouse) == 0 && > > > + alps_enter_command_mode(psmouse) == 0) { > > > + reg_val = alps_command_mode_read_reg(psmouse, > > > + 0xD7); > > > + } > > > + alps_exit_command_mode(psmouse); > > > + ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE); > > > + > > > + if (reg_val == 0x0C || reg_val == 0x1D) > > > + is_dual = true; > > > + } > > > + } > > > + > > > if (is_dual) > > > priv->flags |= ALPS_DUALPOINT | > > > ALPS_DUALPOINT_WITH_PRESSURE; @@ -2570,7 +2588,7 @@ static > > > int alps_set_defaults_ss4_v2(struct psmouse *psmouse, > > > > > > alps_update_btn_info_ss4_v2(otp, priv); > > > > > > - alps_update_dual_info_ss4_v2(otp, priv); > > > + alps_update_dual_info_ss4_v2(otp, priv, psmouse); > > > > Now looking at this change... Is there reason why you are passing psmouse parameter there? Because struct alps_data contains psmouse member. > > > > > > > > return 0; > > > } > > > > -- > > Pali Rohár > > pali.rohar@gmail.com > > -- > Pali Rohár > pali.rohar@gmail.com -- Pali Rohár pali.rohar@gmail.com