Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1076753pxb; Tue, 9 Nov 2021 04:52:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMS1IedALSFnaxiPLkTMwKHj++JlsFoF5AuVb0bgUg3lEOvFejzlk0PrMqm9bkMnw50ytI X-Received: by 2002:a17:907:9612:: with SMTP id gb18mr9409236ejc.205.1636462371527; Tue, 09 Nov 2021 04:52:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636462371; cv=none; d=google.com; s=arc-20160816; b=dlAqr9zqzprKr1d8UxxW/289VwRzv4hd+9RGd4cu/5pw18oySjWAoO7wzAuKHYu/SO PXkJJwl7Uk0zn2rC6Av2145ITM2tWliCXskXgKI1UkR1JFc6pz6mH2OCw2bdPTeYRl6+ wYFFr16zydYLwBwswk2M5Vrjp56iQ/l5JXRQrwBtnw36cqxR4r6yLT5uNtSVvbCTJCqQ W0nAOwIgLvn4EFHdx6Dr10apERQaWrKKqvrKs99ql8by/HUg6nT7HD27znAWM8BFn2p6 GStc06pELm316JBf5VhEqPnykzmJgag/OyQ56LaBeK6jsNdmjCkAFO1UqQjaEmU4TgIr 6v/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=UxegNfcD59CXLSmdHdqWpFL81/2EPGX8MigazJ437Lo=; b=RnNJxl47CwqkMf0g1Rsg0j4TAl4WFH6IYgJL/aNGDzH+ae8mxG3QeIhlA/Kx4iMv5d E+Zrsr9UptdRP+B/BfFTZLQGb64HWtJJJdl10hI6xT1V+7tMHDHPee1YPTM9VMIzrbNt 19rn13WL3q/Ux2MQizqQvXXxblZvElrvn6WW3oMqBQZqfBKE5Y7gfNAbrRRv8TUa3weR 8BCc2qySa0Zra4dCeJmEq64eL9DWu1k/um8V+nR4lQiAKlWUPNoluRb7wOm48RtbYpJg nniO8OXAD5m/IuWXWQLmEg7e5VQK1XtikfRlPR9XKLqb8kcHoL2cP1r5PvXb5oWSj209 /UbA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si37971850edc.553.2021.11.09.04.52.25; Tue, 09 Nov 2021 04:52:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234897AbhKIDRC (ORCPT + 99 others); Mon, 8 Nov 2021 22:17:02 -0500 Received: from smtprelay0225.hostedemail.com ([216.40.44.225]:51764 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231910AbhKIDRB (ORCPT ); Mon, 8 Nov 2021 22:17:01 -0500 Received: from omf20.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 8B43F1829B8FD; Tue, 9 Nov 2021 03:14:15 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf20.hostedemail.com (Postfix) with ESMTPA id 5E4A218A60C; Tue, 9 Nov 2021 03:14:14 +0000 (UTC) Message-ID: Subject: Re: [PATCH 1/2] erofs: add sysfs interface From: Joe Perches To: Huang Jianan , linux-erofs@lists.ozlabs.org Cc: guoweichao@oppo.com, guanyuwei@oppo.com, yh@oppo.com, zhangshiming@oppo.com, linux-kernel@vger.kernel.org Date: Mon, 08 Nov 2021 19:14:13 -0800 In-Reply-To: <20211109025445.12427-1-huangjianan@oppo.com> References: <20211109025445.12427-1-huangjianan@oppo.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: 5E4A218A60C X-Spam-Status: No, score=-4.15 X-Stat-Signature: 4k1qequtneuzwq7efx34abfoa48qjm1y X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19tC8M+OVunKUJInFptKz4De5mCUJw4EP8= X-HE-Tag: 1636427654-852723 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-11-09 at 10:54 +0800, Huang Jianan wrote: > Add sysfs interface to configure erofs related parameters in the > future. [] > diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c [] > +static ssize_t erofs_attr_show(struct kobject *kobj, > + struct attribute *attr, char *buf) > +{ > + struct erofs_sb_info *sbi = container_of(kobj, struct erofs_sb_info, > + s_kobj); > + struct erofs_attr *a = container_of(attr, struct erofs_attr, attr); > + unsigned char *ptr = __struct_ptr(sbi, a->struct_type, a->offset); > + > + switch (a->attr_id) { > + case attr_feature: > + return snprintf(buf, PAGE_SIZE, "supported\n"); > + case attr_pointer_ui: > + if (!ptr) > + return 0; > + return snprintf(buf, PAGE_SIZE, "%u\n", > + *((unsigned int *) ptr)); Prefer sysfs_emit over snprintf case attr_feature: return sysfs_emit(buf, "supported\n"); case attr_pointer_ui: ... return sysfs_emit(buf, "%u\n", *(unsigned int *)ptr); etc...