Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp119602pxb; Mon, 25 Oct 2021 05:07:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVLEdwqN18U6tR+0O6jacJvQqaVAWCXmkgnbqFRGxpf6yZUeIgSup1QXBm6PF6vbhrs5iG X-Received: by 2002:a50:e044:: with SMTP id g4mr25599863edl.46.1635163673437; Mon, 25 Oct 2021 05:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635163673; cv=none; d=google.com; s=arc-20160816; b=MVE3cfKHMnZdWb6nrFVYKLrxQRComs9t5VYVX/eKhWughtk2173aCLNQXMIf+huaJ/ CvottAhSao5yioGxR6C/1myH6t0vsZnkSrxKkJ96yFLqgs1lC+ME1fWMUCU8YYsEW8hL J18bv1kvc760LdLqbUCT5KG0cIE3BL1fIofCLdAJGQwtyt8+1UEeu9Wfybt1cqOVfGt5 KHIvyqN7Rtqn+18K4RlUeWg795bhLYE8a+D+Y9pVQPEgsBVfG8+Wh8c583T3L3wvKMhp t7u+uo5pcGvn/By4yYjIczwZQ6iBMkMp1A4jj/DBAlUauuE4jSBP2gDnyqa0EkXbqsnP RQeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=h4bWF2ilnpVDva88taAGnZTLJCyflbbTnOcr/iOQ1m8=; b=vHcSSwp9DRmAowS+swHKW/XecCphzEKcM4Yl0w/JIctUFORsxHZT7sDZUfLpq53eSU wAe1B/DIvts+DgDAH6LuCu/pLh3X+jTykq+iA8GIkjlKIWOTQnTJ1L0UztR3oeRChyj7 Y4wzBJ9M5/59seksIprudR3N2M3B+AJMka71FlGbUMLjOkF791Glg61rjgIZW07gOrne q1D8u2aFcUEmF7LViySP81Z+01EDSUmmPIxk7WXZJsjadjDxHHXfe+yVipUIdFDqDsR6 W/gR/32WKjCUX4x3iJTwEFDAaM6/XYt5sjJNTWQ2o6Jhkvi/vkTSe6enIBj8AawEMwjP 2pvQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dz20si13115edb.535.2021.10.25.05.07.14; Mon, 25 Oct 2021 05:07:53 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbhJYMFy (ORCPT + 99 others); Mon, 25 Oct 2021 08:05:54 -0400 Received: from mga14.intel.com ([192.55.52.115]:24240 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbhJYMFv (ORCPT ); Mon, 25 Oct 2021 08:05:51 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10147"; a="229903341" X-IronPort-AV: E=Sophos;i="5.87,180,1631602800"; d="scan'208";a="229903341" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2021 05:03:28 -0700 X-IronPort-AV: E=Sophos;i="5.87,180,1631602800"; d="scan'208";a="446201127" Received: from smile.fi.intel.com ([10.237.72.184]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2021 05:03:27 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1meyh0-000c18-2u; Mon, 25 Oct 2021 15:03:06 +0300 Date: Mon, 25 Oct 2021 15:03:05 +0300 From: "andriy.shevchenko" To: "changlianzhi@uniontech.com" Cc: linux-kernel , "dmitry.torokhov" , gregkh , jirislaby , 282827961 <282827961@qq.com> Subject: Re: [PATCH v6] tty: Fix the keyboard led light display problem Message-ID: References: <20211021020511.18016-1-changlianzhi@uniontech.com> <202110250129181502896@uniontech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202110250129181502896@uniontech.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 25, 2021 at 01:29:18AM +0800, changlianzhi@uniontech.com wrote: > >>On Thu, Oct 21, 2021 at 10:05:11AM +0800, lianzhi chang wrote: > >> Switching from the desktop environment to the tty environment, > >> the state of the keyboard led lights and the state of the keyboard > >> lock are inconsistent. This is because the attribute kb->kbdmode > >> of the tty bound in the desktop environment (xorg) is set to > >> VC_OFF, which causes the ledstate and kb->ledflagstate > >> values of the bound tty to always be 0, which causes the switch > >> from the desktop When to the tty environment, the LED light > >> status is inconsistent with the keyboard lock status. > > >... > > >> + unsigned long leds; > >> + > >> + leds = (unsigned long)ledstate; > > >Can be one line. > > >But most important question you are ignoring to answer / address is why do you > >use casting? > >>But most important question you are ignoring to answer / address is why do you > >>use casting? > Casting is used here because: > The second parameter of test_bit is "volatile unsigned long *addr" (see constant_test_bit() in /arch/x86/include/asm/bitops.h), but ledstate is an "unsigned int" type. If casting is not used, > compile Will report an error. Wait, you are casting pointer to an integer?! This is completely wrong in this case! -- With Best Regards, Andy Shevchenko