Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4187540pxb; Sun, 14 Feb 2021 01:55:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUItQ1OFkVGpHkmZbHm5rOxJv0A7ULqDkSyziixg9ywKGxXdHLy+iql91dvIBF4CgBi2u/ X-Received: by 2002:a05:6402:10c8:: with SMTP id p8mr10582885edu.144.1613296519368; Sun, 14 Feb 2021 01:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613296519; cv=none; d=google.com; s=arc-20160816; b=zdBX1iFyEWnL7PoKGooWZHgPaFbL1uCohg/WNc+8TAxtjitXy8+/r4ZYosasLBQRyq 9WM9Qg1VpVWsS3HrIxo9iZ/m9/OIIGNh5NerqCnzCT2fUwyhsAOkP87OUdt/OwqnHCuU gr/BnUfr1MiwV/5MQcWfvZUbecmtgcPWkpNkyf0KCMYPa6z1J3b23XC+ioI2lctIEcQc 5PjbgGStcpPGKDt4YzgVAYKaqfY8cUYHRpYWYaP1p3kAiJ9d527vlNMQ67ps5fwoQcLK PO5Mz54xERvC1a/FU0BLQTuOSo/L/FSHxpO7CpIS9Ov2dakzIyI5m8NNxvzs+BD4Z0by 8S9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EuL2O4wVZ1ifAgqf2ytmcugYPXkQRyxgbfuk04WJO7o=; b=B67VfjkBEmZQowy/r/kvWLNcTm/KpEiBYnybnF2rrlAS3O0XFQkRSx3AyT3oaYErWq 4ViPHylG95Wtk4h+b6pjs64cm5tdMOpsTaqff3B2V93Bsjxzf6K557HhZqbUms4/gUAH 6lfryZFWv/Nldhnzuy6nwYwcW7Dd3n77NO2Mq7+gqPVcZm5bG3uBiCTpHhEWWUjNj9KB JZ+ZObB7WdjTAa/n1edYIxDVHvn5zIUZCIHIwHGf6THJTGcMBtbD4fpKsh6fgskEArJ7 00jQbzWc6kDS33f43ZnX4MgvPoRngkXPmrLqPJmNApquW2kBWkOijWmuR2IbFs032Gpq JO4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pZ6hJFFO; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si10792368ejt.11.2021.02.14.01.54.55; Sun, 14 Feb 2021 01:55:19 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=pZ6hJFFO; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbhBNJya (ORCPT + 99 others); Sun, 14 Feb 2021 04:54:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:55956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbhBNJy3 (ORCPT ); Sun, 14 Feb 2021 04:54:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C06BA64E08; Sun, 14 Feb 2021 09:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613296428; bh=P7YH5U72rLYY0NLz86z2yrEBx/saP1+3AifXty9JevQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pZ6hJFFOa/FRrqi/XhUc/S6Ef4mCS/qbHCuBXiAl/4DnhI2SMjC3oqEkuEZf2hdUY SW7Xe895SVpfztfh96pyArBQE6JjBtUAsqypQ5Wllb4DZNpoPYJRjdWbhQoeh3Q1Hj esjMZf9RsAAb1GcI5ZWtztMLGgsTlhouMDjfjtAE= Date: Sun, 14 Feb 2021 10:53:44 +0100 From: Greg KH To: Bart Van Assche Cc: Arthur Simchaev , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, alim.akhtar@samsung.com, Bean Huo , Arthur Simchaev Subject: Re: [PATCH] scsi: ufs: sysfs: add is_ascii_output entry Message-ID: References: <1612954425-6705-1-git-send-email-Arthur.Simchaev@sandisk.com> <4bba4245-df01-f23d-65ba-4ff133cae0bc@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4bba4245-df01-f23d-65ba-4ff133cae0bc@acm.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 07:35:25PM -0800, Bart Van Assche wrote: > On 2/10/21 2:53 AM, Arthur Simchaev wrote: > > +static bool is_ascii_output = true; > > [ ... ] > > > static const char *ufschd_uic_link_state_to_string( > > enum uic_link_state state) > > { > > @@ -693,7 +695,15 @@ static ssize_t _name##_show(struct device *dev, \ > > SD_ASCII_STD); \ > > if (ret < 0) \ > > goto out; \ > > - ret = sysfs_emit(buf, "%s\n", desc_buf); \ > > + if (is_ascii_output) { \ > > + ret = sysfs_emit(buf, "%s\n", desc_buf); \ > > + } else { \ > > + int i; \ > > + \ > > + for (i = 0; i < desc_buf[0]; i++) \ > > + hex_byte_pack(buf + i * 2, desc_buf[i]); \ > > + ret = sysfs_emit(buf, "%s\n", buf); \ > > + } \ > > out: \ > > pm_runtime_put_sync(hba->dev); \ > > kfree(desc_buf); \ > > Please do not introduce a mode variable but instead introduce a new > attribute such that there is one attribute for the unicode output and > one attribute for the ASCII output. Mode variables are troublesome when > e.g. two scripts try to set the mode attribute concurrently. Agreed, just make a new sysfs file, please never change the output of an existing sysfs file, that way will guarantee confusion in userspace. thanks, greg k-h