Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1414380pxj; Fri, 21 May 2021 13:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyruH2gwyw+t6G3cfUXKsyyzyPJuAOw2sVl2dA5jS034hjVEIqY7CnhUDn23obj/wvtIuCo X-Received: by 2002:a6b:ec0b:: with SMTP id c11mr684458ioh.99.1621629860069; Fri, 21 May 2021 13:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621629860; cv=none; d=google.com; s=arc-20160816; b=IoSvRHwqPoWZeVEOEE/tXaxcCcKpkUZiMXruroDs8IylpxWhcIwB+1Z4bkpY3jPsoI 3jT8X3hQF3xaU4tTjosweEtpH0MF7cIKPHARk9J+4gpVZJJj4Rf2P0tmz9u6MF0UDZl/ zUqJErDznZDso+RHNGSdjIz9jBtscb/cybg/x1SSfpBEu/jZIosUID7joIzfft/lsYY0 TveAIf/89wJbnhTkNXQtKpGjbHf4QTH4MvCx4tJzOYhM8Lj61F4/+68chehwu69tXeZp 01uPef9eCySaz9J9SRL/ym9j4SFqg0AvvKR0MaZZJXLULavxMtpwMO0MIR5UfdkjTxNX vLZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:dkim-signature; bh=n8Z/QXHnUfTkXQhNoayjp7WtOt3kAL1EVir5n540m8E=; b=V57ys+/M6HHfhJkw69b7pVZZD5lt0J0auDYpEeEWu8ggaDHJoyJHmmpfIsPZ3GmxcE i6QUV8+olq5P/J+IkD7X4iTXEI1TuoqT322Gqjx5JrQgyKZpPlUGHZTLBuIccTiYkRrN IYmVNOIc1DtwJSEfUJcTmRVShjFoCYWDkY7y4Qp5807T4r/4FQLrdb8YQ62ZjoXFI5Fk V2kgcBEOpiNyHYjT8OwzH7NeA7lse2mZBDnE17Qyq62xW4Jd7mbBezI8k58vOELbu/xc 2tS28TPb+W2CvsXuNZ/ZFSyQt2EshHjPYjDdAPqWRm0QaWcM5uAxxhHAvLOzHHj1Ey7+ MyNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UDYNF133; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p10si6618223ilq.156.2021.05.21.13.44.06; Fri, 21 May 2021 13:44:20 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UDYNF133; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236404AbhEUSpd (ORCPT + 99 others); Fri, 21 May 2021 14:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbhEUSpc (ORCPT ); Fri, 21 May 2021 14:45:32 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F211C061574 for ; Fri, 21 May 2021 11:44:08 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id d11so21961796wrw.8 for ; Fri, 21 May 2021 11:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=n8Z/QXHnUfTkXQhNoayjp7WtOt3kAL1EVir5n540m8E=; b=UDYNF1331XPzsY7GSP0dE2lpiY6kPJq5qmHwJqFgHsF7bcC/og12pEi7gt1PdLqvhc SK1IEV0vMHj1AEqqrPhcvfbkgyXGn/l02UYFAqa+3Xznl0FYMe7jPrtkspQoaZ/OIDn4 YXJwz6cNnandUu9EgnICKeUCykKhF/6qaPXBk5CdnE1jbeY8DLV+mz/xBLuXYuNCHkYp +nqmUDaUc6tUAibpwpEQ/c6GRqxn2JCZYa+AVgMZ1R2e9rMTff+6z2ImU9nkCtkYPXIP 67z4P7vlVNcMO7F5PJLna5knS8UqSs5wGGN5OHpLAOpwFx2mj4yPg4ECkEexc66qlovg i3Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=n8Z/QXHnUfTkXQhNoayjp7WtOt3kAL1EVir5n540m8E=; b=nXWq3s+DFF9BJ2/nrt01/EkAYmHyvwXfGNCb2sNjEHQK6D80365Yf5lUxVhUpNyVSV w5NWVRnZ52AZoNPsD+BkRx6jzxm8IHdP/oglIjAYBKggXYP/b2iW0JL7siugD7whXYae KpkxlNcoinBphbR0zKdbecZwWcwI8aPVOezjJWGWByMu9hRluzIuknzO0jOBcRBRG5Vj 4LQ9SOsPioFSqwoaBWW8HjPDwZqFxp23Div9Yl4W3QMIE1ogsf18jRU1xT2yUfQRP8FG MHyqCz3elgOLQYLK90+JIdDOMxHga2FDrGHPvhN0r+jUVd+AB15UdlNIGoKqjoIrV9NS PpQg== X-Gm-Message-State: AOAM5308XRZg+n4vWozCNAfFHOufYdBzQPC8k8hj1OuUr30Vqi62hdfb 278cmvI42aH4OJEk24zCJ8A= X-Received: by 2002:a05:6000:551:: with SMTP id b17mr10867623wrf.32.1621622646995; Fri, 21 May 2021 11:44:06 -0700 (PDT) Received: from ?IPv6:2003:ea:8f38:4600:3901:4092:a56:60d4? (p200300ea8f384600390140920a5660d4.dip0.t-ipconnect.de. [2003:ea:8f38:4600:3901:4092:a56:60d4]) by smtp.googlemail.com with ESMTPSA id n10sm2865953wrw.37.2021.05.21.11.44.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 May 2021 11:44:06 -0700 (PDT) Subject: Re: [PATCH v2] eeprom: ee1004: Let device core handle attribute eeprom From: Heiner Kallweit To: Arnd Bergmann , "Rafael J. Wysocki" Cc: Linux Kernel Mailing List , Greg Kroah-Hartman References: <66e9f6e5-fdee-6963-6131-228c69705350@gmail.com> <082be5db-46ef-6ddd-c33f-b30d5037a3f5@gmail.com> Message-ID: Date: Fri, 21 May 2021 20:43:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <082be5db-46ef-6ddd-c33f-b30d5037a3f5@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Greg added his Reviewed-by to v1, so you may disregard v2. On 20.05.2021 21:25, Heiner Kallweit wrote: > Instead of creating/removing the attribute ourselves, just declare the > attribute and let the device core handle it. This allows to simplify > the code. > > Signed-off-by: Heiner Kallweit > --- > v2: > - open-code the proposed BIN_ATTRIBUTES_GROUPS macro > I leave it to you which version you prefer. > --- > drivers/misc/eeprom/ee1004.c | 30 +++++++++++++----------------- > 1 file changed, 13 insertions(+), 17 deletions(-) > > diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c > index 252e15ba6..d61acdaba 100644 > --- a/drivers/misc/eeprom/ee1004.c > +++ b/drivers/misc/eeprom/ee1004.c > @@ -89,7 +89,7 @@ static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf, > return status; > } > > -static ssize_t ee1004_read(struct file *filp, struct kobject *kobj, > +static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, > struct bin_attribute *bin_attr, > char *buf, loff_t off, size_t count) > { > @@ -160,15 +160,19 @@ static ssize_t ee1004_read(struct file *filp, struct kobject *kobj, > return requested; > } > > -static const struct bin_attribute eeprom_attr = { > - .attr = { > - .name = "eeprom", > - .mode = 0444, > - }, > - .size = EE1004_EEPROM_SIZE, > - .read = ee1004_read, > +static BIN_ATTR_RO(eeprom, EE1004_EEPROM_SIZE); > + > +static struct bin_attribute *ee1004_attrs[] = { > + &bin_attr_eeprom, > + NULL > +}; > + > +static const struct attribute_group ee1004_group = { > + .bin_attrs = ee1004_attrs, > }; > > +__ATTRIBUTE_GROUPS(ee1004); > + > static int ee1004_probe(struct i2c_client *client, > const struct i2c_device_id *id) > { > @@ -222,11 +226,6 @@ static int ee1004_probe(struct i2c_client *client, > ee1004_current_page); > mutex_unlock(&ee1004_bus_lock); > > - /* Create the sysfs eeprom file */ > - err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr); > - if (err) > - goto err_clients_lock; > - > dev_info(&client->dev, > "%u byte EE1004-compliant SPD EEPROM, read-only\n", > EE1004_EEPROM_SIZE); > @@ -237,8 +236,6 @@ static int ee1004_probe(struct i2c_client *client, > > return 0; > > - err_clients_lock: > - mutex_lock(&ee1004_bus_lock); > err_clients: > if (--ee1004_dev_count == 0) { > for (cnr--; cnr >= 0; cnr--) { > @@ -255,8 +252,6 @@ static int ee1004_remove(struct i2c_client *client) > { > int i; > > - sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr); > - > /* Remove page select clients if this is the last device */ > mutex_lock(&ee1004_bus_lock); > if (--ee1004_dev_count == 0) { > @@ -275,6 +270,7 @@ static int ee1004_remove(struct i2c_client *client) > static struct i2c_driver ee1004_driver = { > .driver = { > .name = "ee1004", > + .dev_groups = ee1004_groups, > }, > .probe = ee1004_probe, > .remove = ee1004_remove, >