From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Chanwoo Choi <cw00.choi@samsung.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Subject: [PATCH v2 2/5] extcon: Get rid of not really used name field in struct extcon_dev
Date: Wed, 5 Apr 2023 18:27:42 +0300 [thread overview]
Message-ID: <20230405152745.24959-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20230405152745.24959-1-andriy.shevchenko@linux.intel.com>
The name field is always set to the parent device name and never
altered. No need to keep it inside the struct extcon_dev as we
always may derive it from the dev_name(edev->dev.parent) call.
Moreover, the parent device pointer won't ever be NULL, otherwise
we may not allocate the extcon device at all.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/extcon/extcon.c | 12 +++---------
drivers/extcon/extcon.h | 3 ---
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 47819c5144d5..75a0147703c0 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -387,7 +387,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr,
{
struct extcon_dev *edev = dev_get_drvdata(dev);
- return sysfs_emit(buf, "%s\n", edev->name);
+ return sysfs_emit(buf, "%s\n", dev_name(edev->dev.parent));
}
static DEVICE_ATTR_RO(name);
@@ -885,7 +885,7 @@ struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
mutex_lock(&extcon_dev_list_lock);
list_for_each_entry(sd, &extcon_dev_list, entry) {
- if (!strcmp(sd->name, extcon_name))
+ if (device_match_name(sd->dev.parent, extcon_name))
goto out;
}
sd = ERR_PTR(-EPROBE_DEFER);
@@ -1269,12 +1269,6 @@ int extcon_dev_register(struct extcon_dev *edev)
edev->dev.class = extcon_class;
edev->dev.release = extcon_dev_release;
- edev->name = dev_name(edev->dev.parent);
- if (IS_ERR_OR_NULL(edev->name)) {
- dev_err(&edev->dev,
- "extcon device name is null\n");
- return -EINVAL;
- }
dev_set_name(&edev->dev, "extcon%lu",
(unsigned long)atomic_inc_return(&edev_no));
@@ -1465,7 +1459,7 @@ EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
*/
const char *extcon_get_edev_name(struct extcon_dev *edev)
{
- return !edev ? NULL : edev->name;
+ return edev ? dev_name(edev->dev.parent) : NULL;
}
EXPORT_SYMBOL_GPL(extcon_get_edev_name);
diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h
index 49e4ed9f6450..9ce7042606d7 100644
--- a/drivers/extcon/extcon.h
+++ b/drivers/extcon/extcon.h
@@ -6,8 +6,6 @@
/**
* struct extcon_dev - An extcon device represents one external connector.
- * @name: The name of this extcon device. Parent device name is
- * used if NULL.
* @supported_cable: Array of supported cable names ending with EXTCON_NONE.
* If supported_cable is NULL, cable name related APIs
* are disabled.
@@ -40,7 +38,6 @@
*/
struct extcon_dev {
/* Optional user initializing data */
- const char *name;
const unsigned int *supported_cable;
const u32 *mutually_exclusive;
--
2.40.0.1.gaa8946217a0b
next prev parent reply other threads:[~2023-04-05 15:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 15:27 [PATCH v2 0/5] extcon: Core cleanups and documentation fixes Andy Shevchenko
2023-04-05 15:27 ` [PATCH v2 1/5] extcon: Make the allocation and freeing to be private calls Andy Shevchenko
2023-04-06 19:19 ` Chanwoo Choi
2023-04-05 15:27 ` Andy Shevchenko [this message]
2023-04-06 19:26 ` [PATCH v2 2/5] extcon: Get rid of not really used name field in struct extcon_dev Chanwoo Choi
2023-04-11 11:37 ` Andy Shevchenko
2023-04-11 11:42 ` Andy Shevchenko
2023-04-05 15:27 ` [PATCH v2 3/5] extcon: Use unique number for the extcon device ID Andy Shevchenko
2023-04-05 15:27 ` [PATCH v2 4/5] extcon: Use sizeof(*pointer) instead of sizeof(type) Andy Shevchenko
2023-04-06 19:33 ` Chanwoo Choi
2023-04-05 15:27 ` [PATCH v2 5/5] extcon: Drop unneeded assignments Andy Shevchenko
2023-04-06 19:35 ` Chanwoo Choi
2023-04-11 11:43 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230405152745.24959-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=cw00.choi@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox