lkml.org 
[lkml]   [2019]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 1/2] firmware: google: Expose CBMEM over sysfs
On Thu, Nov 28, 2019 at 01:50:50PM +0100, patrick.rudolph@9elements.com wrote:
> +static int cbmem_probe(struct coreboot_device *cdev)
> +{
> + struct device *dev = &cdev->dev;
> + struct cb_priv *priv;
> + int err;
> +
> + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + memcpy(&priv->entry, &cdev->cbmem_entry, sizeof(priv->entry));
> +
> + priv->remap = memremap(priv->entry.address,
> + priv->entry.entry_size, MEMREMAP_WB);
> + if (!priv->remap) {
> + err = -ENOMEM;
> + goto failure;
> + }
> +
> + err = sysfs_create_group(&dev->kobj, &cb_mem_attr_group);

You just raced with userspace and lost :(

Set the driver's default attribute group up to point at
cb_mem_attr_group and the driver core will handle creating and removing
the group automatically for you correctly.

thanks,

greg k-h

\
 
 \ /
  Last update: 2019-12-19 18:17    [W:1.140 / U:1.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site