From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Bottomley Subject: Re: [PATCH] tpm: Add sysfs interface to show TPM family version Date: Mon, 13 Mar 2017 11:46:11 -0700 Message-ID: <1489430771.23810.5.camel@HansenPartnership.com> References: <1489396817-24855-1-git-send-email-Meng.Li@windriver.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1489396817-24855-1-git-send-email-Meng.Li-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Meng.Li-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: tpmdd-devel@lists.sourceforge.net On Mon, 2017-03-13 at 17:20 +0800, Meng.Li-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org wrote: [...] > +/** > + * tpm_create_sysfs - Create tpm sysfs interface. > + * @dev: pointer to tpm chip device > + * > + * Create sysfs interface for checking current TPM hardware version. > + */ > +static int tpm_create_sysfs(struct device *dev) > +{ > + int r, t; > + > + for (t = 0; t < ARRAY_SIZE(tpm_attrs); t++) { > + r = device_create_file(dev, &tpm_attrs[t]); > + if (r) { > + dev_err(dev, "failed to create sysfs > file\n"); > + return r; > + } > + } > + > + return 0; > +} > + > +/** > + * tpm_remove_sysfs - Remove tpm sysfs interface. > + * @dev: pointer to tpm chip device > + * > + * Remove sysfs interface for checking current TPM hardware version. > + */ > +static void tpm_remove_sysfs(struct device *dev) > +{ > + int t; > + > + for (t = 0; t < ARRAY_SIZE(tpm_attrs); t++) { > + device_remove_file(dev, &tpm_attrs[t]); > + } > +} > + For non-dynamic attributes, use the attribute_group structure in the device instead. It will take care of creation and removal automatically. James ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752925AbdCMSqa (ORCPT ); Mon, 13 Mar 2017 14:46:30 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:58202 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752062AbdCMSqP (ORCPT ); Mon, 13 Mar 2017 14:46:15 -0400 Message-ID: <1489430771.23810.5.camel@HansenPartnership.com> Subject: Re: [tpmdd-devel] [PATCH] tpm: Add sysfs interface to show TPM family version From: James Bottomley To: Meng.Li@windriver.com, linux-kernel@vger.kernel.org Cc: tpmdd-devel@lists.sourceforge.net Date: Mon, 13 Mar 2017 11:46:11 -0700 In-Reply-To: <1489396817-24855-1-git-send-email-Meng.Li@windriver.com> References: <1489396817-24855-1-git-send-email-Meng.Li@windriver.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-03-13 at 17:20 +0800, Meng.Li@windriver.com wrote: [...] > +/** > + * tpm_create_sysfs - Create tpm sysfs interface. > + * @dev: pointer to tpm chip device > + * > + * Create sysfs interface for checking current TPM hardware version. > + */ > +static int tpm_create_sysfs(struct device *dev) > +{ > + int r, t; > + > + for (t = 0; t < ARRAY_SIZE(tpm_attrs); t++) { > + r = device_create_file(dev, &tpm_attrs[t]); > + if (r) { > + dev_err(dev, "failed to create sysfs > file\n"); > + return r; > + } > + } > + > + return 0; > +} > + > +/** > + * tpm_remove_sysfs - Remove tpm sysfs interface. > + * @dev: pointer to tpm chip device > + * > + * Remove sysfs interface for checking current TPM hardware version. > + */ > +static void tpm_remove_sysfs(struct device *dev) > +{ > + int t; > + > + for (t = 0; t < ARRAY_SIZE(tpm_attrs); t++) { > + device_remove_file(dev, &tpm_attrs[t]); > + } > +} > + For non-dynamic attributes, use the attribute_group structure in the device instead. It will take care of creation and removal automatically. James