mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-10 07:50:04 +00:00
gpio: sim: fix hogs with custom chip labels
We always assign the default device name as the chip_label in hog structures which makes it impossible to assign hogs to chips. Let's first check if a custom label was set and then copy it instead of the default device name. Fixes: cb8c474e79be ("gpio: sim: new testing module") Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
This commit is contained in:
parent
cc38ef9368
commit
c162ca0bcb
@ -570,6 +570,11 @@ static struct gpio_sim_bank *to_gpio_sim_bank(struct config_item *item)
|
|||||||
return container_of(group, struct gpio_sim_bank, group);
|
return container_of(group, struct gpio_sim_bank, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool gpio_sim_bank_has_label(struct gpio_sim_bank *bank)
|
||||||
|
{
|
||||||
|
return bank->label && *bank->label;
|
||||||
|
}
|
||||||
|
|
||||||
static struct gpio_sim_device *
|
static struct gpio_sim_device *
|
||||||
gpio_sim_bank_get_device(struct gpio_sim_bank *bank)
|
gpio_sim_bank_get_device(struct gpio_sim_bank *bank)
|
||||||
{
|
{
|
||||||
@ -770,9 +775,15 @@ static int gpio_sim_add_hogs(struct gpio_sim_device *dev)
|
|||||||
* point the device doesn't exist yet and so dev_name()
|
* point the device doesn't exist yet and so dev_name()
|
||||||
* is not available.
|
* is not available.
|
||||||
*/
|
*/
|
||||||
hog->chip_label = kasprintf(GFP_KERNEL,
|
if (gpio_sim_bank_has_label(bank))
|
||||||
"gpio-sim.%u-%s", dev->id,
|
hog->chip_label = kstrdup(bank->label,
|
||||||
fwnode_get_name(bank->swnode));
|
GFP_KERNEL);
|
||||||
|
else
|
||||||
|
hog->chip_label = kasprintf(GFP_KERNEL,
|
||||||
|
"gpio-sim.%u-%s",
|
||||||
|
dev->id,
|
||||||
|
fwnode_get_name(
|
||||||
|
bank->swnode));
|
||||||
if (!hog->chip_label) {
|
if (!hog->chip_label) {
|
||||||
gpio_sim_remove_hogs(dev);
|
gpio_sim_remove_hogs(dev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -816,7 +827,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
|
|||||||
|
|
||||||
properties[prop_idx++] = PROPERTY_ENTRY_U32("ngpios", bank->num_lines);
|
properties[prop_idx++] = PROPERTY_ENTRY_U32("ngpios", bank->num_lines);
|
||||||
|
|
||||||
if (bank->label && (strlen(bank->label) > 0))
|
if (gpio_sim_bank_has_label(bank))
|
||||||
properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label",
|
properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label",
|
||||||
bank->label);
|
bank->label);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user